[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: document scope difficulty (Was: decode( source, ... )
Subject: Re: document scope difficulty (Was: decode( source, ... ) From: "Steve Muench" <smuench@xxxxxxxxxxxxx> Date: Tue, 5 Oct 1999 00:26:23 -0700 |
I get mon34 as the output using our Oracle XSLT engine so I'm pretty sure the sum one is just a bug. You could use a top-level: <xsl:stylesheet> <xsl:param name="monthlookup">defaultfile.xml</param> and later use: document($monthlookup)//xyz How you override the default values of top-level "stylesheet" param's is implementation-specific... ________________________________________________________ Steve Muench, BC4J Development Team & XML Evangelist http://technet.oracle.com/tech/java http://technet.oracle.com/tech/xml ----- Original Message ----- From: Clark C. Evans <clark.evans@xxxxxxxxxxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxx> Cc: James Clark <jjc@xxxxxxxxxx> Sent: Monday, October 04, 1999 10:54 PM Subject: 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 | XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Dynamic Documents / Creating a node, Clark C. Evans | Thread | Re: document scope difficulty (Was, James Clark |
XSL Examples.., Joy Daniel | Date | stylesheet woes, Greg Bylenok |
Month |