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[(_at_)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