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

Re: Namespace problem

Subject: Re: Namespace problem
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Tue, 26 Feb 2002 14:50:27 -0500
familyml
Eric,

Your xml file has a default namespace, http://purl.org/rss/1.0/.  Therefore,
the "item" element is in that namespace.  For the xslt processor to match
it, it needs to know it should look for the "item" element ***in that
namespace***.  To do that, you need to declare the namespace in the
stylesheet, using an arbitrary prefix (it cannot be the default namespace
because the template needs to match a name with a prefix).  You use that
prefix with the element's name.  Here is an example using your xml file:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xx='http://purl.org/rss/1.0/'
 exclude-result-prefixes='xx'>

<xsl:template match="/">
<result>
        <xsl:value-of select='count(//xx:item)'/> "item" element(s)
</result>
</xsl:template>

<xsl:template match='*'/>
</xsl:stylesheet>


Here are the results of running this stylesheet on your file:

  <result> 1 "item" element(s)</result>

Cheers,

Tom P

[Eric Vitiello]

I'm trying to apply a simple transformation to the file below, and for some
reason I'm unable to get any nodes returned.  I think it may be a namespace
issue.  I'm totally stumped, and losing hair.

apply this XPath:  //item

should return a nodeset of items


the XML:



<?xml version="1.0"?>
<rdf:RDF
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://purl.org/rss/1.0/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">

<channel rdf:about="http://www.perceive.net/">
<title>Perceive Designs</title>
<link>http://www.perceive.net</link>
<description>Your perception of design and technology</description>
<lastBuildDate>Tue, 26 Feb 2002 13:26:00 GMT</lastBuildDate>
<docs>http://www.perceive.net</docs>
<managingEditor>eric@xxxxxxxxxxxx (Eric Vitiello)</managingEditor>
<webMaster>webmaster@xxxxxxxxxxxx (Perceive Designs Webmaster</webMaster>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
</channel>

<item>
<title>FamilyML DTD Released</title>
<link>http://www.vitiello.org/familyml.htm</link>
<description>
<p>The DTD used in created in the <a href="http://www.vitiello.org">Vitiello
Family Tree</a> has finally been released to the public. You can read about
the FamilyML specification and download the DTD at the <a
href="http://www.vitiello.org/familyml.htm">Vitiello Family Tree
Website</a>.  The Current version of the DTD, 0.5 may be linked directly to
at: <a
href="http://www.vitiello.org/dtd/0.5/family-tree.dtd">http://www.vitiello.o
rg/dtd/0.5/family-tree.dtd</a></p>
</description>
<dc:date>2002-02-22</dc:date>
<dc:language>en</dc:language>
<dc:source></dc:source>
<dc:creator></dc:creator>
</item>
</rdf:RDF>






 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.