[xquery-talk] trying to retrieve element value

Patrick Durusau patrick at durusau.net
Wed Jan 6 11:38:22 PST 2016


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mary,

Try moving the extended predicate to your for statement:

for $mlid in doc("YOUR-File-Name")//article-title[@id="AVD210_art1"]
return $mlid

(untested)

Hope you are having a great day!

Patrick

On 01/06/2016 01:28 PM, Mary McRae wrote:
> Sorry for what is probably a very basic question; I've read through
> a number of XQuery tutorials but haven't been able to come up with
> something that yields the expected results. I have a MarkLogic
> database, which contains a few thousand XML documents. I'm trying
> to return the value of the ML UID (captured in the XML document as
> <system-pub-id>) for a known document identifier <article-title
> id="value">.
> 
> I've tried several variants of the following, but each returns the
> full set of system-pub-ids rather than the one matching the
> specified id value.
> 
> I've tried running through oXygen as well as the MarkLogic console;
> I get the same results (which I suppose is a good thing). I'm
> pretty certain that I'm missing something obvious, and appreciate
> any pointers.
> 
> I started with this: xquery version "1.0-ml"; for $mlid in
> /samhsa-doc//system-pub-id where
> /samhsa-doc//article-title[@id="AVD210_art1"] return $mlid
> 
> but when I got the full list back (some 14,000 items - many of
> which don't have an article-title) I thought I'd try starting at
> the root ...
> 
> XQuery: xquery version "1.0-ml"; for $mlid in /samhsa-doc where
> /samhsa-doc//article-title[@id='AVD210_art1'] return
> $mlid//system-pub-id
> 
> 
> XML: <?xml version="1.0" encoding="UTF-8"?> <samhsa-doc> 
> <doc-meta> <status>Archived</status> 
> <system-pub-id>100001</system-pub-id> <display-mode>Internal and
> External</display-mode> </doc-meta> <doc-content> <samhsapub> 
> <article> <front> <article-meta> <title-group> <article-title
> id="AVD210_art1"> ... </article-title> ...
> 
> 
> Thank you in advance,
> 
> Mary 
> 
> Mary McRae, PMP | XML Strategist / Technical Project Manager |
> mmcrae at iqsolutions.com
> 
> 
> 
> _______________________________________________ talk at x-query.com 
> http://x-query.com/mailman/listinfo/talk
> 

- -- 
Patrick Durusau
patrick at durusau.net
Technical Advisory Board, OASIS (TAB)
OpenDocument Format TC (OASIS), Project Editor ISO/IEC 26300
Co-Editor 13250-5 (Topic Maps)

Another Word For It (blog): http://tm.durusau.net
Homepage: http://www.durusau.net
Twitter: patrickDurusau

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJWjW0tAAoJEFPGsgi3MgycOVoP+wa3Y7OJeD5HNguP1cGjYH4P
sTJSnvuKjSjksxne6bnZSvcDk+NydF2e20nWArC3isy7qh00ubc7M1qrObAM2kk+
trbrads1ZaDMO8CtZCVTLgKkxC0FsM4eU0McifIKO6gyeh2HnHjgwREfUwKiPTa4
HygJFscHJ63X4VOmrRy9KLBYhOK58N8MyYStGcFz0RMsMQgFWyOwKpqzFVGPOFMM
Z6OFuYx73QrvQZjvgG0ZfKBwguoytLL5VIX7wg9L8Xn5sUCRSV0a8aReDZfCtg+w
wmzt/UFDMn34x3Lv84wZ6PoUFmkWGKgZJ6A6nYbYQCKjHzkbPaW38ccTE8uz+mPL
ZxpViZrABgZ9c3weWPxUHO48GvUJMw41xoiuLSLpUdtJ1xtaftXXJIyT6NtlD8mU
lUWRr3QhbLl1/zVbkSq9GQblXp732e3GsWkHW2ti4hlehpn77vk52Q20LhqE6CkG
T/aOHszVRHuChKzrKqehY0HPAXJfRKvxPlloeVA2U4hAH+4ISGGtNdjRHki1ADXR
pdBlywLPWc/DZpJcrwhVJLOxmKPmbmoF2GCRvyP4FEWZrxTKQIw1vGvkCP8Pvce4
fIRxZLkDXgWomuc99BqiUHUOuL7uxouLf+vuVUauGVCwJCGrRarLRRlXxbj1oanq
MJ/Q7xa0NrHdey/QxuPn
=6xE8
-----END PGP SIGNATURE-----


More information about the talk mailing list