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
- Based on your input XML file; create relevant CLASSES and PROPERTIES in your PRPC system.
- Create a PARSE-XML file which maps the elements of your input XML file to your PRPC Properties.
- Use ‘Actions’ Button and select ‘Run’.
- Provide your input XML as input.
- Confirm the result mapping is incomplete.
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
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.