xsl-list
[Top] [All Lists]

Re: Element value

2002-11-21 03:33:14
Jarno,
just a naive question..
wouldnt this serve?

<xsl:template match="/">
<element name="{/element/element.name}"/>
</xsl:template>

What are the downsides if any in the above approach apart from the fact that
i have hardcoded the attribute "name" rather than using the string-after()
function to get the attribute's name ( "name" )..
for what Endre needed  as in.
----------------------------------------------------------------------------
-----------------
I need to tranform an element value to an attribute value:
input:
<element>
<element.name>hello</element.name>
</element>
output:
<element name="hello"/>
I have no idea ho to refer the element's value in an xsl:template
----------------------------------------------------------------------------
-----------------
Wouldnt  the template I have given above suffice.

----- Original Message -----
From: <Jarno(_dot_)Elovirta(_at_)nokia(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Thursday, November 21, 2002 8:48 AM
Subject: RE: [xsl] Element value


Hi,

I need to tranform an element value to an attribute value:

input:
<element>
<element.name>hello</element.name>
</element>

output:
<element name="hello"/>


I have no idea ho to refer the element's value in an xsl:template

E.g.

<xsl:template match="*">
  <xsl:copy>
    <xsl:for-each select="*[contains(local-name(), '.')]">
      <xsl:attribute name="{substring-after(local-name(), '.')}">
        <xsl:value-of select="." />
      </xsl:attribute>
    </xsl:for-each>
  </xsl:copy>
</xsl:template>

Jarno - Xorcist: Xorcist (Bleeding mix)

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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