On Mon, 2013-05-13 at 19:15 -0600, James Wright wrote:
[...] I know the xml standard defines id and idref however I have not been able to find any documentation on these in BaseX or XML in general. For example does BaseX handle idiosyncrasies of id and idref or must I handle these in my queries? For example: let $context := <item id="10">
Note that an XML ID must be an identifier, so must start with a name start character (a letter)...
let $context := <item id="10"> <child idref="2" /><item><item id="20"> <child idref="2" /> <child idref="1" /></item><item id="30" /> <child id="1" name="firstChild" /><child id="2" name="secondChild" /> for $itemWithFirstChild in $context/item[child/@name = 'firstChild']return $itemWithFirstChild/@id
I think this got garbled somewhere - e.g. there aren't enough end tags. Make sure you turn off HTML formatting in your email program.
I would like this to return "10 20"Now this example uses a dynamic context node however in the application these would exist as nodes in the database... If it does fully support this how do I enable it or get it to work?
One way to get started with BaseX would be to use the "basexgui" program in the bin directory to create a database (there's also a command-line program to do it; I use the Perl and PHP APIs too on www.fromoldbooks.org).
People usually do joins by value in XML and XQuery; ID/IDREF only work with older DTD technology, or with xml:id; I don't know if BaseX has support for them. But if it does the values must be IDs :)
So you're on the right lines.
Also what about XLink?
It's not used very much. As a standard it solved the wrong problems, unfortunately. Easy for me to say in hindsight.
The XQuery Use Cases on www.w3.org/TR may be helpful; there's also a chapter on XQuery using BaseX for examples in a book I co-authored last year, "Beginning XML" 5th edition.
Liam