[xquery-talk] Query the attributes

Mailing Lists Mail daktapaal at gmail.com
Thu May 23 02:19:41 PDT 2013

Just updating...
I tried :



Both worked!

You were right John, I checked the source of HTML .. the name was
getting on to the div element as an attribute.

so it is more like copy-of select as opposed to  value-of select

So i tried


this copied the text node of the name.. So the <div> <name>rerr
</name> </div> now is more  <div> rerr </div> which is what i want...

I guess we couldnt do the same for the attribute nodes as {$college/@id/text()}


On Thu, May 23, 2013 at 10:01 AM, Mailing Lists Mail
<daktapaal at gmail.com> wrote:
> Hi Mike/ JOhn/
> As far as my knowledge went, i did not think anything was wrong as
> calling a child element should be the same as calling attribute for
> practical purposes.
> I will try to reproduce the issue with something smaller. In the
> meantime, I shall try John's suggestion..,
> Thanks both for your replies.
> Dak
> On Thu, May 23, 2013 at 9:53 AM, John Snelson
> <john.snelson at marklogic.com> wrote:
>> On 23/05/13 09:34, Mailing Lists Mail wrote:
>>>   I was trying to query the atribute value using Xquery in MarkLogic and
>>>   no matter what, I dont seem to be printing the value...
>>>   So this is what I do...
>>>   for $college at $position in  $doc//college
>>>      return
>>>           <div>
>>>               {$college/name}
>>>           </div>
>>>          <div>
>>>               {$college/@id}
>>>           </div>
>> In both those cases you're selecting nodes, and the nodes are being added to
>> the result tree. I suspect the browser is displaying the name, as it is an
>> element with text content, but the "id" attribute is added as an attribute,
>> which browsers don't display.
>> In both cases what you really want is probably the string value of those
>> nodes, which you can get be calling the string() function on them.
>> John
>> --
>> John Snelson, Lead Engineer                    http://twitter.com/jpcs
>> MarkLogic Corporation                         http://www.marklogic.com
>> _______________________________________________
>> talk at x-query.com
>> http://x-query.com/mailman/listinfo/talk

More information about the talk mailing list