Improve XML Processing documentation#550
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (16)
📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThe XML processing documentation page ( ChangesXML Processing Guide Rewrite
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Broken links, images & orphan pages
Links/images come from one crawl of the production build (baseUrl-aware). Orphans are docs not referenced by Summary
Broken links & imagesIntroduced by this PRNo new broken link(s)/image(s) introduced by this PR. ✅ Already on
|
| 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. |
There was a problem hiding this comment.
Lets mention the <> button
|
|
||
| Name the variable `id`, set the type to `string`, and enter `check product.id`. | ||
|
|
||
| Output: `greeting` |
There was a problem hiding this comment.
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 | ||
| ``` |
There was a problem hiding this comment.
Suggestion: Can use a foreach loop to show in the visual diagram, But ok for this as well
|
@CodeRabbit review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
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.
| 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; |
| - [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 |
Overview
Rewrites the XML Processing page (
en/docs/develop/transform/xml.md) into a comprehensive, task-oriented guide covering how to construct, read, transform, andvalidate 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:
${}interpolation, namespaces (module- and function-level scope)New content
x.attr,x?.attr) andgetAttributes().xslt:transform).parseString,parseBytes,parseStream.xmldata:validateagainst an.xsdfile path or a record type, returning()on success or anxmldata:Erroron failure.en/static/img/develop/transform/xml/.Summary by CodeRabbit