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

RE: a namespace problem

Subject: RE: a namespace problem
From: "Dion Houston" <dionh@xxxxxxxxxxxxx>
Date: Wed, 3 Apr 2002 08:12:32 -0800
xpath matching rdf title rss
Hi Bryan:

The most obvious thing I see is the use of a default namespace.  This is
a highly misunderstood area of XPath/XSLT.

The short of it: XPath does not consider namespace prefixes, but rather
URIs when comparing elements... In your case, the following are
identical documents:

<Foo xmlns="http://purl.org/rss/1.0/"/>
<bar:Foo xmlns:bar="http://purl.org/rss/1.0/"/>

In XPath match expressions without a prefix are considered to be a NULL
(not default) namespace.  So for both of the above two documents:

<xsl:template match="Foo">

Will select no nodes.  To get what you expect, simply choose an
arbitrary namespace prefix for your default namespace, and use that in
expressions... Using the above prefix bar, the following will work:

<xsl:template match="bar:Foo">

For either of the two document instances above.

HTH!

Dion

-----Original Message-----
From: Bryan Rasmussen [mailto:bry@xxxxxxxxxx] 
Sent: Wednesday, April 03, 2002 7:30 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  a namespace problem


hi, I'm processing a rss file and I got some strange(to-me) results, no
doubt due to my misunderstanding apropos the functioning of multiple
namespaces in a document, anyhow I was just wondering why this
<xsl:template match="rdf:*">
<xsl:apply-templates select="channel"/></xsl:template>

<xsl:template match="channel"><h3 title="{description}"><a
href="{link}"><xsl:value-of  select="title"/></a></h3>
<xsl:apply-templates/>
</xsl:template>
didn't work

when this is


<xsl:template match="rdf:*">

<xsl:apply-templates select="*"/></xsl:template>



<xsl:template match="*[local-name()='channel']">
<h3 title="{child::*[local-name()='description']}"><a
href="{child::*[local-name()='link']}"><xsl:value-of
select="child::*[local-name()='title']"/></a></h3>
<xsl:apply-templates/>
</xsl:template>
of course I expected I might have to make some use of local-name() but
not
quite so much

I'm using msxml 4

the rss file is as follows:

<?xml version="1.0" encoding="iso-8859-1"?>

<rdf:RDF
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns="http://purl.org/rss/1.0/"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"
 xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
>

<channel rdf:about="http://www.bizreport.dk">
<title>BizReport</title>
<link>http://www.bizreport.dk</link>
<description>Internet Business Starts Here</description>
<dc:language>da</dc:language>
<items>
 <rdf:Seq>
  <rdf:li rdf:resource="http://www.bizreport.dk/article.php?id=410" />
  <rdf:li rdf:resource="http://www.bizreport.dk/article.php?id=409" />
  <rdf:li rdf:resource="http://www.bizreport.dk/article.php?id=408" />
  <rdf:li rdf:resource="http://www.bizreport.dk/article.php?id=407" />
  <rdf:li rdf:resource="http://www.bizreport.dk/article.php?id=406" />
 </rdf:Seq>
</items>
<image
rdf:resource="http://www.adsguide.com/templates/images/bizreport_network
02.g
if" />
</channel>

<image
rdf:about="http://www.adsguide.com/templates/images/bizreport_network02.
gif"
>
<title>BizReport</title>
<url>http://www.adsguide.com/templates/images/bizreport_network02.gif</u
rl>
<link>http://www.bizreport.dk/</link>
</image>

<item rdf:about="http://www.bizreport.dk/article.php?id=410">
<title>Spandt online rejsemarked: 150 milliarder kroner i
udsigt?</title>
<link>http://www.bizreport.dk/article.php?id=410</link>
<description>Rejsemarkedet gar mod udviklingen. Online rejsemarkedet er
nemlig praget af en markant vakst, og det synes hverken den
11....</description>
</item>

<item rdf:about="http://www.bizreport.dk/article.php?id=409">
<title>Opfind eller forsvind - Mindlab for staten</title>
<link>http://www.bizreport.dk/article.php?id=409</link>
<description>Inde i Erhvervs- og Okonomiministeriet sidder en mand, der
har
store visioner for den offentlige sektors fremtid. Han
hedder...</description>
</item>

<item rdf:about="http://www.bizreport.dk/article.php?id=408">
<title>Ideministeriet</title>
<link>http://www.bizreport.dk/article.php?id=408</link>
<description>Idekapitalen i Danmark er mere eller mindre
ikke-eksisterende.
Vi har en af verdens bedst uddannede arbejdsstyrker og er
et...</description>
</item>

<item rdf:about="http://www.bizreport.dk/article.php?id=407">
<title>Fremtidens tv i dag</title>
<link>http://www.bizreport.dk/article.php?id=407</link>
<description>af Keld Reinicke, Kanalredaktor, TV 2 ZuluDet var en ganske
almindelig dag, jeg besluttede mig for at finde ud...</description>
</item>

<item rdf:about="http://www.bizreport.dk/article.php?id=406">
<title>iTV mangler stadig skarmtakke</title>
<link>http://www.bizreport.dk/article.php?id=406</link>
<description>Udnyt mediekonvergensen, bade i markedsforingen og
salgsprocessen! Lav strategiske alliancer og del investeringen i de
forskellige medie-platforme! Men husk...</description>
</item>

</rdf:RDF>


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


 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.