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.

Support Article

Parsing XML not happening properly - SalesForce api

SA-7604

Summary



You have manually created a PARSE-XML rule (or made modifications to an automatically created-one) which is not mapping all the input types of your input XML document.
Your input XML document has elements which belong to multiple XML namespaces.

Error Messages


No errors: the result is that properties are missing (or empty) from the resultant CLIPBOARD page following the execution of the PARSE-XML rule.

Steps to Reproduce

  1. Based on your input XML file; create relevant CLASSES and PROPERTIES in your PRPC system.
  2. Create a PARSE-XML file which maps the elements of your input XML file to your PRPC Properties.
  3. Use ‘Actions’ Button and select ‘Run’.
  4. Provide your input XML as input.
  5. Confirm the result mapping is incomplete.
Note: if you have an XSD (or multiple XSDs as in this case) for your XML, you can use the “Connector and Metadata Wizard” to generate the CLASSES and PROPERTIES – but you will need to manually edit this rule in order to demonstrate this issue. [That is: the issue will should not occur if you use the wizard to create the PARSE-XML rule in the first place].
Here’s an example input XML document that we want to map – it is comprised of elements from TWO namespaces (‘urn:person.com.test’ and ‘urn:address.com.test’).

<?xml version="1.0"?>
<!—person.xml-->
<p:person
    xmlns:p="urn:person.com.test"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:person.com.test person.xsd">
    <p:first_name>Joe</p:first_name>
    <p:last_name>Bloggs</p:last_name>
    <a:address xmlns:a="urn:address.com.test">
        <a:Street_name>10 Downing Street</a:Street_name>
        <a:Town_City>London</a:Town_City>
        <a:Country>UK</a:Country>
        <a:Postcode>SW1A 2AA</a:Postcode>
    </a:address>
</p:person>
 
We also happen to have XSDs to define schemas for both these namespaces:

<?xml version="1.0" encoding="UTF-8"?>
<!—person.xsd-->
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="urn:person.com.test"
           xmlns="urn:person.com.test"
           xmlns:p="urn:person.com.test"
           xmlns:a="urn:address.com.test"
           elementFormDefault="qualified">
    <xs:import namespace="urn:address.com.test" schemaLocation="address.xsd"/>
    <xs:element name="person" type="Person" />
    <xs:complexType name="Person">
        <xs:sequence>
            <xs:element name="first_name" type="xs:string" />
            <xs:element name="last_name" type="xs:string"/>
                <xs:element ref="a:address"/>
        </xs:sequence>
    </xs:complexType>  
</xs:schema>
 
<?xml version="1.0" encoding="UTF-8"?>
<!—address.xsd-->
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="urn:person.com.test"
           xmlns="urn:person.com.test"
           xmlns:p="urn:person.com.test"
           xmlns:a="urn:address.com.test"
           elementFormDefault="qualified">
    <xs:import namespace="urn:address.com.test" schemaLocation="address.xsd"/>
    <xs:element name="person" type="Person" />
    <xs:complexType name="Person">
        <xs:sequence>
            <xs:element name="first_name" type="xs:string" />
            <xs:element name="last_name" type="xs:string"/>
 
                <xs:element ref="a:address"/>
 
        </xs:sequence>
    </xs:complexType>  
</xs:schema>
 
The CLASSES and PROPERTIES we need to map to will look something like this:



Create your PARSE-XML rule as follows:



From the ‘Actions’ button, select ‘Run’: provide the input XML document as input.
Check the output PRPC XML Page data: in this case it is incomplete:

<?xml version="1.0"?>
<pagedata>
<first_name>Joe</first_name>
<last_name>Bloggs</last_name>
<pxObjClass>Supp-sa-Work-Int-Person</pxObjClass>
<pzStatus>valid</pzStatus>
<address>
<pxObjClass>Supp-sa-Work-Int-Address</pxObjClass>
<Street_name REPEATINGTYPE="PropertyList"/>
</address>
</pagedata>
 


Root Cause



In this case; it was found that the Node ‘namespace’ for elements in the PARSE-XML rule were not configured for every element mappings in the rule.



Resolution


When setting every element within the mapping tree to have the correct namespace, the mapping can be made to work correctly.
In this case; we have two namespaces; so it was necessary to add in the explicit namespaces references of ‘urn:person.com.test’ for the elements the ‘person’, ‘first_name’, ‘last_name’ and ‘urn:address.com.test’ for the element ‘address’ and all the children of the ‘address’ element.



After changing every element mapping to the correct namespace (Double-clicking the element mapping, switching to ‘Node’ tab on the modal dialogue and entering the namespace into the field ‘Node Namespace) and re-saving the PARSE-XML rule; we now get the correct result when testing the rule:
 
<?xml version="1.0"?>
<pagedata>
<first_name>Joe</first_name>
<last_name>Bloggs</last_name>
<pxObjClass>Supp-sa-Work-Int-Person</pxObjClass>
<pzStatus>valid</pzStatus>
<address>
<Postcode>SW1A 2AA</Postcode>
<pxObjClass>Supp-sa-Work-Int-Address</pxObjClass>
<Country>UK</Country>
<Town_City>London</Town_City>
<Street_name REPEATINGTYPE="PropertyList">
<rowdata REPEATINGINDEX="1">10 Downing Street</rowdata>
</Street_name>
</address>
</pagedata>

 

Published January 31, 2016 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

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

Did you find this content helpful?

Want to help us improve this content?

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