[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

document scope difficulty (Was: decode( source, ... )

Subject: document scope difficulty (Was: decode( source, ... )
From: "Clark C. Evans" <clark.evans@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 5 Oct 1999 01:54:22 -0400 (EDT)
document scope
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.