Bugs item #1872806, was opened at 2008-01-16 15:27
Message generated for change (Comment added) made by yingying
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=1872806&group_id=56967

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: PF/runtime
Group: Pathfinder CVS Head
Status: Closed
Resolution: Invalid
Priority: 5
Private: No
Submitted By: Ying Zhang (yingying)
Assigned to: Wouter Alink (vzzzbx)
Summary: PF: weird results of fn:id()

Initial Comment:
Querying fn:id() on my own xml document returns weird results.

The query doc("http://homepages.cwi.nl/~zhang/sheep.xml";)/id("s1") returns 
empty result (there do exist a node with id "s1"), while the query 
doc("http://homepages.cwi.nl/~zhang/sheep.xml";)/id("001") returns the whole 
document.

However, the query doc("http://www.functx.com/input/book.xml";)/id("preface") 
returns correct result.

Maybe my document is incorrect?

Below is a copy of my query session.  I'm using the current brach, recompiled 
this morning, but I got the same behaviour with the stable version.


Regards,

Jennie

==============
$ mclient -lx
xquery>doc("http://homepages.cwi.nl/~zhang/sheep.xml";)/id("s1")
more><>

xquery>doc("http://homepages.cwi.nl/~zhang/sheep.xml";)/id("001")
more><>
<?xml version="1.0" encoding="utf-8"?>
<sheepdb>
  <sheep id="s1">
    <name>Baby Sheep</name>
    <price>100</price>
    <stock>98</stock>
    <picture>pictures/BabySheep.jpg</picture>
    <description>
      My favourite sheep with extreme high cuddle factor
    </description>
  </sheep>
  <sheep id="s2">
    <name>Lost Sheep</name>
    <price>1234</price>
    <stock>50</stock>
    <picture>pictures/DSC01689.jpg</picture>
    <description>
      Oops, wrong site ;-)
    </description>
  </sheep>
  <sheep id="001">
    <name>Baby Sheep</name>
    <price>100</price>
    <stock>98</stock>
    <picture>pictures/BabySheep.jpg</picture>
    <description>
      My favourite sheep with extreme high cuddle factor
    </description>
  </sheep>
  <sheep id="002">
    <name>Lost Sheep</name>
    <price>1234</price>
    <stock>50</stock>
    <picture>pictures/DSC01689.jpg</picture>
    <description>
      Oops, wrong site ;-)
    </description>
  </sheep>
</sheepdb>

xquery>doc("http://www.functx.com/input/book.xml";)/id("preface")
more><>
<section id="preface">This book introduces XQuery...
    The examples are downloadable<fnref ref="fn1"/>...
  </section>
xquery>


----------------------------------------------------------------------

>Comment By: Ying Zhang (yingying)
Date: 2008-01-17 11:07

Message:
Logged In: YES 
user_id=341633
Originator: YES

Hi Stefan en Wouter,  thanks a lot for your explaination!

I also had the impression that the number "001" was treated as a NID, but
could not understand why the third query does return the expected node,
while the document seems similar with my document.  The problem is that I
opened book.xml in firefox and it didn't tell me that the document has a
DTD!

----------------------------------------------------------------------

Comment By: Stefan Manegold (stmane)
Date: 2008-01-16 23:10

Message:
Logged In: YES 
user_id=572415
Originator: NO

The third query (correctly) returns the expected result as the respective
document does have a(n inlined) DTD.

Hence, given the documents, all three queries work as expected and
correctly.


----------------------------------------------------------------------

Comment By: Wouter Alink (vzzzbx)
Date: 2008-01-16 22:37

Message:
Logged In: YES 
user_id=621590
Originator: NO

p.s. i cannot explain why the third query did return a result. i would
have expected an empty result.

----------------------------------------------------------------------

Comment By: Wouter Alink (vzzzbx)
Date: 2008-01-16 22:33

Message:
Logged In: YES 
user_id=621590
Originator: NO

hello jenny,

the results seem to me to be completely as one would expected. 

The 'id(xs:string)' function is not per definition tied to a 'id'
attribute. normally you have to specify in a dtd or xmlschema which
attribute name denotes a 'id' or 'idref' relation. MonetDB had (at least a
while back) a compile-time option in the shredder denoting all id-attribute
nodes to be 'id's. 

Therefore your first query doesn't give you a result.

The second query has another problem. Your query is malformed. 'id's may
never start with a digit. However, this fact has been misused in monetdb.
monetdb _does_ allow the parameter given to the "id(xs:string)" function to
start with a digit. When it detects the first character of the string to be
a digit, it will try to convert the value to a number, and will return the
node with the corresponding 'nid' value (an internal numbering scheme of
monetdb's xml representation).

Therefore your second query will return the document root of the first
document in your query. (When you would have queried id("0"), you probably
would have gotten the whole collection) This feature is specific to
monetdb. "pf:nid() as xs:string" is the inverse function.  for example:
'pf:nid(doc("x.xml")/id("1"))' should return 1

i hope this helps (and that i explained it correctly :)

p.s. as i am not a developer i cant change the status of this bugreport.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=1872806&group_id=56967

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-bugs

Reply via email to