473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Use of XSL:variable in XML-Attribute

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

Sep 16 '05 #1
3 1446
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
Sep 16 '05 #2
Hi,

Tempore 10:00:18, die Friday 16 September 2005 AD, hinc in foro {comp.text.xml} scripsit schaf <sc***@2wire.ch>:
<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
Sep 16 '05 #3
Hi!
Thanks the solution with the {$ProjectName} was wath I needed.
Regards

Sep 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Xeon | last post by:
Hi, I'm trying this code snippet below but the parser (sablotron) returns error : <xsl:choose> <xsl:when test="some test case"> <xsl:variable name="test" select="0"/> </xsl:when>...
5
by: Nagi Peters | last post by:
Hello I try to tranform a XML Document in php/Sablotron with the following XSL Stylesheet. I tried to write "@id='1'" with the variable chapter_id. So it works: <xsl:variable...
4
by: sylvain.loiseau | last post by:
Hello Given a node set, I try to compute the total of the string-length value of each node. For instance, with : <xsl:for-each select="//q"> <!-- the length of each node is compute with:...
2
by: Norman Barker | last post by:
Hi, I have the following template <xsl:template match="midas:Request"> <xsl:variable name="var1" select="string(./midas:DataDescriptorGUID/@GUID)"/> <test> <result1><xsl:copy-of...
10
by: Tjerk Wolterink | last post by:
The following code does not work: <xsl:variable name="width" select="form:image-width"/> <xsl:if test="$width>$max_image_width"> <xsl:variable name="width" select="$max_image_width"/> </xsl:if>...
1
by: schaf | last post by:
Hello NG ! I have a big problem. I would like to go through a xml file in a xsl:for-each statement. for-each entry (ID) in the XML file i would like to call an xsl:function, which returns a...
2
by: sucheta.phatak | last post by:
Hello, I am trying to use XSLT. Here is the problem that I am facing. My XML file: <Book level="1" name="Mapplicationtoc1"> ....... Some more tags </Book>
5
by: Afshar Mohebbi | last post by:
Hi everybody there, I've declared a <xsl:variable name="something" select="999"/> in my xslt and when I want to set another value in it (with same syntax) I get error the variable "something" has...
0
by: paragguptaiiita | last post by:
I have one problem regarding displaying text from XML file. I have a XSL variable named $p = (0 0 0) (0.82 0 0) (1.63 -0.01 0) (2.63 -0.01 0) (3.63 -0.01 0) (4.63 -0.01 0) (5.63 -0.02 0) (6.63 -0.02...
0
by: paragguptaiiita | last post by:
I have one problem regarding displaying text from XML file. I have a XSL variable named $p = (0 0 0) (0.82 0 0) (1.63 -0.01 0) (2.63 -0.01 0) (3.63 -0.01 0) (4.63 -0.01 0) (5.63 -0.02 0) (6.63 -0.02...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.