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

Re: Réf. : RE : XML tags to XML attributes wit

Subject: Re: Réf. : RE : XML tags to XML attributes with XSL
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 22 Oct 2003 11:14:51 -0400
xml attribute select
Laurent,

Jarno suggested using xsl:copy-of, and you reported it placed the value of your attribute into element content.

Are you sure you said copy-of, not value-of? xsl:value-of would give the result you reported, but xsl:copy-of would (as Jarno said) copy the attribute as an attribute (not place its value into the content).

At 04:50 AM 10/22/2003, you wrote:
I'done

<xsl:template match="* | @*">
     <xsl:copy>
          <xsl:apply-templates select="Attributes"/>
          <xsl:apply-templates select="* | @* | text()"/>
     </xsl:copy>
</xsl:template>

and it seems to work now.

This works because you are selecting attributes (select="@*") and also matching them with the same template, which copies them.


The line <xsl:apply-templates select="Attributes"/> is, however, spurious. It's not doing anything at all, since you don't have any child elements named "Attributes" -- and if you did, it would break your stylesheet and your actual attributes would fail to be copied, since they are being copied by the next instruction <xsl:apply-templates select="* | @* | text()"/>, and you can't add attributes to an element node after other things have been placed in its content (as would presumably happen if you had element children named "Attributes").

So you probably want to delete that line (try it; it will still work) ... and maybe go back to Jarno's idea as it's a bit tighter (albeit a little less adaptable).

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.