Sunteți pe pagina 1din 7

Top of Form

Bottom of Form

How to create an XML document using XML Stream rules


Article ID Category Applies from Last Updated PRKB-25626 Integration PRPCV505 March 25, 2009 Rate This Article

Currently 4.1/5 Stars. 1 2 3 4 5


Rated 4.1/5 stars

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.

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.

The root node provides the opening and closing tags for the XML document. In this example:
3. <HomeProperties xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4. ... 5. ... 6. </HomeProperties>

7. Add additional elements to the rule by clicking the Add Element icon

. Each element defines a set of opening and closing tags within the root node. Notice the hierarchy

presented in the tree diagram.

8. 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.

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.

9. 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 icon . 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.

10. 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.

Note: See the Help system for more information on element metadata. 11. 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.

S-ar putea să vă placă și