Skip to main content
This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.
LinkedIn
Copied!

Table of Contents

How to create an XML document using XML Stream rules

Summary

Your applications can automatically generate XML documents based on property relationships defined in an XML Stream rule. In addition to being generated during an XML Schema import, XML Stream rules can be created manually. These rules can then be used to provide content to Connect and Service rules. The finished rule will appear as follows:

<ns1:HomeProperties MarketValue="<pega:reference name=".MarketValue" mode="normal"/>" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.homeproperties.com">
<Area><pega:reference name=".Area" mode="normal"/></Area>
<ns1:BurglarAlarm><pega:reference name=".BurglarAlarm" mode="normal"/></ns1:BurglarAlarm>
<DistanceFromFireHydrant><pega:reference name=".DistancetoFireHydrant" mode="normal"/></DistanceFromFireHydrant>
<DistanceToFireStation><pega:reference name=".DistanceToFireStation" mode="normal"/></DistanceToFireStation>
<FireAlarm><pega:reference name=".FireAlarm" mode="normal"/></FireAlarm>
</ns1:HomeProperties>

 

Suggested Approach

To create an XML Stream rule:

  1. Define a new XML Stream Rule by navigating to the Integration-Mapping category. Complete the New Rule dialog. Enter a Stream Name and XML Type. If the XML Stream rule is going to be referenced by a Service or Connect rule, the XML Type must be set to MapFrom.
    New
  2. On the XML Stream rule form, the root node is already present and is set to the context of the class the rule is saved in. Double click the root node to display the mapping properties panel.
    Root Node
    The root node provides the opening and closing tags for the XML document. In this example:
    <HomeProperties xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    ... ...
    </HomeProperties>
  3. Add additional elements to the rule by clicking the Add Element icon addelement. Each element defines a set of opening and closing tags within the root node. Notice the hierarchy presented in the tree diagram.
    Tree
  4. You can reference properties, so that the elements in the XML document are set to property values from the clipboard.
    Double-click on the element you would like to add a reference to. On the mapping properties panel, specify the property in the Source Property field.
    Map
    Note: The properties listed in the Source Property SmartPrompt are in the context of the Context Class. You can change this class by defining a new Context Page.
  5. You can also add attributes to any element, and set them equal to properties. For example, to add Market Value as an attribute of HomeProperties, select HomeProperties and click the Add Attribute iconattribute. Set the Source Property of the attribute to .MarketValue. To increase readability, you may wish to move the attribute to the top of the tree. Do this by simply clicking and dragging the attribute.
    Att
  6. Optionally, add a namespace value to selected elements within the document. Double-click the element to display the properties panel. On the Node tab, enter Node Namespace value. Adding a namespace value to the root node is recommended if you are using an XML Stream rule with a SOAP Service.
    namespace
    Note: See the Help system for more information on element metadata.
  7. Save the rule form. You can see the generated XML content on the XML tab in the XML Source section. The generated content is as follows:

    <ns1:HomeProperties MarketValue="<pega:reference name=".MarketValue" mode="normal"/>" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.homeproperties.com">
    <Area><pega:reference name=".Area" mode="normal"/>
    </Area>
    <ns1:BurglarAlarm><pega:reference name=".BurglarAlarm" mode="normal"/>
    </ns1:BurglarAlarm>
    <DistanceFromFireHydrant><pega:reference name=".DistancetoFireHydrant" mode="normal"/></DistanceFromFireHydrant>
    <DistanceToFireStation><pega:reference name=".DistanceToFireStation" mode="normal"/></DistanceToFireStation>
    <FireAlarm><pega:reference name=".FireAlarm" mode="normal"/></FireAlarm>
    </ns1:HomeProperties>

    Note: XML Source content is updated when the rule is saved.

You can also define an XML document directly from an XML Schema. To use this method:

  1. On the XML tab of the XML Stream rule, copy the URL of the defined schema into Schema URL field.
  2. On the Mapping tab, click the Update Tree Content button. The contents of the tree diagram is completed. Map each element to properties as described previously.

    Note: If the schema you would like to use contains more than 500 elements, it is recommended that you use the XML Schema Import Wizard.
Suggest Edit
Did you find this content helpful?

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Ready to crush complexity?

Experience the benefits of Pega Community when you log in.

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us