By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 814 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

referencing an xslt variable

P: n/a
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="coordinates" select="document( REFERENCE
FILENAME VARIABLE HERE)"/>
<xsl:apply-templates/>

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

Dec 12 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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="coordinates" select="document( REFERENCE
FILENAME VARIABLE HERE)"/>
<xsl:apply-templates/>

I tried document('$fileName') 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>.xml</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

P: n/a
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>.xml</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.silmaril.iewrote in message
news:4u*************@mid.individual.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: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="coordinates" select="document( REFERENCE
FILENAME VARIABLE HERE)"/>
<xsl:apply-templates/>

I tried document('$fileName') 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>.xml</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

P: n/a
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.com.auwrote in message
news:45***********************@authen.yellow.readf reenews.net...
>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>.xml</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.silmaril.iewrote in message
news:4u*************@mid.individual.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: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="coordinates" select="document( REFERENCE
FILENAME VARIABLE HERE)"/>
<xsl:apply-templates/>

I tried document('$fileName') 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>.xml</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 #4

This discussion thread is closed

Replies have been disabled for this discussion.