|
Subject: [xsl] unwanted noNamespaceSchemaLocation? From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx> Date: Wed, 15 Sep 2010 00:44:06 +1200 |
Hi
I have a number of separate XML files which each have <document> as their
outermost node. A document element might look like this:
<document
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../util/docs.xsd"
version="1.80"
>
...
</document>
Documents may contain <include> elements, which point to other documents.
Thus:
<document ..>
<title>Test Document</title>
<include srcfile="intro.xml"/>
<include srcfile="middle.xml"/>
<include srcfile="end.xml"/>
</document>
where each of the XML documents referred to in the srcfile attributes have
the same schema declaration as the outer document.
We have a particular XML stylesheet which processes a document and creates
an expanded version which contains all included documents in the single
file; in this document the (sub)documents are children of <included>
elements.
A minimal version of the expand.xsl stylesheet is as follows:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" />
<xsl:template match="/">
<xsl:apply-templates>
<xsl:with-param name="currdoc" />
</xsl:apply-templates>
</xsl:template>
<!-- Content of include'd subfiles inside an includED element -->
<xsl:template match="include">
<xsl:param name="currdoc" />
<xsl:element name="included">
<xsl:attribute name="srcfile">
<xsl:value-of select="@srcfile" />
</xsl:attribute>
<xsl:apply-templates select="document(@srcfile)/*">
<xsl:with-param name="currdoc" select="@srcfile" />
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<xsl:template match="*">
<xsl:param name="currdoc" />
<!-- don't want to copy namespace nodes, hence <xsl:element> instead of
<xsl:copy> -->
<xsl:element name="{name()}">
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="node()">
<xsl:with-param name="currdoc" select="$currdoc" />
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:copy />
</xsl:template>
My question is, how can I eliminate the
xsi:noNamespaceSchemaLocation="../../util/docs.xsd"
attribute from all the lower level <document> elements?
The stylesheet must be XSL 1.0 because that's a restriction of one of the
environments in which it runs (although if there is an XSL2 solution I would
be interested in it for the future).
Cheers
Trevor
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Problem with Key matching, Etheridge, Stephen | Thread | Re: [xsl] unwanted noNamespaceSchem, David Carlisle |
| RE: [xsl] Problem with Key matching, Etheridge, Stephen | Date | Re: [xsl] unwanted noNamespaceSchem, David Carlisle |
| Month |