Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Use of XSL:variable in XML-Attribute

Reply
Thread Tools

Use of XSL:variable in XML-Attribute

 
 
schaf
Guest
Posts: n/a
 
      09-16-2005
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

 
Reply With Quote
 
 
 
 
Chris Huebsch
Guest
Posts: n/a
 
      09-16-2005
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
--
Chris Huebsch www.hübsch-gemacht.de | TU Chemmnitz, Informatik, RNVS
GPG-Encrypted mail welcome! ID:7F2B4DBA | Str. d. Nationen 62, B204
Chemnitzer Linux-Tage 2005, 5.-6.März | D-09107 Chemnitz
http://chemnitzer.linux-tage.de/ | +49 371 531-1377, Fax -1803
 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      09-16-2005
Hi,

Tempore 10:00:18, die Friday 16 September 2005 AD, hinc in foro {comp.text.xml} scripsit schaf <(E-Mail Removed)>:

> <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)

--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Gaudiam omnibus traderat W3C, nec vana fides
 
Reply With Quote
 
schaf
Guest
Posts: n/a
 
      09-16-2005
Hi!
Thanks the solution with the {$ProjectName} was wath I needed.
Regards

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not use ''; file already in use. M K ASP .Net 11 04-09-2008 11:35 AM
where to use CPLD & where to use FPGA? kulkarku@math.net VHDL 6 03-06-2006 07:27 AM
How do I know when to use the Viewstate and when to use the posted data? :-) Simon ASP .Net 1 11-09-2004 02:32 AM
Can I use XPath or something to a remote Mac or Linux box and just query an xml file, not using web services and use encyrption? jake ASP .Net 0 07-06-2004 02:16 PM
Cannot use the profile "default" because it is in use, not. please.post@yur.re.ply Firefox 1 07-04-2004 03:41 AM



Advertisments