Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old June 10th, 2005, 08:28 AM
Authorized User
Join Date: Jun 2005
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help:Recursive Function - attributes into elements

Hi, I am fairly new at XSLT. I was wondering if anyone knew how to convert attributes into a child element of the original element.
Here is an example of code that I have:
 <w:pgSz w:w="12240" w:h="15840"/>
 <w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:header="720" w:footer="720" w:gutter="0"/>
 <w:cols w:space="720"/>
 <w:docGrid w:line-pitch="360"/>

And I would like to have it transformed into.

 Also, please note that I need for this recursive function to start at the root node. (w:wordDocument). And thank you in advance to anyone that can provide me with any helpful advice!

Reply With Quote
  #2 (permalink)  
Old June 10th, 2005, 08:56 AM
mhkay's Avatar
Wrox Author
Points: 18,420, Level: 59
Points: 18,420, Level: 59 Points: 18,420, Level: 59 Points: 18,420, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,952
Thanks: 0
Thanked 289 Times in 284 Posts

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

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
transformation from attributes to nested elements e-bell XSLT 2 January 21st, 2007 07:21 PM
how to control optional elements and attributes NEO1976 XSLT 5 September 4th, 2006 03:58 AM
sequenced elements to attributes zkent XSLT 0 April 19th, 2006 09:50 AM
Elements and attributes Morrislgn XSLT 1 June 20th, 2005 12:13 PM
Elements w same name and their attributes supafly XSLT 1 May 30th, 2005 07:34 AM

All times are GMT -4. The time now is 02:17 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.