xsl-list
[Top] [All Lists]

RE: [xsl] Wrap HTML headings and following siblings in <section/>

2010-03-27 06:13:59

Currently processors choke on the XPath,

(html:h1|html:h2|html:h3|html:h4|html:h5|html:h6)/following-si
bling::node()

That's a legal XPath 2.0 expression, but it's not legal in 1.0. You have to
write

*[self::h1|self::h2|...]/following-sibling::node()

Though it's probably more efficient to do

*[preceding-sibling::*[self::h1|self::h2|self::h3...]]

Looking at your code, you're trying to use this as an XSLT pattern rather
than as an XPath expression. For a pattern, you need to use this last form
whether you're in 1.0 or 2.0.

Overall, I think this kind of problem is much better tackled using sibling
recursion, where you apply-templates to the first sibling, it does
apply-templates to the next sibling, and so on. Or in 2.0, you can use
<xsl:for-each-group group-starting-with="h1"/>.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>