From: Michael B. <mbe...@mb...> - 2005-10-22 15:08:57
|
Ok, I'm sure you'll crack it. And you won't have to change any of your documents, you just have to make a small preliminary addition to your queries. I deliberately didn't show you an example that would get a quick result (though maybe other list members will do so) because there's a Big Problem with namespaces for people who want to grasp XML. Show a working example without a lot of additional explanation, and it's bound to be seriously misleading, because under the wraps, namespaces just don't work like they seem to on the surface. But anyone who takes the other approach of explaining first issues like: The distinction between being in no namespace and in the default namespace The namespace scoping of attributes (which is entangled with the previous point) The arbitrary character of the prefix and the processor's sole reliance on the id to which the prefix is bound etc etc and the understandable response is "stop yacking on about theory and show me how to do it". But one small pointer to focus your home-study reading... Where a document has placed the element you want to query in a default namespace, you need in your query to bind the *identifier* uri for that namespace to a prefix of your choice (any legal string will do) and use that prefix in your query. Or, there's XQuery syntax for declaring a default namespace in an XQuery, but the declaration has to be there up front, and it must bind to the same identifier as the targetted default namespace in the document does. Where the document has placed the element you are targetting in a prefixed namespace, you equally need to bind a prefix (yes "a" prefix, any one you want that's legal, it doesn't need to be the same one used in the document) to the identifier to which the prefix in the document is bound. Look at the "mods" database in the eXist example materials to see queries that do this. Michael Beddow |