[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Using document() and XPath to extract data from multiple namespac es in multiple files


Subject: Re: [xsl] Using document() and XPath to extract data from multiple namespac es in multiple files
From: Oleg Tkachenko <oleg@xxxxxxxxxxxxx>
Date: Thu, 14 Aug 2003 10:28:52 +0200

SORENS,MICHAEL (HP-Boise,ex1) wrote:

I am attempting to use xsltproc to process try.xml with test.xsl. The files
history.xml and motivation.xml are read by test.xsl. The issue is this:
while I am able to extract data with explicit namespaces (cc:title and
cc:version in this case), when I attempt to extract data from the unadorned
"foo" element or an attribute of the unadorned "meta" element, I get
nothing.
In fact foo and meta elements are in http://www.w3.org/1999/xhtml namespace due to default namespace declaration, so you have to declare http://www.w3.org/1999/xhtml namespace in the stylesheet, bind it to a prefix and use that prefix to select those elements:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:cc="stuff.com"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" />

<xsl:template match="/files">
	<cc:myDoc
		xmlns:cc="stuff.com"
		xmlns="http://www.w3.org/1999/xhtml"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
...
			<display-title><xsl:value-of
select="$extNode/cc:head/foo"/></display-title>
select="$extNode/cc:head/xhtml:foo"/></display-title>
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel


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




Current Thread