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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.