Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i output element tags also...

Status
Not open for further replies.

mountainbiker

Programmer
Aug 21, 2002
122
GB
xml:
<addressBook>
<address>
<firstName>John</firstName>
<surname>Smith</surname>
<email>smithj@world.org</email>
</address>
</addressBook>


xsl:
<xsl:template match=&quot;/addressBook&quot;>
<!-- must use variable -->
<xsl:variable name=&quot;output&quot;>
<!-- what do i put here? -->
</xsl:variable>
<xsl:value-of select=&quot;$output&quot; />
</xsl:template>


need this output:
<address>
<firstName>John</firstName>
<surname>Smith</surname>
<email>smithj@world.org</email>
</address>
 
Code:
<xsl:template match=&quot;/addressBook&quot;>
  <xsl:copy-of select=&quot;address&quot; />
</xsl:template>

-pete
 
a more guaranteed result would be to use the following:
(i.e. if u want 2 copy attributes also)

<xsl:template match=&quot;/&quot;>
<xsl:apply-templates />
</xsl:template>

<xsl:template match=&quot; / | @* | node()&quot;>
<xsl:copy>
<xsl:apply-templates select=&quot;@* | node()&quot; />
</xsl:copy>
</xsl:template> Build web applications faster with a few lines of XML Code using DataML[tm]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top