|
Subject: RE: [xsl] XPath Axes From: Jarno.Elovirta@xxxxxxxxx Date: Wed, 2 Apr 2003 10:01:15 +0300 |
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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] XPath Axes, J dinesh | Thread | [xsl] Replacing DTD reference with , Cams Ismael |
| RE: [xsl] XSL and 2 XML-documents, Johan Thorèn (EAB) | Date | [xsl] Replacing DTD reference with , Cams Ismael |
| Month |