[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] document scope difficulty (Was: decode( source, ... )
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|