Hi all, I'm reposting my earlier notes, partly in case anyone missed
them, and partly because I've added some more content to them.

Random Notes and Thoughts on XML Update Langauge
================================================
Tom Bradford - September 27, 2000


This paper represents personal ramblings based on about an hour of
work that I did developing a schema for a minimal XML database query
and update language.  Don't assume that this is what I'm proposing
be our ultimate solution, it's just a bit of research.


What an XML Update Language SHOULD BE:
--------------------------------------

   - A simple, yet powerful query, aggregation,  and update language
     for XML repositories.
   - Implementation agnostic.  We should not define how and where a
     repository stores its data.
   - A framework for querying and building document sets in disparate
     locations.
   - A harness for executing implementation-specific logic.
   - Built on top of existing W3C standards like XPath and XPointer.
   - Open to future extensibility.


What an XML Update Language SHOULD NOT BE:
------------------------------------------

   - A swiss-army knife that tries to be everything to everyone.
   - A transformation language like XSLT (been done).
   - A document-centric query language like XQL or XPath (been done).
   - Designed specifically favoring a vendor's current implementation.
     (Unless that implementation meets every proposed requirement)
   - Designed dependant on a XML object or parser model (DOM, SAX).


XML Update Language Implementations MUST:
-----------------------------------------

   - Provide a minimal set of standardized base logic as determined by
     the XML:DB initiative.  This logic includes string, math, and
     date manipulation routines.


Schema Elements:
----------------

query:
   query is the top level element of any XML query.  A query must
   contain one element, logic, or xml tag to be considered valid,
   except for a delete operation.

param:
   param defines a query parameter.  Query parameters can be
   considered macros in query execution.  A param can either be
   defined as a static value or as a required provided value from
   the querying interface.

element:
   element defines an output element.  Elements are typically
   aggregated from data sources in the XML repository.  An element can
   also nest other elements, attributes (for that specific element),
   logic and pass through xml.

attribute:
   attributes add attribute information to an element tag.  These
   attribute values can be static, or they can be aggregated from data
   sources in the XML repository.

logic:
   logic provides base or implementation specific logic.  The type of
   logic that is performed is based on the logic class that is
   provided.  A class matching "http://xmldb.org/logic"; represents
   base XML Update logic.

xml:
   xml allows well-formed, static XML data to be embedded into the
   output.

update:
   update performs an update against the query output as that data
   that will be updated.  The target defines where in the document set
   that the update should occur.

delete:
   delete performs a delete against the specified target, potentially
   using the query output as the constraining data in performing the
   delete.

insert:
   insert performs an insert operation against the specified target,
   using the query output as the data to be inserted.

where:
   where narrows document sets for the query operation that will be
   performed.  The document sets can be either source or target
   document sets.  Operations in the where section are implicitly
   ANDed.

match:
   match narrows the document set based on the validity of the
   provided XPath expression.

or, not:
   Are all logical operators used in performing match operations. The
   'and' operator is implicit.

exists:
   Checks that the specified target node exists.


Given my current schema:
------------------------

<query>
   <element name="output"
            source="local/cart/addresses"
            xpath="/address" />
   <where>
      <match source="local/cart/addresses"
             xpath="/[EMAIL PROTECTED]'Tom Bradford'" />
      <not>
         <match source="local/cart/addresses"
                xpath="/[EMAIL PROTECTED]'vacation']" />
      </not>
   </where>
</query>


This query retrieves all address elements in the addresses collection
(dbXML) where the name attribute on the address is 'Tom Bradford' :),
and the type attribute on the address is NOT 'vacation'.  The name
match could have been performed in the element XPath as well, but for
consistency, I included it in the where section.  Also...  The target
attributes in the where section are optional if only one source is
being queried from.


Output might be:
----------------

<output>
   <address name="Tom Bradford" type="home">
      <address1>1234 West Black Road</address1>
      <city>Mesa</city>
      <state>AZ</state>
      <postal>85205</postal>
   </address>
   <address name="Tom Bradford" type="work">
      <address1>6900 East Camelback Road</address1>
      <address2>Suite 700</address2>
      <city>Scottsdale</city>
      <state>AZ</state>
      <postal>85251</postal>
   </address>
</output>


An insertion example:
---------------------

<query>
   <element source="local/cart/addresses"
            xpath="/address"
            replace="true" />
   <where>
      <!-- element source is the default -->
      <match xpath="/[EMAIL PROTECTED]'Tom Bradford'" />
      <match xpath="/[EMAIL PROTECTED]'work'" />
      <!-- this one narrows the target set -->
      <match target="local/cart/orders"
             xpath="/[EMAIL PROTECTED]'12345']" />
   </where>
   <insert target="local/cart/orders"
           xpath="/order/shipto" />
</query>


And yet another:
----------------

<query>
   <xml>
      <order id="12345">
         <!-- blah blah blah -->
      </order>
   </xml>
   <insert target="local/cart/orders" />
</query>



We'll probably have to provide a facility so that the same document
set can be used as a source and a target using an aliasing system.
An alternative to this would be to allow the match element to support
either a source attribute or a target attribute to determine whether
the document set is a target or not.


A deletion example:
-------------------

<query>
   <where>
      <match target="local/cart/orders"
             xpath="/order/shipto/[EMAIL PROTECTED]'home']" />
   </where>
   <delete target="local/cart/orders"
           xpath="/order/shipto/address" />
</query>
<?xml version ="1.0"?>
<!--Generated by XML Authority. Conforms to w3c http://www.w3.org/1999/XMLSchema-->
<schema xmlns = "http://www.w3.org/1999/XMLSchema";>
	<element name = "query">
		<complexType content = "elementOnly">
			<sequence>
				<element ref = "param" minOccurs = "0" maxOccurs = "unbounded"/>
				<choice minOccurs = "0" maxOccurs = "1">
					<element ref = "element"/>
					<element ref = "logic"/>
					<element ref = "xml"/>
				</choice>
				<element ref = "where" minOccurs = "0" maxOccurs = "1"/>
				<choice minOccurs = "0" maxOccurs = "1">
					<element ref = "update"/>
					<element ref = "insert"/>
					<element ref = "delete"/>
				</choice>
			</sequence>
		</complexType>
	</element>
	
	<element name = "update">
		<complexType content = "empty">
			<attribute name = "xpath" type = "string"/>
			<attribute name = "target" type = "string"/>
			<attribute name = "validate" use = "default" value = "true" type = "boolean"/>
		</complexType>
	</element>
	
	<element name = "insert">
		<complexType content = "empty">
			<attribute name = "xpath" type = "string"/>
			<attribute name = "target" type = "string"/>
			<attribute name = "validate" use = "default" value = "true" type = "boolean"/>
		</complexType>
	</element>
	
	<element name = "delete">
		<complexType content = "empty">
			<attribute name = "xpath" type = "string"/>
			<attribute name = "target" type = "string"/>
			<attribute name = "validate" use = "default" value = "true" type = "boolean"/>
		</complexType>
	</element>
	
	<element name = "element">
		<complexType content = "elementOnly">
			<choice minOccurs = "0" maxOccurs = "unbounded">
				<element ref = "attribute"/>
				<element ref = "element"/>
				<element ref = "logic"/>
				<element ref = "xml"/>
			</choice>
			<attribute name = "xpath" type = "string"/>
			<attribute name = "name" type = "string"/>
			<attribute name = "recursive" use = "default" value = "true" type = "boolean"/>
			<attribute name = "source" use = "required" type = "string"/>
			<attribute name = "replace" use = "default" value = "false" type = "boolean"/>
		</complexType>
	</element>
	
	<element name = "attribute">
		<complexType content = "empty">
			<attribute name = "xpath" type = "string"/>
			<attribute name = "name" type = "string"/>
		</complexType>
	</element>
	
	<element name = "param">
		<complexType content = "empty">
			<attribute name = "name" type = "string"/>
			<attribute name = "value" type = "string"/>
		</complexType>
	</element>
	
	<element name = "logic">
		<complexType content = "textOnly">
			<attribute name = "name" type = "string"/>
			<attribute name = "source" use = "required" type = "string"/>
			<attribute name = "replace" use = "default" value = "false" type = "boolean"/>
			<attribute name = "class" use = "default" value = "http://xmldb.org/logic"; type = "string"/>
		</complexType>
	</element>
	
	<element name = "xml">
		<complexType content = "textOnly">
			<attribute name = "name" type = "string"/>
			<attribute name = "replace" use = "default" value = "false" type = "boolean"/>
		</complexType>
	</element>
	
	<element name = "match">
		<complexType content = "empty">
			<attribute name = "xpath" type = "string"/>
			<attribute name = "target" type = "string"/>
			<attribute name = "source" use = "required" type = "string"/>
		</complexType>
	</element>
	
	<element name = "or">
		<complexType content = "elementOnly">
			<choice minOccurs = "0" maxOccurs = "unbounded">
				<element ref = "match"/>
				<element ref = "or"/>
				<element ref = "not"/>
				<element ref = "exists"/>
			</choice>
		</complexType>
	</element>
	
	<element name = "not">
		<complexType content = "elementOnly">
			<choice minOccurs = "0" maxOccurs = "unbounded">
				<element ref = "match"/>
				<element ref = "or"/>
				<element ref = "not"/>
				<element ref = "exists"/>
			</choice>
		</complexType>
	</element>
	
	<element name = "exists">
		<complexType content = "empty">
			<attribute name = "xpath" type = "string"/>
			<attribute name = "target" type = "string"/>
		</complexType>
	</element>
	
	<element name = "where">
		<complexType content = "elementOnly">
			<choice minOccurs = "0" maxOccurs = "unbounded">
				<element ref = "match"/>
				<element ref = "or"/>
				<element ref = "not"/>
				<element ref = "exists"/>
			</choice>
		</complexType>
	</element>
	
</schema>
begin:vcard 
n:Bradford;Tom
tel;fax:(480) 947-2280
tel;work:(480) 421-1233
x-mozilla-html:FALSE
url:http://www.dbxmlgroup.com/bradford.html
org:<b>The dbXML Group, L.L.C.</b>;<a href="http://www.dbxmlgroup.com/";><img src="http://www.dbxmlgroup.com/images/dbxmllogo.gif"; border="0"></a>
version:2.1
email;internet:[EMAIL PROTECTED]
title:Chief Software Architect
adr;quoted-printable:;;6900 East Camelback Road=0D=0ASuite 700;Scottsdale;AZ;85251;USA
x-mozilla-cpt:;5184
fn:Tom Bradford
end:vcard

Reply via email to