|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XPath Axes
Hi,
> How to convert following xml into xml output format
> using XPath Axes.
You mean XSLT?
> Input:
> ------
> <trow>
> <cell>author 1</cell>
> <cell>fname:</cell>
> <cell>John</cell>
> </trow>
> <trow>
> <cell/>
> <cell>midname:</cell>
> <cell>N.</cell>
> </trow>
> <trow>
> <cell/>
> <cell>sname:</cell>
> <cell>Tippett</cell>
> </trow>
>
> Output:
> -------
> <author id="1">
> <fname>John</fname>
> <midname>N.</midname>
> <sname>Tippett</sname>
> </author>
e.g.
<xsl:template match="*[trow]">
<xsl:variable name="x" select="trow[cell[1]/text()]/cell[1]/text()" />
<xsl:element name="{substring-before($x, ' ')}">
<xsl:attribute name="id">
<xsl:value-of select="substring-after($x, ' ')" />
</xsl:attribute>
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<xsl:template match="trow">
<xsl:element name="{translate(cell[2], ':', '')}">
<xsl:value-of select="cell[3]" />
</xsl:element>
</xsl:template>
Cheers,
Jarno - Flesh Field: Prophecy (Assemblage 23 Remix)
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








