Skip to content

Improve XML Processing documentation#550

Open
LakshanWeerasinghe wants to merge 4 commits into
wso2:mainfrom
LakshanWeerasinghe:xml-transform
Open

Improve XML Processing documentation#550
LakshanWeerasinghe wants to merge 4 commits into
wso2:mainfrom
LakshanWeerasinghe:xml-transform

Conversation

@LakshanWeerasinghe

@LakshanWeerasinghe LakshanWeerasinghe commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Overview

Rewrites the XML Processing page (en/docs/develop/transform/xml.md) into a comprehensive, task-oriented guide covering how to construct, read, transform, and
validate XML in WSO2 Integrator. The page grows from 483 to ~1,160 lines, and every task now ships paired Visual Designer and Ballerina Code tabs so both
low-code and pro-code users are covered. Adds 8 supporting screenshots.

Structure change

The previous flat layout (XML literals, navigating, namespaces, iterating, mutation, conversions) is reorganized into four developer-question sections:

Section Covers
Construct Building XML payloads, dynamic ${} interpolation, namespaces (module- and function-level scope)
Read and query Navigation expressions, accessing attributes, filtering by attribute value, iterating over sequences
Transform Mutating elements, concatenation, XSLT, XML↔record, parsing from string/bytes/stream, XML↔JSON
Validate XSD schema validation

New content

  • Visual Designer tabs for every task (previously code-only), with step-by-step UI instructions and screenshots.
  • Accessing attributes — attribute expressions (x.attr, x?.attr) and getAttributes().
  • Filtering elements by attribute value — query expressions over navigation results, plus positional access.
  • XSLT transformation — transform XML to HTML/text with an XSL stylesheet (xslt:transform).
  • Parsing XML from strings, bytes, and streamsparseString, parseBytes, parseStream.
  • XSD schema validationxmldata:validate against an .xsd file path or a record type, returning () on success or an xmldata:Error on failure.
  • 8 screenshots under en/static/img/develop/transform/xml/.

Summary by CodeRabbit

  • Documentation
    • Significantly refreshed the XML processing guide with reorganized sections and clearer, end-to-end examples.
    • Expanded coverage for XML construction, namespaces, navigation, querying, and iterating over XML sequences.
    • Added/updated guidance for attribute access (including optional expressions), filtering by attribute values, and extracting text/values.
    • Improved transformation, XML parsing from strings/bytes/streams, XML↔JSON and record↔XML workflows, and XSD schema validation examples.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a43869e7-9902-46b8-b4e5-d974a29b66aa

📥 Commits

Reviewing files that changed from the base of the PR and between a067557 and ed5c14e.

⛔ Files ignored due to path filters (16)
  • en/static/img/develop/transform/xml/data-mapper-xml-to-record.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/flow-xml-parse-step.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/toXml-flow.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/toXml-function.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/types-import-tab.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-iterating-flow.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-literals-dynamic-panel.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-literals-flow.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-mutation-flow.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-mutation-function.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-namespaces-flow.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-navigating-child-panel.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-navigating-flow.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-parseAsType.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-text-comments-flow.png is excluded by !**/*.png
  • en/static/img/develop/transform/xml/xml-to-json.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • en/docs/develop/transform/xml.md
💤 Files with no reviewable changes (1)
  • en/docs/develop/transform/xml.md

📝 Walkthrough

Walkthrough

The XML processing documentation page (en/docs/develop/transform/xml.md) is substantially rewritten. It adds front-matter keywords, rewrites the Construct, Namespaces, Navigating XML, attribute access, filtering, iteration, Transform, XML-to-record, record-to-XML, XML-to-JSON, and XSD validation sections with updated UI steps, Ballerina code samples, and tables.

Changes

XML Processing Guide Rewrite

Layer / File(s) Summary
Front-matter and Construct section
en/docs/develop/transform/xml.md
Adds keywords to page front-matter and rewrites the Construct section with updated UI steps and a callout identifying which XML node types are produced during reading and transformation.
Construct XML payloads and Namespaces
en/docs/develop/transform/xml.md
Adds a Ballerina Construct code example showing xml payload construction with runtime ${} interpolation, rewrites the Namespaces section with scope guidance, and introduces an updated navigation expressions table for traversing the xml payload with namespaced navigation.
Navigating and accessing XML elements and attributes
en/docs/develop/transform/xml.md
Replaces the prior Navigating XML code sample with an expanded set demonstrating .<name>, /*, /<book>, alternation, <*>, descendant /**/<name>, indexed access, and .data() extraction; introduces expanded Accessing attributes documentation covering required/optional attribute expressions and getAttributes() usage.
Filtering elements, iterating sequences, and transforming XML
en/docs/develop/transform/xml.md
Refreshes attribute-filtering examples with an updated product dataset and query-expression-based filtering; rewrites foreach-based iteration with updated examples showing element selection and .data() extraction; updates Transform section with setChildren and setName mutation guidance plus revised Concatenating XML and XSLT transformation.
XML parsing, record conversion, JSON serialization, and XSD validation
en/docs/develop/transform/xml.md
Updates XML-to-record parsing with xmldata:parseAsType() examples; adds documentation and UI configuration table for parseString, parseBytes, and parseStream functions; refreshes Record-to-XML conversion with annotated record definitions (namespace + attribute mapping) and xmldata:toXml() examples; adds XML-to-JSON section demonstrating toJson() and xmldata:fromJson() round-trip; updates XSD schema validation using .xsd file paths and schema record types; refreshes What's next links.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hopping through the XML trees,
New namespaces and queries with ease,
From setChildren to JSON's glow,
XSD validates the flow—
The docs now shine, row by row! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides an overview, structure changes, and new content additions, but does not follow the repository's required template structure with sections like Purpose, Goals, Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Testing, Security, Samples, Related PRs, Migrations, and Test environment. Restructure the description to match the repository template, including all required sections such as Purpose (with issue links), Goals, Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Automation tests, Security checks, Samples, Related PRs, Migrations, and Test environment.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Improve XML Processing documentation' directly summarizes the main change—a comprehensive rewrite of the XML processing documentation page.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

Broken links, images & orphan pages

Passing — no broken links or images found.

Links/images come from one crawl of the production build (baseUrl-aware). Orphans are docs not referenced by sidebars.ts.

Summary

  • Broken links & images — total 0 · 🆕 introduced 0 · 📄 already on main 0
  • Orphan pages — total 8 · 🆕 introduced 0 · 📄 already on main 8

Broken links & images

Introduced by this PR

No new broken link(s)/image(s) introduced by this PR. ✅

Already on main — 0 total

None.

Orphan pages

Introduced by this PR

No new orphan page(s) introduced by this PR. ✅

Already on main — 8 total

Already present on the base branch (not caused by this PR):

Show 8
  • docs/deploy-operate/observe/datadog-integration
  • docs/deploy-operate/observe/elastic-stack-elk
  • docs/deploy-operate/observe/metrics-prometheus-grafana
  • docs/deploy-operate/observe/opensearch-integration
  • docs/deploy-operate/observe/recipe-elk-stack
  • docs/deploy-operate/observe/recipe-kubernetes-production
  • docs/deploy-operate/observe/recipe-local-development
  • docs/deploy-operate/observe/recipe-opensearch-setup

Access child elements, attributes, and text content using XML navigation expressions in WSO2 Integrator. XML navigation makes it easy to query and extract specific parts of XML payloads during integration flows.
### Navigating XML

WSO2 Integrator provides built-in XML navigation expressions that let you traverse an XML structure without writing loops. These expressions work on the `xml` type directly and return an `xml` value containing the matched nodes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets mention the <> button


Name the variable `id`, set the type to `string`, and enter `check product.id`.

Output: `greeting`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in offline, may be we can change this output showing in a another way

let string? category = check p?.category
where category == "electronics"
select p
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Can use a foreach loop to show in the visual diagram, But ok for this as well

@LakshanWeerasinghe

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reworks the XML Processing documentation into a task-oriented guide (Construct / Read and query / Transform / Validate), with paired Visual Designer and Ballerina Code instructions and supporting screenshots to help users implement common XML workflows in WSO2 Integrator.

Changes:

  • Reorganized the page into developer-task sections with expanded coverage (attributes, filtering, XSLT, parsing from string/bytes/stream, XSD validation).
  • Added Visual Designer step-by-step instructions alongside code examples for each task.
  • Added and referenced new screenshots under en/static/img/develop/transform/xml/ and updated “What’s next” links.

Comment on lines +370 to +381
1. **Filter by attribute value**: Add a **Declare Variable** step and enter a query expression that iterates over a navigation result and filters using the optional attribute expression. For example, to select only `<product>` elements where the `category` attribute equals `"electronics"`:

```
from xml p in catalog/<product>
let string? category = check p?.category
where category == "electronics"
select p
```

2. **Select by position**: To get a single element at a known index, use the `[n]` index syntax directly in the expression field. For example, `catalog/<product>[0]` returns the first `<product>` child.

3. **Extract text from the result**: Chain `.data()` on a positional expression to read the text content. For example, `(catalog/<product>[0]/<name>).data()` returns the name of the first product.

**Call toXml**

Click **+** and select **Call Function**. Search for `toXml` and select **toXml** under the **xmldata** section. In the configuration panel, set the fields:

```ballerina
import ballerina/io;
import ballerina/xmldata;
Comment on lines 1153 to 1156
- [JSON Processing](json.md) - Parse, construct, transform, and validate JSON data
- [XSD Tool](../tools/integration-tools/xsd-tool.md) - Generate Ballerina record types from an XSD schema
- [Visual Data Mapper](../integration-artifacts/supporting/data-mapper/data-mapper.md) - Map fields between record types visually
- [Types](../integration-artifacts/supporting/types.md) - Define record types for type-safe data handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants