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

Re: generalized template to transform elements to attributes

Subject: Re: generalized template to transform elements to attributes
From: Honglin Su <hosu@xxxxxxxxxxx>
Date: Fri, 13 Aug 1999 10:25:34 -0400
xsl transform elements to attributes
If I want to keep the pi (keep the same pi in the result XML file), how can
I modify this xsl?

I add

<xsl:apply-templates select="pi()"/>

to the following xsl stylesheet, but it doesn't work. I am using LotusXSL.

Thank you!

Honglin

David Carlisle wrote:

> <xsl:stylesheet
>   xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
>   default-space="strip"
>   indent-result="yes">
>
> <xsl:template match="*">
> <xsl:copy>
> <xsl:for-each select="@*|*[not(* or @*)]">
> <xsl:attribute name="{name(.)}"><xsl:value-of select="."/>
> </xsl:attribute>
> </xsl:for-each>
> <xsl:apply-templates select="*[* or @*]|text()"/>
> </xsl:copy>
> </xsl:template>
>
> </xsl:stylesheet>
>
> appears to convert
>
> <atom  phase="gas">
>    <name>Hydrogen</name>
>    <symbol>H</symbol>
>    <boiling_point units="Kelvin">20.28</boiling_point>
> </atom>
>
> into
>
> <atom phase="gas" name="Hydrogen" symbol="H">
> <boiling_point units="Kelvin">20.28</boiling_point>
> </atom>
>
> The first select picks up attributes and elements that don't have
> element children or attributes, and makes attributes of them.
> The second select picks up elements with element children or attributes,
> and text nodes.
>
> as written, comments, pis etc get thrown away, but could be added to the
> second select.
>
> David
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 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.