on 08-29-2006 9:51 AM
Hi,
I am using the <xsl:copy-of> element to create a xml structure.
The output seems to be fine, except that, the nodes have a namespace attached to it. <i>copy-of</i> seems to be copying the current nodes and its child nodes "with namespace".
Is there any xsl element which has the same functionality of copy-of but which ignores namespaces while copying?
Regards,
Smitha.
Hi Smitha,
Try using 'Value-of'. This will copy only the value of the source node.
Cheers
JK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
send the input and desired output
maybe we'll be able to help you
Regards,
michal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here goes the code:
XSL:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:output method="text/xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="soapenv:Body">
<xsl:copy-of select="child::node()"/>
</xsl:template>
</xsl:stylesheet>
Expected XML structure:
<?xml version="1.0" encoding="utf-8"?>
<b><loginResponse></b>
<result>
<passwordExpired></passwordExpired>
<serverUrl></serverUrl>
<sessionId></sessionId>
<userId></userId>
</result>
</loginResponse>
The actual output generated is same as above except:
<<b>loginResponse</b> xmlns="urn:enterprise.soap.sforce.com">
The urn is getting added to the tag which is to be ignored.
Regards,
Smitha.
Hi Smitha,
Try this 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>
<!-- go process children (applies to root node only) -->
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<!-- go process attributes and children -->
<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>
Thanks,
Prakash
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.