Reputation: 40318
I have xml as follows
<pin>
<securityProfile>
<userName>userName</userName>
</securityProfile>
</pin>
Expected output
<user_id>
<userName>userName</userName>
</user_id>
xslt
<xsl:template match="/pin">
<user_id>
<xsl:apply-templates select="securityProfile/userName"/>
</user_id>
</xsl:template>
<xsl:template match="userName">
..........................
</xsl:template>
If i change <xsl:template match="/pin">
to <xsl:template match="/">
, then it is not working.What might be the reason .here pin is the root element.
Thanks in advance..
Upvotes: 1
Views: 1081
Reputation: 116959
If i change
<xsl:template match="/pin">
to <xsl:template match="/">
, then it is not working.
If you change that, you also need to change:
<xsl:apply-templates select="securityProfile/userName"/>
to:
<xsl:apply-templates select="pin/securityProfile/userName"/>
Otherwise you're applying templates to non-existing nodes.
Upvotes: 1