[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: simulating conditional <xsl:include> behavior?
> What I would like to do is the equivalent of wrapping > <xsl:include> in an <xsl:if> or <xsl:for-each>. I want to pull into my stylesheet > certain XSLT templates only when certain conditions are true -- namely, > the presence of certain data in a source document. This is going to be tricky, because generally the stylesheet will be read and analysed before the source document is read (e.g. the processor will generally read the xsl:strip-space and xsl:preserve-space elements before it builds the source document tree; certainly it needs to read them before evaluating any XPath expressions, because they can affect the result). One thing you could try is to use external entity references in the stylesheet instead of <xsl:include> (or perhaps in conjunction with xsl:include). You could filter the SAX event stream used by the XSL processor to read the stylesheet, and your filter could resolve the external entity references based on any information it has to hand, including, if you can afford the performance hit, reading the source document. In SAXON, if you're not scared of getting into the guts, you could define an extension element my:include, make the implementation class that supports it a subclass of the one that supports xsl:include, and thus again use your own logic to decide whether or not to invoke the superclass behaviour. But it still wouldn't have access to the source document at this stage of processing. Mike Kay 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
|