[Home] [By Thread] [By Date] [Recent Entries]
Dear list,
I have been trying some variants, but I think I've been stuck in the namespaces and context location labyrinth. What I want seems easy: I have a set of documents, all valid XML and want to output the contents of these documents, either as one big XML document, or as a set of documents. In essence: using the copy idiom on each document and, optionally, doing something with the tree that is input from the document() function. Problem: all my nodes are gone and the external documents are output as one big piece of text (except for the tags "doc" and "input-file") and I don't seem to be able to find specific values, like the "tableData" tag below. I know this is usually a namespace problem, but I don't know how to solve it. Because it does not even work for one input file, I provide a stripped down version of my XSLT below, that parses one external xml document. Namespace of input xml document: this is equal to the current xslt document (just because saxon needs an input document. I don't actually use it) Namespace of document() xml doc: "http://www.nuntia.com/tablewiz1.0" Namespace of output document: "http://www.nuntia.com/tablewiz1.0" XSLT file: <xsl:stylesheet version="2.0" xmlns = "http://www.nuntia.com/tablewiz1.0" exclude-result-prefixes = "nuntia xsl xs fn xdt" xpath-default-namespace = "http://www.nuntia.com/tablewiz1.0"> <xsl:output indent="yes" /> <!-- name of the input file or files --> <xsl:param name="input-file" select="'test.xml'" /> <!-- load the documents --> <xsl:variable name="documents"> <doc> <input-filename><xsl:value-of select="." /></input-filename> <xsl:value-of select="document($input-file)" /> </doc> </xsl:variable> <xsl:template match="/"> <output> <xsl:for-each select="$documents/doc"> <xsl:apply-templates select="." mode="copy" /> </xsl:for-each> </output> </xsl:template> <xsl:template match="node() | @*" mode="copy"> <xsl:copy> <xsl:apply-templates select="@* | node()" mode="copy"/> </xsl:copy> </xsl:template> </xsl:stylesheet> XML file that is input using document() function, namely test.xml:
<?xml version="1.0" encoding="UTF-8"?>
<tableData name="bla">
<description>Table description</description>
<rows total="3">
<row id="35" row-index="not-applicable">
<cell>Row1Cell1</cell>
<cell>Row1Cell2</cell>
</row>
</rows>
</tableData>
|

Cart



