XQuery explorations

Filed under: Uncategorized. Tags:

I’m playing around with XQuery, and am finding it to be quite powerful. Still getting my head around the FLWR syntax, and what I can do with that, but initial pokings are quite promising. Thanks a LOT to Leif and Jim at Bluestream for guiding me through the first steps. Their XStreamDB is quite a nice XML database, and handles XQuery natively.

Anyway, here’s the query that has evolved from the first early steps. It pokes through the XML database for all documents that contain a <langstring></langstring> element, and returns a set of elements describing some stuff I’ll need to display the item in a search result page.

FOR  IN Root("RepositoryDB:LOM")
WHERE
	MATCH  USING [//*:langstring CONTAINS "biology"]
RETURN
	LET XQuery explorations := /*:lom/*:general/*:title/*:langstring/text()
	LET  := /*:lom/*:general/*:description/*:langstring/text()
	LET  :=/*:lom/*:technical/*:location/text()
	LET  := /*:lom/*:technical/*:format/text()
	LET  := GetDocumentId()
	LET  := /*:lom/*:lifecycle/*:contribute/*:centity/*:vcard/text()
	LET  := /*:lom/*:metametadata/*:contribute/*:centity/*:vcard/text()
RETURN
<lo_result>
  <objectid>{}</objectid>
  <title>{XQuery explorations}</title>
  <description>{}</description>
  <location>{}</location>
  <format>{}</format>
  <contributor>{}</contributor>
  <owner>{}</owner>
</lo_result>

Comments

Leave a Reply