[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Adding the child nodes as attributes to the parent

Subject: RE: Adding the child nodes as attributes to the parent node.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 15 Jul 2005 10:15:53 +0100
xslt parent node
Very confusing problem description, as your elements are called "attribute"
(at least you didn't name your attributes "element"!)

You didn't say what part of the problem you found difficult, so short of
writing the whole code for you (not something I do!) it's hard to know
exactly where you need help. 

Converting <Element type="A"> to <A-Element> can be done using

<xsl:element name="{@type}-Element">

Converting the <attribute> elements into attributes can be done using

<xsl:for-each select="@*">
  <xsl:attribute name="{@name}">
    <xsl:value-of select="{@value}"/>

Michael Kay
http://www.saxonica.com/

 

> -----Original Message-----
> From: Lakshmi narayana [mailto:lchintala@xxxxxxxxxxxx] 
> Sent: 15 July 2005 10:26
> To: XSL (E-mail)
> Subject:  Adding the child nodes as attributes to the 
> parent node.
> 
> 
> 
> Hi,
> I have the following xml file. I want to write the xslt to this file.
> In the resultant xml file, all the immediate attribute childs 
> of a node are
> processed and add the attributes of that attribute child
> as attributes to the parent node. Based on the type, the 
> parent element node
> should be changed.
> Only attribute tag attributes should be added to its parent.
> Can any one give the xslt code for this.
> 
> Input file
> <Element type="A">
> 	<attribute name="seq" value="1"/>
> 	<attribute name="rep" value="2"/>
> 	<attribute name="Period" value="3"/>
> 	<Element type="B">
> 		<attribute name="seq" value="4"/>
> 		<attribute name="rep" value="5"/>
> 		<Element type="C">
> 			<attribute name="seq" value="6"/>
> 			<attribute name="rep" value="7"/>
> 			<attribute name="period" value="8"/>
> 			<attribute name="max" value="9"/>
> 		</Element>
> 	</Element>
> </Element>
> 
> output file:
> <A-Element seq="1" rep="2" period="3">
> 	<B-Element seq="4" rep="5">
> 		<C-Element  seq="6" rep="7" period="8" max="9">
> 		</C-Element>
> 	</B-Element>
> </A-Element>
> Thanks,
> Laxmi Narayana

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.