Groups | Blog | Home
all groups > dotnet xml > july 2006 >

dotnet xml : Simple XSLT Question?


Ganesh Muthuvelu
7/18/2006 4:33:02 PM
Hello all,

I have a XML as below:
******************
<BLOCK>
<ROW1>
<A>1</A>
<B>2</B>
</ROW1>
<ROW2>
<A>9</A>
<B>3</B>
<C>4</C>
</ROW2>
<ROW3>
<ROW31>
<A>5</A>
<D>6</D>
<E>7</E>
</ROW31>
</ROW3>
</BLOCK>
******************

with which I want to apply 2 rules:
1) Move "ROW3" up and bring the element "ROW2" down.
2) Change the element name "ROW2" to "order"


This is my xsl:
***************
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @* "/>
</xsl:copy>
</xsl:template>


<xsl:template match="BLOCK">
<BLOCK>
<xsl:copy-of select="ROW1"/>
<xsl:copy-of select="ROW3"/>
<xsl:copy-of select="ROW2"/>
</BLOCK>
</xsl:template>

<xsl:template match="ROW2">
<xsl:element name="order">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

</xsl:stylesheet>
***************

However, the element "ROW2" does not get changed to "order" but the first
rule works..

Any help is appreciated..

Thanks,
Dimitre Novatchev
7/18/2006 8:48:36 PM
Just change:

[quoted text, click to view]

to:

<xsl:apply-templates select="ROW2"/>


Cheers,
Dimitre Novatchev

"Ganesh Muthuvelu" <GaneshMuthuvelu@discussions.microsoft.com> wrote in
message news:3B1FCE16-74FE-4C6D-9B90-DD7B87FD514D@microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button