sharpener pencil

A look at Widex Requirements

Dave Raggett <dsr@w3.org>

wispy clouds in a blue sky

Widex F2F, 65th IETF, Dallas
23 March 2006

A look at Widex Requirements

Drilling down on the requirements

Remote Events for XML (REX)

Remote Events for XML (REX)

REX examples

Setting an attribute

<rex xmlns='http://www.w3.org/2006/rex'>
  <event target='id("spot")/@fetch'
   name='DOMAttrModified' newValue='ball'/>
</rex>

REX examples

Inserting an element

<rex xmlns='http://www.w3.org/2006/rex'>
  <event target='/html/body/table[2]'
   name='DOMNodeInserted' position='7'>
    <tr xmlns='http://www.w3.org/1999/xhtml'>
      <td>Rover</td>
      <td>Alpine Labrador</td>
      <td class='food'>bone</td>
    </tr>
  </event>
</rex>

Inserts new row at position 7 in 2nd table. Element previously at position 7 will now be at position 8.

REX examples

Removing several elements

<rex xmlns='http://www.w3.org/2006/rex'>
  <event target='/svg/circle[@class="poodle-stylist-location"]'
   name='DOMNodeRemoved'/>
</rex>

REX examples

Replacing an element

<rex xmlns='http://www.w3.org/2006/rex'>
  <event target='id("femur")'
   name='DOMNodeRemoved'>
    <bone xmlns='http://example.org/BoneML'
     xml:id='tibia'>
      <taste>good</taste>
      <smell>excellent</smell>
      <solidity>medium</solidity>
      <availability>common</availability>
    </bone>
  </event>
</rex>

REX examples

Updating character data directly

<rex xmlns='http://www.w3.org/2006/rex'>
  <event target='/svg:svg/svg:g[2]/svg:tspan[7]/text()'
   name='DOMCharacterDataModified' newValue='Hello World!'/>
</rex>

REX examples

Replacing an entire document

<rex xmlns='http://www.w3.org/2006/rex'>
  <event target='/' name='DOMNodeRemoved'>
    <svg xmlns='http://www.w3.org/2000/svg'
     viewBox='0 0 300 400'>
      <defs>
        <!-- ... --->
      </defs>
      <g>
        <rect x='42' y='27' width='100' height='200' fill='red'/>
        <!-- ... --->
      </g>
    </svg>
  </event>
</rex>

REX Processing Model

Note that REX doesn't provide a means to extract nodes from one part of the tree and copy them to another, but this could be a future extension.

XUpdate

XUpdate examples

Given

 <addresses version="1.0"> 
   <address id="1"> 
     <fullname>Andreas Laux</fullname> 
     <born day='1' month='12' year='1978'/> 
     <town>Leipzig</town> 
     <country>Germany</country> 
   </address> 
 </addresses>

This will insert a new address element after the first:

 <xupdate:modifications version="1.0"
          xmlns:xupdate="http://www.xmldb.org/xupdate"> 
   <xupdate:insert-after select="/addresses/address[1]" > 
     <xupdate:element name="address">
       <xupdate:attribute name="id">2</xupdate:attribute>
       <fullname>Lars Martin</fullname> 
       <born day='2' month='12' year='1974'/> 
       <town>Leizig</town> 
       <country>Germany</country> 
     </xupdate:element> 
   </xupdate:insert-after> 
 </xupdate:modifications> 

XUpdate and the use of variables

Named variables can used as macros for path expressions:

 <xupdate:modifications version="1.0"
          xmlns:xupdate="http://www.xmldb.org/xupdate"> 

   <!-- pick out name of town from first address -->
   <xupdate:variable name="town"
          select="/addresses/address[0]/town"/>
 
   <!-- and append new address with that town -->
   <xupdate:append select="/addresses"> 
     <xupdate:element name="address"> 
       <xupdate:value-of select="$town"/> 
     </xupdate:element> 
   </xupdate:append> 
 </xupdate:modifications> 

In principle, REX could use value-of for copying sub-trees.

XML Patch

Example:

<p:diff xmlns="urn:ietf:params:xml:ns:xxx"
        xmlns:y="urn:ietf:params:xml:ns:yyy"
        xmlns:p="urn:ietf:params:xml:ns:diff">
   <p:add sel="doc/elem[@a='foo']">
     <child id="ert4773">
       <y:node/>
     </child>
   </p:add>
   <p:replace sel="doc/note/text()">Patched doc</p:replace>
   <p:remove sel="*/elem[@a='bar']/y:child" ws="both"/>
   <p:add sel="*/elem[@a='bar']" type="@b">new attr</p:add>
</p:diff>

Widex requirements for remote updates

For DOM Updates, the following points seem appropriate:

Widex requirements for remote updates

Widex requirements for remote events

Widex requirements for remote events

Widex requirements for remote events

Widex requirements for remote events

Other kinds of updates

Some User Interface updates go beyond updating the markup:

These can be set via events sent from the Widex server to the Widex renderer.

Should these events be part of the Widex specification or left to the application layer?

Suggestions for next steps

Extending REX with value-of

Wrapping an existing element with another

<rex:rex xmlns:rex='http://www.w3.org/2006/rex'>
  <event target='id("femur")' name='DOMNodeRemoved'>
    <leg>
      <rex:value-of select='.'/>
    </leg>
  </rex:event>
</rex:rex>