1 Feb 2005 10:54
Re: Valid HTML Considered Harmful?
Michael Beddow <mbteil-2 <at> mbeddow.net>
2005-02-01 09:54:28 GMT
2005-02-01 09:54:28 GMT
Among off-list responses to my posting re grouping via keys in this thread was a note from Wendell suggesting the application of what, with characteristic generosity, he described as a "tweaklet", but is in truth the correction of a pretty major goof on my part. As tends to be the case with such goofs at their very worst, the effect isn't visible on the sample document, but it would have definitely unwanted consequences in a longer one. It concerns my (mis)use of the XSLT union operator "|". Ironically in my production code (nothing to do with xhtml generation, but everything to do with grouping) from which I adapted the example for posting, I had it right; but somehow I persuaded myself while writing the posting that the original formulation could be "abbreviated". Big mistake. My error is at the point where I say > So, leaving our predicate in place to filter the <p>s as > before, we extend the XPath to select children of those filtered<p>s, > whether they are text nodes or element children (along with any text > descendants those children may have), giving: > match = "p[q/ <at> rend='block']/text()|*" The narrative part is correct, but the sample XPath doesn't do what I claim. In XSLT, the operator "|" evaluates the XPath expressions either side of it and returns the union of the two resultant nodesets. What I wanted was the union of all the immediate text children of <p>s with at least one q child having <at> rend='block' (which my expression left of the "|" indeed matches) and the element children of <p>s matching the same filtering predicate. But what I stupidly placed to the right of the union operator in my attempt at terseness (!) was the bare expression "*", which of course selects all(Continue reading)
RSS Feed