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 |
- XPath Axes
- J dinesh - Tue, 1 Apr 2003 23:08:06 -0500 (EST)
- <Possible follow-ups>
- Jarno . Elovirta - Wed, 2 Apr 2003 01:57:14 -0500 (EST) <=
|
|