|
Subject: document scope difficulty (Was: decode( source, ... ) From: "Clark C. Evans" <clark.evans@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 5 Oct 1999 01:54:22 -0400 (EDT) |
Is there a way to specify the "primary" document
in a <xsl:for-each select="" > construct?
On Sun, 3 Oct 1999, James Clark wrote:
> <xsl:value-of
> select="document('month.xml')
> /months/month[number(substring('19991003',5,2))]"/>
This was *sweet* ... now I'd like to take it one step further
and drive report headers/footers using this technique.
Unfortunately, the document() specifier works too well...
it seems to be changing the entire scope of the construct.
Here is an example for illustration:
----------------- stylesheet.xsl ------------------
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
xmlns="http://www.w3.org/TR/REC-html40"
result-ns="">
<xsl:template match="/">
<html>
<xsl:for-each select="document('two.xml')//day-list" >
<xsl:value-of select="day" />
<xsl:value-of select="sum(//amount)" />
</xsl:for-each>
</html>
</xsl:template>
</xsl:stylesheet>
----------------- one.xml -------------------------
<entry-list>
<entry>
<day>mon</day>
<amount>34</amount>
</entry>
</entry-list>
----------------- two.xml -------------------------
<root>
<day-list>
<day>mon</day>
</day-list>
<amount> 99 </amount>
</root>
----------------- command line --------------------
xt one.xml stylesheet.xsl
----------------- expected output -----------------
mon 34
----------------- actual output -------------------
mon 99
---------------------------------------------------
The sum(//amount), unfortunately, seems to be
pointing at document two.xml, not document one.xml.
Any way to fix this "scope" problem?
Of course, I could "sum(document('one.xml')//amount)", however:
a) I was not expecting document('two.xml') to change
the current root node; is this a bug?
b) You can't hard code the input file name beacuse
it will change; perhaps a param could be set automagically?
c) I found that document('') means the stylesheet...
so I was hoping for some other like trick!
Thank you!
Clark
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: decode( source,'if-one','1', .., James Clark | Thread | Dynamic Documents / Creating a node, Clark C. Evans |
| Re: XSL and XSLT, Paul Tchistopolskii | Date | RE: Is fo:block an area-container?, Bovone Stefano |
| Month |