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 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Manikandan SurendranathSubject: XPath query doesnot work if xml has namespace declaration
Author: Manikandan Surendranath
Date: 06 Apr 2005 06:57 AM
I have an xml exported from MS-Excel. I opened it in SS and gave the XPath query "/Workbook/Worksheet/Table" the query resulted with no hits.
However if remove the namespace declaration from the root node, i.e.

<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">

changed to
<Workbook>

The query works. What is the problem here?

Postnext
Alberto MassariSubject: XPath query doesnot work if xml has namespace declaration
Author: Alberto Massari
Date: 06 Apr 2005 07:52 AM
XPath 1.0 does not use default namespaces (see http://www.w3.org/TR/xpath#node-tests,
"A QName in the node test is expanded into an expanded-name using the namespace
declarations from the expression context. This is the same way expansion is
done for element type names in start and end-tags except that the default
namespace declared with xmlns is not used: if the QName does not have a prefix,
then the namespace URI is null"), so writing "/Workbook" will not match
the <Workbook xmlns="..."> element in your XML.
The correct XPath query is "/ss:Workbook/ss:Table....."

Hope this helps,
Alberto

Posttop
Manikandan SurendranathSubject: XPath query doesnot work if xml has namespace declaration
Author: Manikandan Surendranath
Date: 06 Apr 2005 11:50 AM
It works, Thanks.

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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.