[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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

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
Keywords