Describe Amara2/XUpdate here.
4Suite implemented the old XUpdate spec as best it could (the spec is pretty full of holes), and so did a lot of other people, as discussed in this article. For Amara 2.x we'd like to tighten up the declared semantics more, which puts us in an odd spot. We could continue to curate the stagnant XUpdate spec, but it would be nice to align with something that's being maintained by a larger community. One obvious candidate is the W3C's XQuery Update Facility 1.0, but it's a non-XML syntax we'd have to parse, and also relies on the very complicated XQuery data model. Another option is the RFC 5261: An XML Patch Operations Framework Utilizing XPath Selectors, but this is a bit less general purpose than XUpdate, and is also at a pretty early stage of incubation. Note: ERH.
Our proposal for XUpdate in Amara 2.x is to stick with the old XUpdate, but to refine it where necessary using input from the W3C and IETF work, and to document these refinements as a hopeful input to a revived XUpdate community. It should be fairly easy to accept the IETF syntax as an input to our XUpdate engine, given its more limited scope.
Other sources of ideas for tightening up XUpdate:
The old XUpdate required the user to properly order the XUpdate commands so that there were no conflicting operations. The XUpdate in Amara 2.x will now do the ordering itself so as to simplify creating an XUpdate document. The updates will be applied in the following order:
First, all xupdate:append, xupdate:update for non-elements, and xupdate:rename operations are applied.
Next, all xupdate:insert-before and xupdate:insert-after operations are applied.
Next, all xupdate:update operations on elements are applied.
Finally, all xupdate:remove operations are applied.
Future Enhancements
xupdate:replace - as defined in XQuery Update for upd:replaceNode and upd:replaceValue
XUpdate DTD
<!-- allowed literal element types -->
<!ENTITY % literal-elements "
">
<!ENTITY % char-instructions "
| xupdate:value-of
| xupdate:text
">
<!ENTITY % instructions "
%char-instructions;
| xupdate:element
| xupdate:attribute
| xupdate:processing-instruction
| xupdate:comment
">
<!ENTITY % commands "
xupdate:insert-before
| xupdate:insert-after
| xupdate:append
| xupdate:update
| xupdate:remove
| xupdate:rename
">
<!ENTITY % char-template "
(#PCDATA
| %char-instructions;)*
">
<!ENTITY % template "
(#PCDATA
| %instructions;
| %literal-elements;)*
">
<!ENTITY % top-level "
(%commands;
| xupdate:variable
| xupdate:if)*
">
<!-- Used for the type of an attribute value that is an
attribute value template that evaluates to a QName. -->
<!ENTITY % qname-avt "CDATA">
<!-- Used for the type of an attribute value that is an
attribute value template that evaluates to a URI reference. -->
<!ENTITY % uri-avt "CDATA">
<!-- Used for the type of an attribute value that is an
attribute value template that evaluates to a NCName. -->
<!ENTITY % ncname-avt "CDATA">
<!-- Used for the type of an attribute value that is a QName; the prefix
gets expanded by the XUpdate processor. -->
<!ENTITY % qname "NMTOKEN">
<!-- Used for the type of an attribute value that is an expression. -->
<!ENTITY % expr "CDATA">
<!ELEMENT xupdate:modifications %top-level;>
<!ATTLIST xupdate:modifications
id ID #IMPLIED
version NMTOKEN #REQUIRED
xmlns:xupdate CDATA #FIXED "http://www.xmldb.org/xupdate"
>
<!ELEMENT xupdate:insert-before %template;>
<!ATTLIST xupdate:insert
select %expr; #REQUIRED
>
<!ELEMENT xupdate:insert-after %template;>
<!ATTLIST xupdate:insert
select %expr; #REQUIRED
>
<!ELEMENT xupdate:append %template;>
<!ATTLIST xupdate:insert
select %expr; #REQUIRED
child %expr; #IMPLIED
>
<!ELEMENT xupdate:element %template;>
<!ATTLIST xupdate:element
name %qname-avt; #REQUIRED
namespace %uri-avt; #IMPLIED
>
<!ELEMENT xupdate:attribute %char-template;>
<!ATTLIST xupdate:attribute
name %qname-avt; #REQUIRED
namespace %uri-avt; #IMPLIED
>
<!ELEMENT xupdate:text (#PCDATA)>
<!ELEMENT xupdate:processing-instruction %char-template;>
<!ATTLIST xupdate:processing-instruction
name %ncname-avt; #REQUIRED
>
<!ELEMENT xupdate:comment %char-template;>
<!ELEMENT xupdate:update %char-template;>
<!ATTLIST xupdate:update
select %expr; #REQUIRED
>
<!ELEMENT xupdate:remove EMPTY>
<!ATTLIST xupdate:remove
select %expr; #REQUIRED
>
<!ELEMENT xupdate:rename %char-template;>
<!ATTLIST xupdate:rename
select %expr; #REQUIRED
>
<!ELEMENT xupdate:variable %char-template;>
<!ATTLIST xupdate:variable
name %qname; #REQUIRED
select %expr; #IMPLIED
>
<!ELEMENT xupdate:value-of EMPTY>
<!ATTLIST xupdate:value-of
select %expr; #REQUIRED
>
<!ELEMENT xupdate:if %top-level;>
<!ATTLIST xupdate:if
test %expr; #REQUIRED
>
Differences from XUpdate WD DTD
Added declaration for %literal-elements;
Added declaration for %char-instructions;
Added declaration for %char-template;
Added declaration for %top-level;
Changed allowed content of xupdate:modifications from %commands; to %top-level;
Changed allowed content of xupdate:insert-before, xupdate:insert-after, and xupdate:append from %instructions; to %template;
Changed allowed content of xupdate:attribute from #PCDATA to %char-template;
Changed allowed content of xupdate:processing-instruction from #PCDATA to %char-template;
Added declaration of xupdate:comment
Changed allowed content of xupdate:update from #PCDATA to %char-template;
Changed allowed content of xupdate:rename from #PCDATA to %char-template;
Changed allowed content of xupdate:variable from #PCDATA to %char-template;
Changed allowed content of xupdate:if from %template; to %top-level;
