Use of XSL:variable in XML-Attribute

Discussion in 'XML' started by schaf, Sep 16, 2005.

  1. schaf

    schaf Guest

    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
    schaf, Sep 16, 2005
    #1
    1. Advertising

  2. 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
    Chris Huebsch, Sep 16, 2005
    #2
    1. Advertising

  3. schaf

    Joris Gillis Guest

    Hi,

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

    > <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
    Joris Gillis, Sep 16, 2005
    #3
  4. schaf

    schaf Guest

    Hi!
    Thanks the solution with the {$ProjectName} was wath I needed.
    Regards
    schaf, Sep 16, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. 5tein
    Replies:
    1
    Views:
    457
    Patrick TJ McPhee
    Apr 30, 2004
  2. Richard
    Replies:
    2
    Views:
    7,110
    Gerald Aichholzer
    Aug 28, 2004
  3. MC
    Replies:
    1
    Views:
    7,231
    David Carlisle
    Mar 24, 2005
  4. Replies:
    1
    Views:
    3,582
    A. Bolmarcich
    May 27, 2005
  5. Kourosh
    Replies:
    6
    Views:
    837
    Peter Flynn
    May 17, 2006
Loading...

Share This Page