Support Article
Not able to set default schema and XML declaration in XML stream
SA-1761
Summary
User's business requirement is to generate a XML file and attach it to case, which will be downloaded by an end user (operator) and sent to external organisation for processing. The XML content must have the xml declaration <?xml version="1.0" encoding="UTF-8"?> and using a default schema of a configured namespace. Out of the box PRPC XML stream rule does not provide this functionality.
Error Messages
No error message. Observed an unexpected behavior where XML stream rule does not include the xml declaration line and unable to set a default namespace.
Steps to Reproduce
- Create an xml stream rule, including elements from a work object.
- Set a name space.
- Run the xml stream rule. Here's an example.
<ATextProperty>asdfas</ATextProperty>
<APage>
<PropertyA>aaaaa</PropertyA>
<PropertyB>bbbbb</PropertyB>
</APage>
</ns1:SR117786-1>
- Observe the generated xml does not include the xml declaration line and the for every element where a namespace is defined, there will be an ns1 keyword in front of the element id.
- The expected output
<SR117786-1 xmlns="http://192.168.56.138:8080/test/testschema.xsd">
<ATextProperty>asdfas</ATextProperty>
<APage>
<PropertyA>aaaaa</PropertyA>
<PropertyB>bbbbb</PropertyB>
</APage>
</SR117786-1>
- Further details with screenshots are attached with this support article.
Root Cause
Product engineers explained that out of the box xml stream rule was not intended to include the xml declaration as this is optional for XML version 1.0. As for the default namespace, this is currently a function that is not available hence can be considered an enhancement request.
Resolution
This issue is resolved through the following local change: by having a custom xml generation, instead of auto-generated, and manually add the xml declaration and default namespace.
An example of the manually edited xml stream is by specifying the below xml manually.
<?xml version="1.0" encoding="UTF-8"?>
<SR117786-1 xmlns="http://192.168.56.138:8080/test/testschema.xsd">
<ATextProperty><pega:reference name=".ATextProperty" mode="normal"/></ATextProperty>
<APage>
<pega:withEmbedded name=".APage"><PropertyA><pega:reference name=".PropertyA" mode="normal"/></PropertyA></pega:withEmbedded>
<pega:withEmbedded name=".APage"><PropertyB><pega:reference name=".PropertyB" mode="normal"/></PropertyB></pega:withEmbedded>
</APage>
</SR117786-1>
Published January 31, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.