Quantcast

XQuery dump

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

XQuery dump

Paulo F. Sarli
I have a rather large xml file, exported by MSProject 2003, with size 7.153.314 bytes, that starts like this:

<?xml version="1.0"?>

<Project xmlns="http://schemas.microsoft.com/project">
<Name>whatever</Name>
<Title>My Project</Title>
<Company>MyCompany</Company>
<Manager>MyManager</Manager>
.
.
.

Very, well. I created a very simple file that I supply to XQuery, using the following comandline:

java net.sf.saxon.Query a.xqy
These are the file´s contents (the single line below):
 
doc( "ici.xml" )/Project
 
This query returns a blank response. If I change "Project" for "*", the query does what I expect it to do, which is dump the entire xml file. My question is: What am I doing wrong? Please forgive if the answer is too obvious for me to figure out...
 
Paulo
--
A coisa certa dita na hora errada
é pior do que
a coisa errada dita na hora certa...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: XQuery dump

Michael Kay
This gotcha is well-known to XSLT users, though it still catches many newcomers.
 
The Project element is in a namespace. Its full name is {http://schemas.microsoft.com/project}Project. You are trying to match it against the unqualified name "Project" (which expands to {}Project - a name in no namespace). These are different names, so they don't match.
 
You can declare a default namespace in the query:
 
declare default namespace "http://schemas.microsoft.com/project";
 
which should cause the query to work as you expect. Note however that this default namespace will also apply to any elements you try to construct.
 
Michael Kay


From: [hidden email] [mailto:[hidden email]] On Behalf Of Paulo F. Sarli
Sent: 29 September 2005 21:26
To: [hidden email]
Subject: [saxon] XQuery dump

I have a rather large xml file, exported by MSProject 2003, with size 7.153.314 bytes, that starts like this:

<?xml version="1.0"?>

<Project xmlns="http://schemas.microsoft.com/project">
<Name>whatever</Name>
<Title>My Project</Title>
<Company>MyCompany</Company>
<Manager>MyManager</Manager>
.
.
.

Very, well. I created a very simple file that I supply to XQuery, using the following comandline:

java net.sf.saxon.Query a.xqy
These are the file´s contents (the single line below):
 
doc( "ici.xml" )/Project
 
This query returns a blank response. If I change "Project" for "*", the query does what I expect it to do, which is dump the entire xml file. My question is: What am I doing wrong? Please forgive if the answer is too obvious for me to figure out...
 
Paulo
--
A coisa certa dita na hora errada
é pior do que
a coisa errada dita na hora certa...
Loading...