on 09-11-2006 12:17 PM
Dear Collegues,
i am doing Simple xsl transformation ,
source xml
<?xml version="1.0" encoding="UTF-8"?>
<!Sample XML file generated by XMLSpy v2006 sp2 U (http://www.altova.com)>
<ns0:Request xmlns:ns0="http://sap.com/xi/demo/httpxsd">
<CARRID>LH</CARRID>
<CONNID>0400</CONNID>
</ns0:Request>
XSL file
<?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" indent="yes"/> -->
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<ns0:ZSYNCCONNECTIONDET xmlns:ns="urn:sap-com:document:sap:rfc:functions">
<carrid>
<xsl:value-of select="/ns0:Request/CARRID"/>
</carrid>
<connid>
<xsl:value-of select="/ns0:Request/CONNID"/>
</connid>
</ns0:ZSYNCCONNECTIONDET>
</xsl:template>
</xsl:stylesheet>
when i execute the xsl progtram i am getting the output without the values ,
output:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:ZSYNCCONNECTIONDET xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
<carrid></carrid>
<connid></connid>
</ns0:ZSYNCCONNECTIONDET>
any suggestions?
Regards
shekar chandra
> XSL file
> <?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" indent="yes"/> -->
> <xsl:output method="xml" indent="yes"/>
> <xsl:template match="/">
> <ns0:ZSYNCCONNECTIONDET
> IONDET
> <b>xmlns:ns</b>="urn:sap-com:document:sap:rfc:functions">
> <carrid>
> <xsl:value-of
> <xsl:value-of select="/ns0:Request/CARRID"/>
> </carrid>
> <connid>
> <xsl:value-of
> <xsl:value-of select="/ns0:Request/CONNID"/>
> </connid>
> </ns0:ZSYNCCONNECTIONDET>
> </xsl:template>
> </xsl:stylesheet>
You missed a '0' in the part in bold.
It should be " xmlns:ns0: ... ". 🐵
Regards,
Henrique.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Friends,
Thanks for your pointers,
Regarding as per vishnu,
<i><b>the namespace itself is wrong. </b></i>
I really didnt understant why the name space is wrong,
as the target message is RFC ,
<i><b>if he ensures that the namespace of Input XML is used in the map</b></i>
i really didnt get this?
Regards
chandra
Hi Chandra,
As mentioned in my msgs, you have to use the Namespace of the Input XML in your XSL code (as per how your programme) to get the desired output.
pls check the below code, where I have added the same in the xsl:stylesheet tag.
Try it now. This works.
XSL file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <b>xmlns:ns0="http://sap.com/xi/demo/httpxsd"</b>>
<!-- <xsl:output method="xml" indent="yes"/> -->
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<ns0:ZSYNCCONNECTIONDET xmlns:ns="urn:sap-com:document:sap:rfc:functions">
Regards
Vishnu
> Hi Henrique,
>
> It is not the "0" alone what he missed, the
> he namespace itself is wrong. But irrespective of
> that, as per my above message, if he ensures that the
> namespace of Input XML is used in the map, then it
> would work perfectly.
>
> Regards
> Vishnu
Vishnu,
You were right in the part that not only the 0 is missing, but the namespace is not wrong, since he needs it to define output message's namespace. The point is that he has forgot to define input namespace and has used the same prefix for input and output.
Chandra,
For correction, you should add that 0 to ns (so it's ns0) and add the namespace&prefix for the input message, and use this other prefix for refering to the input fields.
In order to don't get confused, you should use prefixes that say directly which message you are refering to. Your xslt could be like (modifications in bold):
XSL file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <b>xmlns:input="http://sap.com/xi/demo/httpxsd"</b>>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<<b>output</b>:ZSYNCCONNECTIONDET xmlns:<b>output</b>="urn:sap-com:document:sap:rfc:functions">
<carrid>
<xsl:value-of select="/<b>input</b>:Request/CARRID"/>
</carrid>
<connid>
<xsl:value-of select="/<b>input</b>:Request/CONNID"/>
</connid>
</<b>output</b>:ZSYNCCONNECTIONDET>
</xsl:template>
</xsl:stylesheet>
Regards,
Henrique.
Hi,
Try this
<xsl:value-of select="/ns0:Request/CARRID"/>
instead of
<xsl:value-of select="Request/CARRID"/>
Thanks,
Prakash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this and I think should work
Copy the following code and save it as Nspace.xsl
<?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" indent="no"/>
<xsl:template match="/|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
Import in Imported Archive and during your Interface Mapping add one more mapping of type XSLT and add this Nspace.xsl first and then your XSLT file which should hae the code as follows.
<xsl:value-of select="Request/CARRID"/>
wichout namespace and not like this
<xsl:value-of select="/ns0:Request/CARRID"/>
Thanks,
Prakash
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
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.