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

Re: XPath - accessing nodes with a namespace with no

Subject: Re: XPath - accessing nodes with a namespace with no prefix
From: Philip Vallone <philip.vallone@xxxxxxxxxxx>
Date: Fri, 04 Dec 2009 17:42:23 -0500
Re:  XPath - accessing nodes with a namespace with no
Hi Ken,

Thank you for your help. I should have been more clear. I am not using XSLT,
but rather libxml2 for C.

What I ended up doing was to give the namespace a prefix, but was wondering if
there was another way.


Thanks for your help,


On Dec 4, 2009, at 5:17 PM, G. Ken Holman wrote:

> At 2009-12-04 17:04 -0500, Philip Vallone wrote:
>> This is a pure xpath question.
> Which is frequently asked.
>> Suppose I have a namespace declaration like this:
>> <organizations version="1.0"
>> The namespace does not have a prefix.
> Right, but the element node in the tree has the namespace in the expanded
>> I want to use local-name() to access the nodes
> Why?  That would be improper.  You want to use qualified names representing
expanded names to access the node.
>> but not sure how. For example, how do I access a path like this:
>> /organizations/organization/title[2]/title
> In an XSLT 1 or XSLT 2 stylesheet:
> xmlns:ims="http://www.imsglobal.org/xsd/imscp_v1p1"
> ...
> /ims:organizations/ims:organization/ims:title[2]/ims:title
>> XML:
>>        <organizations version="1.0"
>>                <organization>
>>                        <title>SCORM 2004 4th Edition Manifest Basics
Content Example 1.0</title>
>> ...
> The expanded name in the stylesheet must match the expanded name in the XML
data.  The qualified name in the stylesheet can be different than the
qualified name in the XML data.  The qualified name in the stylesheet cannot
use the default namespace in XSLT 1.
> In XSLT 2 you can use xpath-default-namespace= to support unprefixed names
in XPath, but I've come to the conclusion it isn't helpful when more than one
input namespace is in use.
> I hope this helps.
> . . . . . . . . . . . Ken
> --
> XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19
> Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
> Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
> Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
> Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
> Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
> G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
> Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
> Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread


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.
First Name
Last Name
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.