|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xhtml xslt?
Hi Nathan,
> but I am thinking that I could do something more generic like this
> instead:
>
> <!-- copy all nodes and attributes -->
> <xsl:template match="xhtml:node()|@*">
> <!--<xsl:message>Element <xsl:value-of
> select="local-name()"/></xsl:message>-->
> <xsl:copy>
> <xsl:apply-templates select="@*|xhtml:node()"/>
> </xsl:copy>
> </xsl:template>
>
> However, the above does a copy, which is not what I want, as an
> XHTML element may contain a custom element inside of it, so I really
> need to do an apply-templates instead.
The above isn't actually legal (you can't have "xhtml:node()"). What
you probably meant was:
<xsl:template match="xhtml:*">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
The above does an <xsl:apply-templates> on the content of the XHTML
elements.
> Also, I believe the above will copy all attributes on all nodes
> right, when I only want to copy the attributes on xhtml: nodes.
My revision above only matches XHTML elements, so it only does what it
does with those elements. To copy XHTML elements and their attributes,
I'd usually use:
<xsl:template match="xhtml:*">
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








