xsl-list
[Top] [All Lists]

RE: [xsl] Separate same level elements on a criteria

2007-01-19 15:37:15
You can process all the children other than those in the group starting with
<head>TOC</head> like this:

  <xsl:for-each-group select="*" group-starting-with="head">
    <xsl:apply-templates select="if (.='TOC') then () else
current-group()"/>
  </xsl:for-each-group>

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


-----Original Message-----
From: Spencer Tickner [mailto:spencertickner(_at_)gmail(_dot_)com] 
Sent: 19 January 2007 20:31
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Separate same level elements on a criteria

Hi Group,

I'm wondering if anyone has a slick way of solving this 
problem. I have an xml document like:

<root>
      <head_document>Title</head_document>
      <para>This is a paragraph</para>
      <bold_para>This is a paragraph</bold_para>
      <head>TOC</head>
      <section>1. Title</section>
      <section>2. Title</section>
      <head>Heading 1</head>
      <paragraph_indent>This is a paragraph</paragraph_indent>
      <paragraph_outdent>This is a paragraph</paragraph_outdent>
      <head>Heading 2</head>
      <paragraph>This is a paragraph</paragraph>
      <chart>This is a chart</chart>
</root>

Basically I'm making a bunch of html documents from this xml 
document and a table of contents. Table of contents is easy 
(I need to grab the <head_document> element and skip the 
<head>TOC</head> element):

<xsl:template match="root" mode="toc">
<ul>
<xsl:for-each select="head_document|head[not(contains(., 
'TOC'))]"> <li>Do Something</li> </xsl:for-each> </ul> </xsl:template>


Ok, so that all works great, I now have to do something 
similar to above but apply-templates to all the elements that 
belong with the heads I want. ie: <head_document> down to 
<head>, skip <head>TOC</head>, next <head> element down to 
the next <head> element, repeat.

Any ideas on how to do this would be very helpful. I thought 
group-by would probably be the answer but so far my research 
hasn't turned up anything.

Thanks,

Spencer

--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>