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

(not) evaluating a document name and a path in xslt

P: n/a
Hi,

suppose I get a document name a.xml and a path //foo/bar (which nodes
eventually to read from it) from another doc.

Problem: how to combine them so that the whole expression gets
evaluated. I've tried:

<xsl:variable name="imported" select="concat(document('$doc'),$path)"
/>

But this makes the value of imported [a sequence of linefeeds]
//foo/bar.

Another possibility:
<xsl:for-each select="xalan:evaluate(concat(document('$doc'),$pa th))">

...does not seem to work: the $path is ok but probably the
document('$doc') part is still a sequence of linefeeds so as a whole
the expression is meaningless.

Is there any way of defining "set the value of the variable to be
document('$doc') but do not evaluate it yet"?

Marko

Mar 23 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a

markoniinimaki wrote:
suppose I get a document name a.xml and a path //foo/bar (which nodes
eventually to read from it) from another doc.


Not sure I've read your question quite carefully enough, but what's
wrong with this?
<xsl:variable name="imported" select="document ($doc)//foo/bar" />

Mar 23 '06 #2

P: n/a
> Is there any way of defining "set the value of the variable to be
document('$doc') but do not evaluate it yet"?


<xsl:variable name="test">document('$doc')</xsl:variable>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Mar 23 '06 #3

P: n/a
Hi,

thanks for your answer. However, the following code

<xsl:variable name="nfile">y1980.xml</xsl:variable>
<xsl:variable name="ndoc">document('$nfile')</xsl:variable>
<xsl:value-of select="$nfile"/>
<xsl:value-of select="$ndoc"/>

results:
y1980.xml
document('$nfile')

Marko

Mar 23 '06 #4

P: n/a


markoniinimaki wrote:
<xsl:variable name="nfile">y1980.xml</xsl:variable>
<xsl:variable name="ndoc">document('$nfile')</xsl:variable>
<xsl:value-of select="$nfile"/>
<xsl:value-of select="$ndoc"/>

results:
y1980.xml
document('$nfile')


Perhaps you want e.g.
<xsl:variable name="nfile" select="'y1980.xml'" />
<xsl:variable name="ndoc" select="concat('document(&quot;', $nfile,
'&quot;)')" />

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 23 '06 #5

P: n/a
Hi,

<xsl:variable name="imported" select="document ($doc)//foo/bar" />

could work but "//foo/bar" is a variable. Thus concat($docvar,$pathvar)
does not work.
xalan:evaluate(concat($docvar,$pathvar)) could work but seemingly does
not..

It might be possible to refer to "docvar" by using a namespace. Is
there a way of forcing a new namespace for a file that streams trough
the processor ("-IN" file in xalan)?

Marko

Mar 23 '06 #6

P: n/a

markoniinimaki wrote:
could work but "//foo/bar" is a variable.


OK, that's hard (more than I can think of offhand)

But you can use a cascade of individual "name()=$foo" which will work
for dynamic selections

Mar 23 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.