Yesterday, I threw together some ideas for a quick and dirty extension
of the XUpdate language that would provide support for relational
queries against multiple collections. It would be a easy to use,
relatively easy to implement alternative to XQuery, which becomes more
of a monstrosity every time I look at it.
Like I said, I threw it together quickly, so it's nowhere close to
usable. I'd very much like feedback for refining it more.
The file XSelect.txt is attached.
Thanks,
Tom
--
Tom Bradford The dbXML Group, L.L.C. http://www.dbxmlgroup.com/
Desktop, Laptop, Settop, Palmtop. Can your XML database do that?
XSelect is a selection extension for the XUpdate language. It
can be used to either pre-select a set of nodes to be processed,
or to retrieve natural and synthetic nodelists.
Namespaces: xupdate=http://www.xmldb.org/XUpdate
dbxml=http://www.dbxml.org/Query
Element: xupdate:select
Selection container
Contains: (parameter|variable|namespace)*,nodelist?
Element: xupdate:variable
Variable definition. Value is immutable within scope, but can
be shadowed by redefinition in nested scope.
Attributes: name - The variable name
dbxml:col - (Optional) collection name
select - (Optional) XPath value selector
Text Value: (Optional) the variable value
Element: xupdate:parameter
Same scoping rules as a variable, but the value *must* be
provided by an external context. Allows for the storage and
execution of parameterized queries. Also, a parameter
element can only be inserted as an immediate child of a
select element.
Attributes: name - The variable name
Element: xupdate:namespace
Defines a namespace, and optionally associates it with
a prefix.
Attributes: prefix - (Optional) namespace prefix
uri - Namespace URI
Element: xupdate:nodelist
Defines the nodelist that will be returned from this
selection container.
Attributes: dbxml:col - (Optional) collection name
select - (Optional) XPath value selector
// Nodelist Filters
attributes - Whether to include attributes (yes)
elements - Whether to include elements
comments - whether to include comments
text - Whether to include text
pi - Whether to include processor instructions
children - Whether to include any children
(This does not include attributes)
Contains: (variable|namespace|nodelist|element|comment)*
Element: xupdate:foreach
Processes (links) a set of nodes based on an optional
action.
Attributes: select - (Optional) XPath node selector
action - (Optional) The action to take
(replace|append|insert|content)
Contains: (variable|namespace|nodelist|element|comment)*
Example:
<x:select xmlns:x="http://www.xmldb.org/XUpdate"
xmlns:d="http://www.dbxml.org/Query">
<x:parameter name="id">12345</x:parameter>
<x:nodelist d:col="/db/invoices"
select="/[EMAIL PROTECTED]">
<x:foreach select="products/product" action="replace">
<x:variable name="id"
select="@id"/>
<x:nodelist d:col="/db/products"
select="/[EMAIL PROTECTED]" />
</x:foreach>
</x:nodelist>
</x:select>