Re: [xsl] Copy Child Elements

Subject: Re: [xsl] Copy Child Elements
From: "Rick Quatro" <frameexpert@xxxxxxxxxxxx>
Date: Sat, 26 Jan 2008 09:45:18 -0500
Hi Abel,

Thanks for the excellent advice. I do need to use position() on the p element because the id attribute changes for each entry. So, I am using this:

<xsl:template match="p[position()=1]">
 <dt>
   <xsl:copy-of select="text()|*" />
 </dt>
</xsl:template>

<xsl:template match="p[position()=2]">
 <dd>
   <xsl:copy-of select="text()|*" />
 </dd>
</xsl:template>

Thanks again. And thanks to the others who replied.

Rick Quatro
Carmen Publishing
585-659-8267
www.frameexpert.com


Don't use for-each here. Instead, use

<xsl:apply-templates select="p" />

and follow up with matching templates like the following. The last one is a so-called throw-away template, it will be called when a <p> matches that did not match any more specific match:

<xsl:template match="p[id='Field_ShowAuthorJobTitle']>
   <dt>
       <xsl:copy-of select="text() | *" />
   </dt>
</xsl:template>

<xsl:template match="p[id='Desc_ShowAuthorJobTitle']>
   <dd>
       <xsl:copy-of select="text() | *" />
   </dd>
</xsl:template>

<!-- throw away other <p> elements -->
<xsl:template match="p" />

Current Thread