[xsl] Processing input xml containing containing namespace switch

Subject: [xsl] Processing input xml containing containing namespace switch
From: "Revill, D.J." <D.J.Revill@xxxxxx>
Date: Thu, 15 Jul 2004 11:20:14 +0200
Hello,

I'm having difficulty processing an input xml document that contains an
embedded section of xml in a different namespace to that of the root element.
The new namespace (and also schema location) are declared at the point they
occur in the input. My specific problem is that I can't seem to match on
<osis> (point where the new namespace begins), or any of the elements that
fall within <osis>. Its as if the xslt processor doesn't "see" the elements in
the new namespace. I'm using Saxon 6.4.4 to process and an xslt 1.0
stylesheet.

- I declared the extra namespaces used in the input within my stylesheet
- I note that the namespace
xmlns="http://www.bibletechnologies.net/2003/OSIS/namespace"; doesn't specify a
specific prefix (is this a problem?)
- I checked using the namespace-uri() within which namespace <osis>...</osis>
is and this is given as http://www.bibletechnologies.net/2003/OSIS/namespace
.

Input xml is:
---------------

<?xml version="1.0" encoding="UTF-8"?>
<wrapper>
	<a>Some content</a>
	<b>
		<osis
xsi:schemaLocation="http://www.bibletechnologies.net/2003/OSIS/namespace
osisCore.2.0.xsd"
			  xmlns="http://www.bibletechnologies.net/2003/OSIS/namespace";
			  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
		<osisText osisIDWork="NBV" osisRefWork="Bible" xml:lang="nl">
		<header>Some text</header>
		<div type="book" osisID="Mark">
		<title type="main">Het evangelie volgens Marcus</title>
		<p>Some text</p>
		</div>
		</osisText>
		</osis>
	</b>
</wrapper>

Stylesheet is:
----------------

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:saxon="http://icl.com/saxon";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns="http://www.bibletechnologies.net/2003/OSIS/namespace";
extension-element-prefixes="saxon">

	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
	<xsl:strip-space elements="*"/>

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

	<xsl:template match="osis">
		<MATCH name="{name()}">
			<!-- Other logic here -->
			<xsl:apply-templates/>
		</MATCH>
	</xsl:template>

	<!-- Defualt template to catch and output all elements, attributes, and
element content-->
	<xsl:template match="*|@*|text()">
		<xsl:copy>
			<xsl:apply-templates select="*|@*|text()"/>
		</xsl:copy>
	</xsl:template>



</xsl:stylesheet>

- The template match="osis" doesn't match on <osis>
- Nor does match="osis[namespace-uri() =
'http://www.bibletechnologies.net/2003/OSIS/namespace']"
- However *[namespace-uri() =
'http://www.bibletechnologies.net/2003/OSIS/namespace'] does match, but is
very generic
- My default catch all template match="*|@*|text()" also matches.

Any ideas as to why match="osis" doesn't work? Am I missing a ns prefix - if
so what? Any help much appreciated - probably I missed something obvious.

Thanks

Derek Revill

--------------------------------------------
Specialist XML/SGML, Digitaal Productiecentrum
http://www.uba.uva.nl/dpc/

Elektronische Diensten
Universiteitsbibliotheek, Universiteit van Amsterdam
Singel 425, 1012 WP Amsterdam
Netherlands
--------------------------------------------

Current Thread