on 07-06-2010 8:30 PM
I need to add namespace xmlns:prx="urn:sap.com:proxy:SB1:/1SAI/TAS04BED82951A661E02EC4:701:2008/06/06" to my xml document after doing a PI message mapping.
When I run the following XSLT code in my XML editing software, it works as desired. When I import the XSL program and use it at runtime, it is not adding the namespace. Can anyone help?
XSLT:
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:prx="urn:sap.com:proxy:SB1:/1SAI/TAS04BED82951A661E02EC4:701:2008/06/06">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*">
<xsl:copy>
<xsl:copy-of select="document('')/xsl:stylesheet/namespace::*[not(local-name() = 'xsl')]"/>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Source:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:ChartOfAccountsReplicationConfimation xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global">
<MessageHeader>
<UUID>4C321305CA1400AAE10080000A98800D</UUID>
<ReferenceUUID>4bff533d-2452-00f2-e100-80000a98800c</ReferenceUUID>
<CreationDateTime>2010-07-06T13:57:30Z</CreationDateTime>
<SenderBusinessSystemID>ERP_GTPSRM_ECC6_S1</SenderBusinessSystemID>
<RecipientBusinessSystemID>EDG_030_BusinessSystem</RecipientBusinessSystemID>
</MessageHeader>
<Log>
<BusinessDocumentProcessingResultCode>3</BusinessDocumentProcessingResultCode>
<MaximumLogItemSeverityCode>1</MaximumLogItemSeverityCode>
<Item>
<Note>Processed by PI</Note>
</Item>
</Log>
</ns0:ChartOfAccountsReplicationConfimation>
Desired Target:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:ChartOfAccountsReplicationConfimation xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global" xmlns:prx="urn:sap.com:proxy:SB1:/1SAI/TAS04BED82951A661E02EC4:701:2008/06/06">
<MessageHeader>
<UUID>4C321305CA1400AAE10080000A98800D</UUID>
<ReferenceUUID>4bff533d-2452-00f2-e100-80000a98800c</ReferenceUUID>
<CreationDateTime>2010-07-06T13:57:30Z</CreationDateTime>
<SenderBusinessSystemID>ERP_GTPSRM_ECC6_S1</SenderBusinessSystemID>
<RecipientBusinessSystemID>EDG_030_BusinessSystem</RecipientBusinessSystemID>
</MessageHeader>
<Log>
<BusinessDocumentProcessingResultCode>3</BusinessDocumentProcessingResultCode>
<MaximumLogItemSeverityCode>1</MaximumLogItemSeverityCode>
<Item>
<Note>Processed by PI</Note>
</Item>
</Log>
</ns0:ChartOfAccountsReplicationConfimation>
May I ask why you need this namespace?
The prefiy prx is not used in the document, so the namespace would not have any purpose in the target document.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your XSLT could be something like this:
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/*">
<ns0:ChartOfAccountsReplicationConfimation xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global" xmlns:prx="urn:sap.com:proxy:SB1:/1SAI/TAS04BED82951A661E02EC4:701:2008/06/06">
<xsl:copy>
have some logic for copy Message header and log
</xsl:copy>
</ns0:ChartOfAccountsReplicationConfimation>
</xsl:template>
</xsl:stylesheet>
Thanks for staying with me, but that leaves me missing nodes throughout the output.
<?xml version="1.0" encoding="UTF-8"?><ns0:ChartOfAccountsReplicationConfimation xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global" xmlns:prx="urn:sap.com:proxy:SB1:/1SAI/TAS04BED82951A661E02EC4:701:2008/06/06">
4C320682CA1400AAE10080000A98800D
4bff533d-2452-00f2-e100-80000a98800c
2010-07-06T11:55:15Z
ERP_GTPSRM_ECC6_S1
EDG_030_BusinessSystem
3
1
Processed by PI
</ns0:ChartOfAccountsReplicationConfimation>
Instead of <xsl:copy> you use the statement:
<xsl:copy-of select="..." />
Try following:
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/*">
<ns0:ChartOfAccountsReplicationConfimation xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global" xmlns:prx="urn:sap.com:proxy:SB1:/1SAI/TAS04BED82951A661E02EC4:701:2008/06/06">
<xsl:copy-of select="//MessageHeader" />
<xsl:copy-of select="//Log" />
</ns0:ChartOfAccountsReplicationConfimation>
</xsl:template>
</xsl:stylesheet>
Check this page for a reference:
Thank You Stefan.
This code works for me in PI. What is odd is that in my EditiX xml editor program this same code is giving me output missing node names.
<?xml version="1.0" encoding="UTF-8"?><ns0:ChartOfAccountsReplicationConfimation xmlns:ns0="http://sap.com/xi/SAPGlobal20/Global" xmlns:prx="urn:sap.com:proxy:SB1:/1SAI/TAS04BED82951A661E02EC4:701:2008/06/06">
4C320682CA1400AAE10080000A98800D
4bff533d-2452-00f2-e100-80000a98800c
2010-07-06T11:55:15Z
ERP_GTPSRM_ECC6_S1
EDG_030_BusinessSystem
...
In my original post, it was the other way around. That xslt code worked in EditiX, but not PI. Before I close this post, do you have any idea why the difference?
HI Stefen,
I had one XSL question,i have seen in the blogs you have given correct answers regarding the XSLT.
My requirement is the source file is :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8"/>
<ns0:Esri_Identify
xmlns:ns0="http://ottawa.ca/ecc/esri/ecctoesri">
<Identify>
<MapDescription>
<Name/>
<Rotation/>
</MapDescription>
<MapImageDisplay>
<ImageHeight/>
<ImageWidth/>
<ImageDPI/>
</MapImageDisplay>
<SearchShape>
<X/>
<Y/>
</SearchShape>
<Tolerance/>
<IdentifyOption/>
<LayerIDs>
<Int/>
</LayerIDs>
</Identify>
</ns0:Esri_Identify>
and expected is :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8"/>
<ns0:Esri_Identify
xmlns:ns0="http://ottawa.ca/ecc/esri/ecctoesri">
<Identify>
<MapDescription>
<Name/>
<Rotation/>
</MapDescription>
<MapImageDisplay>
<ImageHeight/>
<ImageWidth/>
<ImageDPI/>
</MapImageDisplay>
<SearchShape xmlns:q4="http://www.esri.com/schemas/ArcGIS/10.0" xsi:type="q4:PointN" xmlns="">
<X/>
<Y/>
</SearchShape>
<Tolerance/>
<IdentifyOption/>
<LayerIDs>
<Int/>
</LayerIDs>
</Identify>
</ns0:Esri_Identify>
I need to pass the name space for searchshape element, can you please help me in this regard.
Thanks,
Hi Keith,
Did you try to add the XMLAnonymizerBean in your communication channel:
/people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.