Would this work

$someDoc//@*/text()

--- Original Message ---

From: "buzz chopra" <buzz.chopra@gmail.com>
Sent: November 2, 2013 11:38 PM
To: "Dirk Kirsten" <dk@basex.org>
Cc: "BaseX" <basex-talk@mailman.uni-konstanz.de>
Subject: Re: [basex-talk] xquery and hash:md5

Hello Dirk,

Yes in that case, the issue exists in the nature of our data - and my poor choice of the return value of fn:string as the content to hash.

Our data looks like:

<test guid="blah">
<e1 attr0="a" attr1="b"/>
<e2 attr0="c" attr1="d" attr2="e"/>
</test>

As you state, fn:string behaves the way http://www.w3.org/TR/xpath-functions-30/#func-string says it should. i.e. the empty string is returned for the document above. 

I'll have to try and find something that returns all attribute values in each document.

Thanks again for your help.

Buzz





On Fri, Nov 1, 2013 at 10:37 AM, Dirk Kirsten <dk@basex.org> wrote:
Hello Buzz,

The result of string() depends on the kind of element as an input. For
an attribute value it will simply be the value of the attribute. For an
element node it will be a concatination of the node content and all
descendant nodes. So if string($r) for $r being an element node is
always empty I would guess it is an empty node (something like <reps
/>), which will always yield an empty result.

If you want to create different hashs for empty elements with different
attribute values you might want to do something like the following

let $reps := fn:collection($coll)//reps
for $r at $lcv in $reps
let $l := string-join($r/@*, '')
let $hash := xs:hexBinary(hash:md5(fn:string($l)))
return <hash i="{$lcv}">{$hash}</hash>

If this is not what you actually want to achieve it would be very
helpful to actually get a small example of your data (especiall the reps
nodes) to get an idea how it looks like.

Cheers,
Dirk

On 01/11/13 16:19, buzz chopra wrote:
> Dirk,
>
> Thank you for your quick response.
>
> Upon your suggestion (and prior to that) I checked that the values for $r
> are different. Indeed they are. But, what I didn't check until your
> suggestion is that the values of fn:string($r) are different. They in fact
> are the same - thank you for your suggestion.
>
> Is it possible that there is some sort of type casting related issue going
> on where I call fn:string($r)?
>
> I get different values for the hash of each attribute value when I select
> attributes in the collection like:
>
>   let $reps := fn:collection($coll)//reps/@att0
>   for $r at $lcv in $reps
>   let $hash := xs:hexBinary(hash:md5(fn:string($r)))
>   return <hash i="{$lcv}">{$hash}</hash>
>
>
> when I select elements in the collection like:
>
>   let $reps := fn:collection($coll)//reps
>   for $r at $lcv in $reps
>   let $hash := xs:hexBinary(hash:md5(fn:string($r)))
>   return <hash i="{$lcv}">{$hash}</hash>
>
> I found that the value of fn:string($r) is blank for all values of $r
> (which are different) which is why the hash is the same.
>
> I appreciate your help.
>
> Buzz
>
>
> On Fri, Nov 1, 2013 at 2:52 AM, Dirk Kirsten <dk@basex.org> wrote:
>
>> Hello buzz,
>>
>> it is ok to also ask more general XQuery questions on this list.
>>
>> For testing I executed the following query:
>>
>> for $r in ("123", "234", "345")
>> let $hash := xs:hexBinary(hash:md5(fn:string($r)))
>> return $hash
>>
>> which yields different results for each value of $r. Are you absolutely
>> sure you have different values for $r (you can check using trace())?
>> Also, given they query I would be very suprised if indeed it shows the
>> same result.
>>
>> Cheers,
>> Dirk
>>
>> On 01/11/13 08:24, buzz chopra wrote:
>>> This may be a question better suited for an xquery forum but I'll start
>>> here since I'm using basex:
>>>
>>> Can someone suggest why I'd be getting the same result for the hash call
>>> even though
>>> the content of $r should be changing?
>>>
>>>   let $reps := fn:collection($coll)/Rep
>>>   for $r at $lcv in $reps
>>>     let $hash := xs:hexBinary(hash:md5(fn:string($r)))
>>>     return <hash i="{$lcv}">{$hash}</hash>
>>> };
>>>
>>> Please let me know if I should post this elsewhere (and please include
>>> where).
>>>
>>> Thanks in advance for any suggestions.
>>>
>>> Buzz
>>>
>>>
>>>
>>> _______________________________________________
>>> BaseX-Talk mailing list
>>> BaseX-Talk@mailman.uni-konstanz.de
>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>>>
>>
>> --
>> Dirk Kirsten, BaseX GmbH, http://basex.org
>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
>> |   Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
>> `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
>> _______________________________________________
>> BaseX-Talk mailing list
>> BaseX-Talk@mailman.uni-konstanz.de
>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>>
>

--
Dirk Kirsten, BaseX GmbH, http://basex.org
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
|   Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22