Re: general purpose filter stylesheet
I can't think of any way to do this without modifying the query. For example, if you could get: ((descendent-or-self::author='Date' or descendent-or-self::title='Database Systems') and descendent-or-self::number='1') Then it would be pretty simple to xxx:evaluate() this for every node and output the node if the test is true (although it would be innefficient). The problem is that XSLT isn't really the best language to be able to modify the query like that... good luck. ... Scratch that, I can think of a way (but an almost infinitely more innefficient way than above). It relies on your processor to provide an xxx:evaluate() function and be able to convert an RTF to a node-set. <xsl:param name="query">true()</xsl:param> <xsl:template match="*"> <xsl:variable name="flattened"> <xsl:copy> <xsl:copy-of select="@* | text()"/> <xsl:apply-templates mode="flatten"/> </xsl:copy> </xsl:variable> <xsl:if test="xxx:evaluate(concat('$flattened/*[', $query, ']'))"> <xsl:copy> <xsl:copy-of select="@* | text()"/> <xsl:apply-templates select="*"/> </xsl:copy> </xsl:if> </xsl:template> <xsl:template match="*" mode="flatten"/> <xsl:copy> <xsl:copy-of select="@* | text()"/> </xsl:copy> <xsl:apply-templates select="*" mode="flatten"/> </xsl:template> For each node, it creates an RTF called $flattened that contains a copy of the node and its attributes/text and all of its children, but the children are flattened so there is never more than one level deep of children. Then evaluate the query with the copy of the current node with the modified children and see if it matches. If it does, then copy the node to the output tree and repeat the process. This would get pretty slow pretty fast, and it requires that the query is always in a flattened form (no child/parent tests). But it is the only way I can think of without modifying the original query. On Thursday 14 March 2002 14:17, Robert Sösemann wrote: > My query is an boolean expression: > ########################### > > ((author='Date' or title='Database Systems') and number='1') > PROBLEM: 'number' is not part of the same parent as 'author' -- Peter Davis I'd rather push my Harley than ride a rice burner. 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