Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
| FAQ | Members List | 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 Search this Thread Display Modes
  #1 (permalink)  
Old October 28th, 2003, 01:47 PM
Registered User
Join Date: Jun 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Transform xml to xml changing one tag.


I would like to transform an xml document only affecting text nodes. My problem is that I can't seem to get the attributes to show up in the output.

Here is my stylesheet, you can use any xml document against it just include some attributes to see that they do not come out in the output. I am looking for a generic approach such that I could use this stylesheet against any xml structure.

Thank you for any suggestions!!!

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/>

<xsl:template match="title/text()">
hello there

<xsl:template match="*">
    <xsl:variable name="document">

    <xsl:element name="{name()}">
        <xsl:copy-of select="$document"/>

Reply With Quote
  #2 (permalink)  
Old October 29th, 2003, 01:45 AM
Friend of Wrox
Join Date: Jun 2003
Location: Nor Hachin, Kotayk, Armenia.
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti


you need an identity transformation making template plus "refined" template for text nodes. I also included xsl:strip-space to avoid whitespace-nodes (if you need also to change all the whitespace nodes, you can remove it).

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:strip-space elements="*"/>

    <xsl:template match="@*|node()">
        <xsl:apply-templates select="@*|node()"/>

    <xsl:template match="text()">
        hello there
Reply With Quote
  #3 (permalink)  
Old April 21st, 2010, 05:14 PM
Registered User
Join Date: Apr 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default attributes to nodes?

Is this supposed to convert attributes of an XML element to an XML node?

I.E. From:
<VehicleAttribute type="VehicleType" typeid="12" value="Truck" valueid="4673" />
(it doesn't seem to do anything. the above is what I'm looking for)
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
How do I transform XSLT without the <?xml?> tag? nadavvin XSLT 4 June 10th, 2007 09:25 AM
XML to XML transform (Simplified) nmahesh567 XSLT 2 March 24th, 2007 07:57 AM
XSLT read through XML to transform another XML dendenx2 XSLT 8 July 7th, 2005 08:18 PM
Transform XML to XML using XSLT Mr.D XSLT 2 September 7th, 2004 02:13 PM
XML to (different <tag>) XML mapping Thodoris XML 4 April 27th, 2004 04:02 AM

All times are GMT -4. The time now is 12:26 PM.

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