[XML-SIG] xslt: incorporating xml with document()

Jed Parsons jedp@ilm.com
Tue, 28 May 2002 09:45:49 -0700 (PDT)


Salutations.

I want to incorporate some xml pieces into a larger document using the
document() function in xslt with 4xslt.  When I do, xsl:numbers for
elements in the original document get reset on the corresponding
elements in the included xml.

Here's an example - two xml documents, a stylesheet, and some output:

		      * * * This document: * * *

<foo>
 <section>   <title>One</title>
 </section>

 <include href="tiny.xml" />

 <section>   <title>Three</title>
 </section>
</foo>

	  * * * And this document called "tiny.xml": * * *

<foo>
 <section   <title>Insert me as number Two</title>
 </section>
</foo>

	     * * * When munged by this stylesheet: * * *

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0"
                xmlns="http://www.w3.org/1999/xhtml">

<xsl:output method="html"/>

<xsl:number level="multiple" count="section" />

<xsl:template match="foo">
 <xsl:apply-templates select="section|include" />
</xsl:template>

<xsl:template match="section">
 <h2>
  <xsl:number level='multiple' count='section' format='1'/>.
  <xsl:apply-templates select="title" />
 </h2>

 <xsl:apply-templates select="section|include" />
</xsl:template>

<xsl:template match="include">
 <xsl:apply-templates select="document(@href)/foo/section"/>
</xsl:template>

<xsl:template match="title">
 <xsl:apply-templates />
</xsl:template>

</xsl:stylesheet>

		    * * * Give me this result: * * *


<h2>1. One</h2>

<h2>1. Insert me as number Two</h2>

<h2>2. Three</h2>

What can I do to ensure that elements in the included document will be 
enuerated in the same series as elements in the original document?

Thanks for any advice,

Jed


-- 
Jed Parsons       Industrial Light + Magic  (415) 448-2974 
	     
grep(do{for(ord){(!$_&&print"$s\n")||(($O+=(($_-1)%6+1)and
grep(vec($s,$O++,1)=1,1..int(($_-6*6-1)/6))))}},(split(//,
"++,++2-27,280,481=1-7.1++2,800+++2,8310/1+4131+1++2,80\0.  What!?")));