XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Vinayaka Rama Kiran MuppanaSubject: Help to Write this XSLT Transformation.
Author: Vinayaka Rama Kiran Muppana
Date: 29 Aug 2005 10:57 AM
Hi, I have an XML in the following format.

<Seg1 A="a" B="b>
<Seg1 A="c" B="d">
<Seg2 X="a" Y="b>
<Seg2 X="c" Y="d">

After using XSLT i need to get the XML in the following format.
<Seg1>
<Item>
<A>a</A>
<B>b</B>
</Item>
<Item>
<A>c</A>
<B>d</B>
</Item>
</Seg1>
<Seg2>
<Item>
<X>a</X>
<Y>b</Y>
</Item>
<Item>
<X>c</X>
<Y>d</Y>
</Item>
</Seg2>

The Problem is that the names ot the Elements that are coming in the incoming XML are not constant. So i should not hard code the element names in the XSLT. Can you please kindly help in this issue.

Posttop
Ivan PedruzziSubject: Help to Write this XSLT Transformation.
Author: Ivan Pedruzzi
Date: 30 Aug 2005 01:52 AM
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:if test="@*">
<item>
<xsl:apply-templates select="@*"/>
</item>
</xsl:if>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="@*">
<xsl:element name="{local-name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>

</xsl:stylesheet>

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.