XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
John BlackSubject: Accessing tags in the default namespace
Author: John Black
Date: 10 Jan 2004 10:28 AM
When I try to use a default namespace:
xmlns="http://example.com", I am unable to
locate anything with xpath expressions. I mean


can not be found with /root/unqualifiedTag.

if I have a namespace declared and the tags are qualified, everything works.
xmlns:ns="http://example.com"


can be found with /ns:root/ns:qualifiedTag.

But I should be able to access unqualified tags without a prefix and I can't. Why not? How can we fix?

John Black

Posttop
Minollo I.Subject: Re: Accessing tags in the default namespace
Author: Minollo I.
Date: 10 Jan 2004 11:10 AM
Are you talking about running XPath expression in the XML editor module or
from XSLT?

If it is in XML editor module, what you are hitting is a know limitation of
running XPath expressions in that context.
XPath expression in XML editor always assume the default XML namespace.
Your XML document might be overriding the default namespace in different
ways in multiple fragments of the documents; which one our module should
use is tricky to establish unless you use prefixes.

One workaround is to add a namespace declaration associated to the same URI
you are using to override the default namespace and then use it in the
query; for example, if you have:
{root xmlns="http://example.com" xmlns:help="http://example.com"}
{child1/}
{/root}

....you can run a /help:root/help:child1 XPath query without problems.


If instead you are talking about XPath expressions run in the XSLT context,
then you are seeing the specified behavior; according to the specs, XPath
expressions run in XSLT won't use default namespaces modified in the source
XML document; instead, you have to do something pretty similar to what I
mentioned above:
{xsl:template match="/" xmlns:help="http://example.com"}
{xsl:value-of select="/help:root/help:child1"/}
{/xsl:template}


Hope this helps,
Minollo

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.