The xsl:number element works by walking up the document tree and counting the specified elements. A nodeset created with dovcument() is not attached to the main document, and xsl:number can't walk up the tree. You end up with incorrect numbers.
A solution to this problem is to pipeline two transformations: the first one aggregates all sub-documents into one, and the second transformation applies the styles and numbering.
Another solution could, using only one transformation, build a unique nodeset (using xalan:nodeset for example) containing all sub-documents, and then apply the numbering on that nodeset.
I included a example of the first solution, implemented as an OXF pipeline. Please let me know if you have further questions.
Regards Julien
<?xml version="1.0" encoding="iso-8859-1"?> <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline">
<p:processor uri="oxf/processor/xslt">
<p:input name="data">
<xmldoc title="Main Title">
<section title="Chapter One">
<section title="Introduction">
<text>
This is an introduction.
</text>
</section>
<section file="sub_document.xml"/>
</section>
</xmldoc>
</p:input>
<p:input name="config">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/1999/XSL/Transform http://www.orbeon.com/1999/XSL/Transform">
<xsl:template match="section">
<xsl:choose>
<xsl:when test="string-length(@file) > 0">
<xsl:variable name="external-document"
select="document(@file)/xmldoc"/>
<xsl:copy>
<xsl:apply-templates select="$external-document"/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@*|node()" priority="-2">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
</p:input>
<p:output name="data" id="full"/>
</p:processor><p:processor uri="oxf/processor/xslt">
<p:input name="data" href="#full"/>
<p:input name="config">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/1999/XSL/Transform http://www.orbeon.com/1999/XSL/Transform">
<xsl:template match="section">
<div>
<xsl:variable name="section-title">
<xsl:number level="multiple" count="section" format="1. "/>
<xsl:value-of select="@title"/>
</xsl:variable>
<a>
<xsl:attribute name="name">
<xsl:value-of select="translate($section-title, ' ���', '_oau')"/>
</xsl:attribute>
</a>
<div>
<xsl:attribute name="id">title <xsl:value-of select="count(ancestor::*[self::section])"/></xsl:attribute>
<xsl:value-of select="$section-title"/>
</div>
<div id="section">
<xsl:apply-templates/>
</div>
</div>
</xsl:template>
</xsl:stylesheet>
</p:input>
<p:output name="data" id="numbering"/>
</p:processor> <p:processor uri="oxf/processor/html-serializer">
<p:input name="config">
<config>
<content-type>text/html</content-type>
</config>
</p:input>
<p:input name="data" href="#numbering"/>
</p:processor></p:config>
Thomas Lehmann wrote:
Sorry for missing XSL ... here's the code...
explain: When using the attribute 'file' I'm loading the given xml document and applying the content, otherwise I'm using the numbering (section-title). In addition there's creating an anchor for that section, and calculating the depth for assign a stylesheet 'title' numbered from '0' to 'n'. At lease the content gets applied. That's it.
<xsl:template match="section">
<xsl:choose>
<xsl:when test="string-length(@file) > 0">
<xsl:variable name="external-document" select="document(@file)/xmldoc" />
<xsl:apply-templates select="$external-document" />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="section-title">
<xsl:number level="multiple" count="section" format="1. " />
<xsl:value-of select="@title"/>
</xsl:variable>
<a>
<xsl:attribute name="name"><xsl:value-of select="translate($section-title, ' ���', '_oau')"/>
</xsl:attribute>
</a>
<div>
<xsl:attribute name="id">title<xsl:value-of select="count(ancestor::*[self::section])"/></xsl:attribute>
<xsl:value-of select="$section-title"/>
</div>
<div id="section"> <xsl:apply-templates /> </div> </xsl:otherwise> </xsl:choose> </xsl:template>
Regards, Thomas
_______________________________________________ oxf-users mailing list [EMAIL PROTECTED] http://mail.orbeon.com/mailman/listinfo/oxf-users
