Hi, Dak:

Your XPath expression is copying the id attribute itself (not its value), so 
XQuery is adding the attribute to the div element.

If you want to copy the value of the id attribute as the text of the div 
element, you can use an expression like:

       <div>{$college/@id/string(.)}</div>

If $college is not empty and $college contains an element with an id attribute, 
the XPath expression will get its value.


Hoping that helps,


Erik Hennum

________________________________________
From: [email protected] 
[[email protected]] on behalf of Mailing Lists Mail 
[[email protected]]
Sent: Thursday, May 23, 2013 1:31 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Querying attributes

Dear All,
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>

This is interesting as the first div is prints the name of the
college... the second is empty..  if I change the xpath to:
 <div>
            {$college/@*[1]/name()}
        </div>
 this does print the text "id"  , which is correct.

so I tried

 <div>
            {$college/@*[1] }
        </div>

I thought that this should print the value in the attribute id, which
is also the first attribute...

There is probably something very basic, I am missing... So please help!

Thanks
--Dak
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to