Subject: Re: generalized template to transform elements to attributes From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 3 Aug 1999 17:11:03 +0100 (BST) |
<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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
generalized template to transform e, Honglin Su | Thread | Re: generalized template to transfo, Honglin Su |
Re: XSL FO: static-content, James Tauber | Date | Re: Multiple pages of well formed H, David Carlisle |
Month |