George,
Thank you so much, this is perfect!
David
George Cristian Bina wrote:
Hi David,
When you match a session you can apply the templates further only on
the elements following the current session until the next session
element instead of the elements inside the current session element.
Assuming the following input document:
<?xml version="1.0" encoding="UTF-8"?>
<test>
<section>section one</section>
<para>para1</para>
<para>para2</para>
<section>section two</section>
<para>para3</para>
</test>
then the following stylesheet
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:apply-templates select="test/section"></xsl:apply-templates>
</xsl:template>
<xsl:template match="section">
<!-- create section file file -->
section
<xsl:variable name="sid" select="generate-id(.)"/>
<xsl:apply-templates
select="following-sibling::*[name()!='section' and
generate-id(preceding-sibling::section[1])=$sid]"/>
</xsl:template>
<xsl:template match="para">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
will get as output:
section
para1para2
section
para3
Hope that helps,
George
-----------------------------------------------
George Cristian Bina
<oXygen/> XML Editor - http://www.oxygenxml.com
David Elsmore wrote:
I want to transform an xml file, outputting separate sections into
multiple html documents. If the xml was srtructured as follows I
would have no problem, I could simply use <xsl:for-each
select="section">
<section>
<title>section one</title>
<para/>
<para/>
</section>
However, the structure of the xml file (over which I have no control)
is more like:
<section>section one</section>
<para/>
</para>
<section>section two</section>
<para/>...
The section tags, rather than wrap separate areas of content merely
indicate where a new section begins
Is there an easy way to do this?
Thanks for your help
David
--+------------------------------------------------------------------
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>
--+--
--
David Elsmore
IT Development Manager
School of Social Sciences and Law
Oxford Brookes University
Tel: 01865 484176
email: delsmore(_at_)brookes(_dot_)ac(_dot_)uk