473,396 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Simple XSLT Question?

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,
Ganesh
Jul 18 '06 #1
1 955
Just change:
<xsl:copy-of select="ROW2"/>
to:

<xsl:apply-templates select="ROW2"/>
Cheers,
Dimitre Novatchev

"Ganesh Muthuvelu" <Ga*************@discussions.microsoft.comwrote in
message news:3B**********************************@microsof t.com...
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,
Ganesh

Jul 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: el_bandido | last post by:
Hello, I've tried the FAQ and some minutes in googl'ing but was not happy with what I got. Basically I'd like to get a _simple_ example on how I could create a web based (portable across all...
9
by: Mike King | last post by:
What is the XPath expression that selects the value attribute in the following xml? <?xml version="1.0"?> <root xmlns="http://a/" xmlns:a="http://a/"> <child a:value="1"/> </root>
6
by: chonkme | last post by:
Hi, i have a real simple xslt problem but i just cant figure out how to do it by looking at various examples on the net. i have a xml document and in it are some elements with a "result" tag name....
1
by: Scott | last post by:
The following is the XML I have to work with. Below is the question <Table0> <CaseID>102114</CaseID> <CaseNumber>1</CaseNumber> <DateOpened>2005-06-14T07:26:00.0000000-05:00</DateOpened>...
0
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag,...
4
by: Gauthier | last post by:
Hi, I've a simple issue with the use of extension objects. I'm trying to call a text formating method from an object that I add to my arguments collection, this method take an input string and...
2
by: Yarik | last post by:
Hello, I am not sure the subject of my post adequately describes the problem I am trying to solve, so I think a specific example would be helpful. Let's say there are XML descriptions of...
14
by: Lee | last post by:
I have a xml file, here is sample part: <?xml version="1.0" encoding="UTF-8"?> <ProducsList> <Product id="1"> <SpecList> <Spec> <SpecLabel>Height</SpecLabel> <SpecValue>10</SpecValue>...
3
by: Chrism2671 | last post by:
I'm new to XSLT/XML and I have a very simple, quick question. i've been trying to convert simple xml files into CSV files and have made a simple XSLT template using the w3 tutorials, but it doesn't...
2
by: astroboiii | last post by:
New to the whole xml thing and finding w3schools to be an excellent resource. Now down to my question: I have several xml files I need to parse through and grab relevant information from and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.