473,544 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

referencing an xslt variable

I have the following which creates a variable containing a relative
path where <xsl:value-of select="."/returns a portion of the
filename:

<xsl:variable name="fileName" >../../data/models/<xsl:value-of
select="."/>.xml</xsl:variable>

I want to use this variable as an argument of the document function:

<xsl:apply-templates mode="coordinat es" select="documen t( REFERENCE
FILENAME VARIABLE HERE)"/>
<xsl:apply-templates/>

I tried document('$file Name') and ($fileName) and neither work. Any
ideas?

Dec 12 '06 #1
3 3944
rls03 wrote:
I have the following which creates a variable containing a relative
path where <xsl:value-of select="."/returns a portion of the
filename:

<xsl:variable name="fileName" >../../data/models/<xsl:value-of
select="."/>.xml</xsl:variable>

I want to use this variable as an argument of the document function:

<xsl:apply-templates mode="coordinat es" select="documen t( REFERENCE
FILENAME VARIABLE HERE)"/>
<xsl:apply-templates/>

I tried document('$file Name') and ($fileName) and neither work. Any
ideas?
The second format is correct. If it doesn't work, then your variable may
contain the wrong value. Try using

<xsl:variable name="fileName" >
<xsl:text>../../data/models/</xsl:text>
<xsl:value-of select="."/>
<xsl:text>.xm l</xsl:text>
</xsl:variable>

or

<xsl:variable name="fileName" >
<xsl:value-of select="concat( '../../data/models/',.,'.xml')"/>
</xsl:variable>

and display the value at run-time for checking using <xsl:message>

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Dec 13 '06 #2
The second format is correct. If it doesn't work, then your variable may
contain the wrong value. Try using

<xsl:variable name="fileName" >
<xsl:text>../../data/models/</xsl:text>
<xsl:value-of select="."/>
<xsl:text>.xm l</xsl:text>
</xsl:variable>

or

<xsl:variable name="fileName" >
<xsl:value-of select="concat( '../../data/models/',.,'.xml')"/>
</xsl:variable>

It is recommended to create an RTF when it is possible to evaluate the value
as specified in the "select" attribute:
<xsl:variable name="fileName"
select="concat( '../../data/models/',.,'.xml')"/>
This is probably more efficient, too.

Cheers,
Dimitre Novatchev

"Peter Flynn" <pe********@m.s ilmaril.iewrote in message
news:4u******** *****@mid.indiv idual.net...
rls03 wrote:
>I have the following which creates a variable containing a relative
path where <xsl:value-of select="."/returns a portion of the
filename:

<xsl:variabl e name="fileName" >../../data/models/<xsl:value-of
select="."/>.xml</xsl:variable>

I want to use this variable as an argument of the document function:

<xsl:apply-templates mode="coordinat es" select="documen t( REFERENCE
FILENAME VARIABLE HERE)"/>
<xsl:apply-templates/>

I tried document('$file Name') and ($fileName) and neither work. Any
ideas?

The second format is correct. If it doesn't work, then your variable may
contain the wrong value. Try using

<xsl:variable name="fileName" >
<xsl:text>../../data/models/</xsl:text>
<xsl:value-of select="."/>
<xsl:text>.xm l</xsl:text>
</xsl:variable>

or

<xsl:variable name="fileName" >
<xsl:value-of select="concat( '../../data/models/',.,'.xml')"/>
</xsl:variable>

and display the value at run-time for checking using <xsl:message>

///Peter
--
XML FAQ: http://xml.silmaril.ie/

Dec 13 '06 #3
I wrote:
It is recommended to create an RTF when it is possible to evaluate the
value as specified in the "select" attribute:
Must be:

It is recommended *not* to create an RTF when it is possible to evaluate the
value
as specified in the "select" attribute:
"Dimitre Novatchev" <di******@tpg.c om.auwrote in message
news:45******** *************** @authen.yellow. readfreenews.ne t...
>The second format is correct. If it doesn't work, then your variable may
contain the wrong value. Try using

<xsl:variabl e name="fileName" >
<xsl:text>../../data/models/</xsl:text>
<xsl:value-of select="."/>
<xsl:text>.xm l</xsl:text>
</xsl:variable>

or

<xsl:variabl e name="fileName" >
<xsl:value-of select="concat( '../../data/models/',.,'.xml')"/>
</xsl:variable>


It is recommended to create an RTF when it is possible to evaluate the
value as specified in the "select" attribute:
<xsl:variable name="fileName"
select="concat( '../../data/models/',.,'.xml')"/>
This is probably more efficient, too.

Cheers,
Dimitre Novatchev

"Peter Flynn" <pe********@m.s ilmaril.iewrote in message
news:4u******** *****@mid.indiv idual.net...
>rls03 wrote:
>>I have the following which creates a variable containing a relative
path where <xsl:value-of select="."/returns a portion of the
filename:

<xsl:variab le name="fileName" >../../data/models/<xsl:value-of
select="."/>.xml</xsl:variable>

I want to use this variable as an argument of the document function:

<xsl:apply-templates mode="coordinat es" select="documen t( REFERENCE
FILENAME VARIABLE HERE)"/>
<xsl:apply-templates/>

I tried document('$file Name') and ($fileName) and neither work. Any
ideas?

The second format is correct. If it doesn't work, then your variable may
contain the wrong value. Try using

<xsl:variabl e name="fileName" >
<xsl:text>../../data/models/</xsl:text>
<xsl:value-of select="."/>
<xsl:text>.xm l</xsl:text>
</xsl:variable>

or

<xsl:variabl e name="fileName" >
<xsl:value-of select="concat( '../../data/models/',.,'.xml')"/>
</xsl:variable>

and display the value at run-time for checking using <xsl:message>

///Peter
--
XML FAQ: http://xml.silmaril.ie/


Dec 13 '06 #4

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

Similar topics

0
2684
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron extension responsible for the xslt functions. The problem i have is that the obtained transformation is not the waited one. I try to proccess the...
3
2127
by: Justine Hlista | last post by:
I'm using xalan-j_2_6_0 and trying to get an example from Michael Kay's book to work: <xsl:template match="/"> <xsl:variable name="rainbow"> <color>red</color> <color>blue</color> <color>green</color> </xsl:variable>
5
9532
by: inquirydog | last post by:
Hi- Does anyone know a way to compare whether two nodes contain the same information in xslt (the name, attributes, and all content recursivly should be the same. I am interested in the case where node ordering matters, and also the case where it doesn't, but perhaps that is an advanced topic). Ideally the method should be available to...
4
3232
by: Frederik Srensen | last post by:
I include a xslt stylesheet with variables for all the error messages in my system. <xsl:variable name="Banner_error_1"> errormessage 1 for banner </xsl:variable> <xsl:variable name="Banner_error_2"> errormessage 2 for banner </xsl:variable>
12
3386
by: Keith Chadwick | last post by:
I have a fairly hefty XSLT file that for the sake of debugging and clarity I wish to split into some separate sub-templates contained within the same file. The master template calls an apply-templates and passes a node set to it. This template in turn defines approximately 15 variables that dictate how the following template should proceed....
2
1842
by: Michael Hamm | last post by:
I have the following XML file (simplified from the actual): <r> <o><n>1</n><si>s</si><v1>1</v1><v2>2</v2><v3>3</v3></o> <o><n>2</n><si>i</si><v1>4</v1><v2>5</v2><v3>6</v3></o> <o><n>3</n><si>s</si><v1>7</v1><v2>8</v2><v3>9</v3></o> <o><n>5</n><si>i</si><v1>10</v1><v2>11</v2><v3>12</v3></o>...
2
15374
by: Sharkie | last post by:
I'm relatively new to XSLT, having strong background in bunch of other programming languages (Perl, Java, etc.). I'm writing an XSLT stylesheet, converting XML into HTML. Everything works just fine, except for one detail which I don't know how to handle. I have one element, which sometimes ends with a period, and sometimes not (the value of...
2
2087
by: 张韡武 | last post by:
We have preffered language set as variable in xslt: <xsl:variable name="preferred_language"> zh </xsl:variable> Data: <name xml:lang="de">Raw Materials (Mining incl.)</name> <name xml:lang="zh">原材料(包括采矿业) </name>
3
9561
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the difference between two source documents and output node-sets which are "different" (changed or new) to new XML files using xsl:result-document To...
0
7374
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7632
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7783
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7392
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7720
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5931
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3422
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
996
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.