Hi Guys,
I need help on following....
This is the Contact XML out
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Contact xmlns="urn:/crmondemand/xml/Contact/Data" xmlns:ns="urn:crmondemand/ws/ecbs/contact/10/2004" xmlns:p0="urn:crmondemand/ws/ecbs/contact/10/2004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ModifiedById>AAFA-2M15UT</ModifiedById>
<Id>AAGA-3G1NHA</Id>
<AccountId>AAGA-3G1LK0</AccountId>
<stModified_By_User_ID>AAFA-2M125P</stModified_By_User_ID>
<ContactRole/>
<CustomObject2Id>AAGA-3G1N9U</CustomObject2Id>
</Contact>
This is User XML file...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<UserQueryPage_Output xmlns="urn:crmondemand/ws/ecbs/user/10/2004" xmlns:p0="urn:crmondemand/ws/ecbs/user/10/2004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p0:UserQueryPage_Output">
- <ListOfUser lastpage="true" xmlns="urn:/crmondemand/xml/User/Data" xmlns:ns="urn:crmondemand/ws/ecbs/user/10/2004">
- <User>
<Id>AAFA-2M125P</Id>
<ExternalSystemId>7001</ExternalSystemId>
</User>
</ListOfUser>
</UserQueryPage_Output>
This is Address XML
CustomObject2Id XML form ContactId which is under One level from CustomObject2Id
Code:
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject2 xmlns="urn:/crmondemand/xml/customobject2" xmlns:ns="urn:crmondemand/ws/customobject2/10/2004" xmlns:p0="urn:crmondemand/ws/customobject2/10/2004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CustomObject2Id>AAGA-3G95ON</CustomObject2Id>
<Name>123 Street Blvd</Name>
- <ListOfContact>
- <Contact>
<ContactId>AAGA-3G1NHA</ContactId>
</Contact>
</ListOfContact>
</CustomObject2>
I have following XSLT for merging these XML into one XML record.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="exslt saxon bpws cis ihmap p1 p0 cou0 cou1 cobject0 cobject1" version="2.0"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:cis="http://www.approuter.com/schemas/2003/1/UserCallouts/"
xmlns:exslt="http://exslt.org/common" xmlns:ihmap="http://www.approuter.com/xmlns/2002/Mapping"
xmlns:p0="urn:/crmondemand/xml/Contact/Data" xmlns:p1="urn:crmondemand/ws/ecbs/contact/10/2004"
xmlns:saxon="http://saxon.sf.net/" xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cou0="urn:/crmondemand/xml/User/Data" xmlns:cou1="urn:crmondemand/ws/ecbs/user/10/2004"
xmlns:cobject0="urn:crmondemand/ws/customobject2/10/2004" xmlns:cobject1="urn:/crmondemand/xml/customobject2">
<xsl:output encoding="UTF-8" indent="yes" method="xml"/>
<xsl:variable name="srcDoc1" select="/"/>
<xsl:variable name="CRMODUserOutPut" select="document(User.xml)"/>
<xsl:variable name="CRMODCobjectOutPut" select="document(AddressCO.xml)"/>
<xsl:template match="/">
<xsl:element name="Contact" namespace="">
<xsl:for-each select="$srcDoc1/p0:Contact">
<xsl:variable name="AccountModifiedId" select="p0:stModified_By_User_ID"/>
<xsl:variable name="ContactIdCO" select="p0:Id"/>
<xsl:if test="string-length(p0:Id)>0">
<xsl:element name="contactid" namespace="">
<xsl:value-of select="p0:Id"/>
</xsl:element>
<xsl:element name="primaryaccountid" namespace="">
<xsl:value-of select="p0:AccountId"/>
</xsl:element>
<xsl:element name="primaryaddressid" namespace="">
<xsl:value-of select="p0:CustomObject2Id"/>
</xsl:element>
<xsl:element name="salesrep" namespace="">
<xsl:value-of select=" $CRMODUserOutPut/cou1:UserQueryPage_Output/cou0:ListOfUser/cou0:User[cou0:Id=$AccountModifiedId]/cou0:ExternalSystemId"/>
</xsl:element>
<xsl:element name="AddressIds" namespace="">
<xsl:value-of select="I need AddressCO CustomObject2Id"/>
</xsl:element>
<xsl:element name="AccountIds" namespace="">
<xsl:value-of select="p0:AccountId"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
I am not able to lookup CustomObject2Id from Address so i am confused its like Going down in the tree and getting upper node how can i achieve this? I have stored these XML into my local machine thats why you see document(user.xml) document(addressco.xml).
Thanks in advance