Re: [xsl] Including multiple XML documents with associated stylesheets

Subject: Re: [xsl] Including multiple XML documents with associated stylesheets
From: "Alex Hildyard" <alexhildyard@xxxxxxxxxxx>
Date: Thu, 20 Nov 2003 20:45:57 -0000
I found a helpful message in the archives by Jenni Tennison on this one, but
unfortunately it doesn't address the matter of XSL stylesheets in
sub-documents, rather than using the transformation templates of the
governing document.

I have also searched through Google on "multiple XML documents" and various
related filters, to no avail. Accordingly, I will perform the separate
transformations and recombination in Javascript, unless anyone here can
point me to a better alternative?

Regards,

Alex


----- Original Message ----- 
From: "Alex Hildyard" <alexhildyard@xxxxxxxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, November 19, 2003 1:55 PM
Subject: [xsl] Including multiple XML documents with associated stylesheets


>
> Hi,
>
> I've looked through the FAQ but haven't found a solution to this problem:
> I'm trying to include multiple XML documents, and each sub-document has
its
> own stylesheet. What I find is that I can load each sub-document in
> isolation and its associated stylesheet is applied without problems
> (test-file.xml), but the stylesheet is blatantly ignored when I try to
load
> it as part of a collection of documents (files-list.xml). My understanding
> is that the individual stylesheets' markup isn't being applied because
I've
> never explicitly requested it to be applied, but I'm not quite sure
exactly
> what "apply-templates" argument I would want in this case?
>
> I'm enclosing the files below, to make things a bit clearer:
>
> Many thanks,
>
> Alex
>
> [files-list.xml]
> <?xml version="1.0" encoding="utf-8" ?>
> <?xml-stylesheet type="text/xsl" href="iterate-files.xslt" ?>
> <!-- This top-level document holds references to the set of external
> files that should be marked up on this page. It can also hold
> any scripts that should be globally accessible
> -->
> <html>
> <head />
> <body>
> <files>
> <file src="test-file.xml"></file>
> <file src="test-file2.xml"></file>
> </files>
> </body>
> </html>
>
>
> [iterate-files.xslt]
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:transform version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="html"/>
> <!-- 
> This template iterates through the file list defined within
> a <files> element and processes the set of external XML files
> contained within it
> -->
> <xsl:template match="files">
> <xsl:for-each select="file">
> <xsl:for-each select="document(@src)">
> <xsl:copy-of select="test" />
> </xsl:for-each>
> </xsl:for-each>
> </xsl:template>
> </xsl:transform>
>
> [test-file.xml]
> <?xml version="1.0" encoding="utf-8" ?>
> <?xml-stylesheet type="text/xsl" href="test-file.xslt" ?>
> <test>
> <div>
> This tag shouldn't appear
> </div>
> </test>
>
> [test-file.xslt]
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:transform version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="html"/>
> <!-- All the directives in this file seem toget ignored -->
> <xsl:template match="/">
> <xsl:apply-templates />
> </xsl:template>
> <!-- Template to prove directives in this file are processed:
> replace the contents of the <div> with a new string
> -->
> <xsl:template match="div">
> This text should appear
> </xsl:template>
> </xsl:transform>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread