xsl-list
[Top] [All Lists]

Re: [xsl] Copy Child Elements

2008-01-26 07:45:48
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" />


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>