Re: [bdbxml] Document names....

George Feinberg <[email protected]>
Newsgroups gmane.comp.db.dbxml.general
Message-ID <[email protected]>
> Great - I was trying to figure out how to query for the name but  
> wasn't able
> to figure out the syntax - thanks!
>
> Any reason to use '{ string($a/@time) }' vs. '{ $a/@time/text() }' ??

There's quite a semantic difference between the string() function
and node/text().  The former returns the string value of the node  
(element
or attribute); the latter returns a sequence of all the child text  
nodes of the
node, which is not really what you are looking for, even though it often
works.

George

> Thanks again,
>     Mark
>
>
> On 6/30/05 3:22 PM, "George Feinberg" <[email protected]> wrote:
>
>
>>
>> Mark,
>>
>> An interesting question.
>> What's going on is that when you return constructed nodes,
>> as you are in the second case, they no longer
>> belong to the document from the container.
>> They belong to a constructed document, which has
>> no name.
>>
>> More in context, below...
>>
>>
>>> Howdy,
>>>     I want to know the names of the documents from which I'm getting
>>> results...
>>>     As long as there's no XML markup in my 'return' statement the
>>> name of
>>> the doc can easily be pulled from the Meta Information - however as
>>> soon as
>>> there's markup all of the Mea Info is lost.
>>>
>>> SO - using the perl API I do a:
>>>
>>>                 $container->putDocument($key, $file,  
>>> $update_context);
>>>
>>> & then later:
>>>
>>> for $a in (collection('junit_goto.dbxml')//testsuite)
>>> return
>>>          $a/@time/text()
>>>
>>> I can the fetch the $key of each document from which this value
>>> came via:
>>> $value->asDocument->getMetaData('http://www.sleepycat.com/2002/
>>> dbxml','name'
>>> , $val);
>>>
>>> Groovy!!
>>>
>>> HOWEVER as soon as I put markup in the return statement the 'name'
>>> meta-data
>>> info is lost:
>>>
>>>
>>> for $a in (collection('junit_goto.dbxml')//testsuite)
>>> return
>>> <time>
>>>         { $a/@time/text() }
>>> </time>
>>>
>>> Bummer!  Iterating thru the MetaDataIterator returns nothing.
>>>
>>> So how can I get the key/name of the providing XML doc with markup
>>> in the
>>> 'return' statement????
>>>
>>
>> You can only return one thing, so you have to figure
>> out how to put the name in the constructed information you are
>> returning.
>> First, you may want to use the syntax, "{string($a/@time)}" to get  
>> the
>> attribute value in the query above.
>>
>> You can probably add it as an attribute of your time element -  
>> something
>> like this:
>> for $a in (collection('junit_goto.dbxml')//testsuite)
>> let $name := dbxml:metadata('dbxml:name',$a)
>> return
>> <time docname='{$name}'>
>>          { string($a/@time) }
>> </time>
>>
>> You'll have noticed the way to get the document
>> name in the xquery expression.  Use it as you need.
>>
>> Regards,
>>
>> George
>>
>>
>>>
>>> Thanks!!
>>>     Mark
>>>
>>>
>>
>>
>
>
>
>
> ------------------------------------------
> To remove yourself from this list, send an
> email to [email protected]
>
>



------------------------------------------
To remove yourself from this list, send an
email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.