xsl-list
[Top] [All Lists]

Re: [xsl] Selecting between heading tags in XHTML

2014-10-30 13:42:45
Mark Giffin m1879(_at_)earthlink(_dot_)net wrote:
I want to select all siblings between heading tags in an XHTML file, as
shown below.

<div>
     <h4>my heading</h4> <<<---- select from this sibling
     <ol>
       <li></li>
     </ol>
     <p></p>
     <p></p>
     <p></p>
     <ul>
       <li></li>
     </ul>      <<<<---- all the way down to this sibling
     <h1></h1>  <<<<---- Do not select this sibling or anything after it
     <p></p>
     etc.
</div>

Given the context of <h4> above, I figure that

following-sibling::*[some predicate here]

would do this but I haven't guessed what would exclude the <h1> (or
<h2>, etc.) and everything that follows it. What's a good way to do this?

Assuming XSLT 2.0 I would use

  <xsl:template match="div">
<xsl:for-each-group select="*" group-starting-with="h1 | h2 | h3 | h4 | h5 | h6">
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

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