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

Re: element name as attribute value

Subject: Re: element name as attribute value
From: George Cristian Bina <george@xxxxxxxxxxxxx>
Date: Tue, 23 Jan 2007 12:07:17 +0200
Re:  element name as attribute value
Hi,

You can just start with the recursive copy template and add specific rules to handle the specific processing you want in different contexts. For instance the example below changes X in A and changes Y in <B attribute="Y">

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="X">
<A>
<xsl:apply-templates select="node() | @*"/>
</A>
</xsl:template>
<xsl:template match="Y">
<B attribute="Y">
<xsl:apply-templates select="node() | @*"/>
</B>
</xsl:template>
</xsl:stylesheet>


Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


San wrote:
Hi all,

Hope you can help me with this problem (seems easy but
somehow i can't figure how to do it :(( )
I have this xml file

<X>
  <Y/>
</X>

I would like to have the output (element Y as
attribute value from other element e.g. B)

<A>
  <B attribute="Y">
</A>

I tried with <xsl:copy-of select="child::node()"/> it worked but only in the element part, can't put it
as attribute value.
It become like


<A>
  <Y/>
</A>

Really appreciate when someone can help this desperate
person.

Many thanks before
san




____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091

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.