|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: generalized template to 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
|
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








