[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xhtml xslt?

Subject: Re: xhtml xslt?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 25 Aug 2004 21:52:16 +0100
xslt copy all attributes
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/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.