Use of XSL:variable in XML-Attribute

S

schaf

Hi !
I have a little question. With my XSL File I add additional XML-Tags to
an existing XML-File. But I would like to use a xsl:variable for
inserting a value into an additional xml-attribute.

<xsl:template match="Header">
<xsl:copy >
<xsl:apply-templates select="SubHeader"/>
<xsl:variable name="ProjectName" select="SubHeader/@name"/>
<SubDir name=$ProjectName>
....

Because <subDir> would be treated like an XML-Tag, it is not possible
to add the value of the variable in the name attribute !?!

My destination should look like:

.....
<SubDir name="TestProject">
.....
Is this possible ? Or do I use to "Exportz" the additional XML-Tag in a
second XML file ?

Thanks
 
C

Chris Huebsch

schaf (16 Sep 2005 01:00:18 -0700):
Is this possible ? Or do I use to "Exportz" the additional XML-Tag in a
second XML file ?

You copy an xml-file and would like to add an additiona attribute to an
element-node?

Why do you not use xsl:attribute?

Perhaps you can show us a minimal example input and output
document-fragment.


Chris
 
J

Joris Gillis

Hi,

Tempore 10:00:18 said:
<xsl:template match="Header">
<xsl:copy >
<xsl:apply-templates select="SubHeader"/>
<xsl:variable name="ProjectName" select=""/>
<SubDir name=$ProjectName>

Attribute Value Template:
<SubDir name="{$ProjectName}">
or even: <SubDir name="{SubHeader/@name}">

(The string between the {curly} brackets is interpreted as an XPath expression)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top