Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - RE: Transform attribute to node [Thread Next] Re: Transform attribute to nodeTo: NULL Date: 12/8/2005 9:03:00 AM Thanks for the reply,
In fact, the goal is not to find a particular node, but to do this
recusively on all nodes ! The number of node is not known in advance !
<root>
<test1 value="1"><test11 value="11"/></test1>
<test2 value="1" value2="2" />
</root>
becomes
<root>
<test1>
<value>1</value>
<test11>
<value>11</value>
</test11>
</test1>
<test2>
<value>1</value>
<value2>2</value2>
</test2>
</root>
CR/LF is not important. This could be left on one line.
TIA.
"Mukul Gandhi" <MukulGandhi@d...> wrote in message
news:255D7848-3E64-478A-940A-587A706A585B@m......
> Given this XML file
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root>
> <test value="1" />
> </root>
>
> The following stylesheet does what you want
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:output method="xml" indent="yes" />
>
> <xsl:template match="/root">
> <root>
> <xsl:apply-templates select="test" />
> </root>
> </xsl:template>
>
> <xsl:template match="test">
> <test>
> <xsl:for-each select="@*">
> <xsl:element name="{name()}">
> <xsl:value-of select="." />
> </xsl:element>
> </xsl:for-each>
> </test>
> </xsl:template>
>
> </xsl:stylesheet>
>
> Regards,
> Mukul
>
> "Olivier Matrot" wrote:
>
>> Hello,
>> I'm looking for an XSLT file that transform an XML File to another XML
>> File
>> where all attributes of a node becomes node as well. For instance :
>>
>> <test value="1" />
>>
>> becomes
>>
>> <test>
>> <value>1</value>
>> </test>
>>
>>
>> TIA.
>>
>>
>>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
