xsl-list
[Top] [All Lists]

Re: [xsl] element name as attribute value

2007-01-23 03:04:51
On 1/23/07, San <san_sar(_at_)yahoo(_dot_)com> 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.

It's best if you post some code so we can show you exactly how to
modify your code, or show you where you are going wrong.

If you do have a template matching <Y>, then you would use:

<xsl:template match="Y">
 <B attribute="{.}"/>
</xsl:template>

...assuming you wan't the value of <Y> and not the element name as the
attribute value.

cheers
andrew

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>