[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Using document() and XPath to extract data from multip

Subject: Using document() and XPath to extract data from multiple namespaces in multiple files
From: "SORENS,MICHAEL (HP-Boise,ex1)" <michael.sorens@xxxxxx>
Date: Wed, 13 Aug 2003 14:47:10 -0700
hp boise
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. Any thoughts appreciated...

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
file test.xsl
<?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"
		xsi:schemaLocation="stuff.com ../stuff.xsd"
		>
	<cc:indexList>
	<xsl:for-each select="file">
		<xsl:variable name="extNode"
select="document(.)/cc:subDoc"/>
		<cc:indexItem>
			<file><xsl:value-of select="."/></file>
			<title><xsl:value-of
select="$extNode/cc:head/cc:title"/></title>
			<version><xsl:value-of
select="$extNode/cc:head/cc:version"/></version>
<!-- TBD does not work -->
			<display-title><xsl:value-of
select="$extNode/cc:head/foo"/></display-title>
<!-- TBD does not work -->
			<keywords><xsl:value-of
	
select="$extNode/cc:head/meta[@name='keywords']/@content"/>
			</keywords>
		</cc:indexItem>
	</xsl:for-each>
	</cc:indexList>
	</cc:myDoc>
</xsl:template>

</xsl:stylesheet>
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
file try.xml
<?xml version="1.0" encoding="UTF-8"?>
<files>
	<file>motivation.xml</file>
	<file>history.xml</file>
</files>
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
file motivation.xml:
<?xml version="1.0"?>
<cc:subDoc
	xmlns:cc="stuff.com"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="stuff.com ../stuff.xsd">
<cc:head>
<cc:title>Motivation</cc:title>
<cc:version>$Revision: 1.1 $</cc:version>
<foo>bar1</foo>
<meta name="description" content="motivation doc" />
<meta name="keywords" content="motivation, why, example" />
</cc:head>
<cc:body/>
</cc:subDoc>
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
file history.xml:
<?xml version="1.0"?>
<cc:subDoc
	xmlns:cc="stuff.com"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="stuff.com ../stuff.xsd">
<cc:head>
<cc:title>History</cc:title>
<cc:version>$Revision: 1.2 $</cc:version>
<foo>bar2</foo>
<meta name="description" content="history doc" />
<meta name="keywords" content="history, archive" />
</cc:head>
<cc:body/>
</cc:subDoc>
- - - - - - - - - - - - - - - - - - - - - - - - - - - -

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.