471,594 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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="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
3 3846
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
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
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.

Similar topics

reply views Thread by Sergio del Amo | last post: by
3 posts views Thread by Justine Hlista | last post: by
5 posts views Thread by inquirydog | last post: by
4 posts views Thread by Frederik Sørensen | last post: by
12 posts views Thread by Keith Chadwick | last post: by
2 posts views Thread by Michael Hamm | last post: by
2 posts views Thread by Sharkie | last post: by
2 posts views Thread by 张韡武 | last post: by
3 posts views Thread by super.raddish | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.