canMoveUp, canMoveDown

Hi,

I just saw the DOM Level 3 Validation Specification. This looks very
interesting to me since we at Q42 are building Xopus (xopus.org), a
validating XML editor. During development of this editor we came to a
similar interface:

boolean  canContainNode (parentNode, nodeName, namespaceURI)
boolean  canMoveUp (node)
boolean  canMoveDown (node)
boolean  canDeleteNode (node)
array    getPossibleChildren (node) // Returns both elements and
attributes

Obviously, our interface not as extensive as the proposed specification,
but we do have atomic functions for moving nodes (swapping them with a
sibling). I wondered how the proposed interface would deal with the
following situation:

XML:

<parent>
  <childA/>
  <childB/>
</parent>

Schema:

<xs:element name="parent">
  <xs:complexType>
    <xs:choice minOccurs="2" maxOccurs="2">
      <xs:element name="childA" type="xs:string"/>
      <xs:element name="childB" type="xs:string"/>
    </xs:choice>
  <xs:complexType>
</xs:element>
      
In this example the parent element is valid if and only if it has 2
children. However, it remains valid when its children are swapped. So
canMoveUp(childBNode) is true for the given xml. How could I draw the
same conclusion when using the proposed specification?

Note: both canMoveUp and canMoveDown can easily be implemented when
using a canSwap(firstNode, secondNode) method.

Greetings,

Laurens van den Oever

Received on Friday, 26 July 2002 09:48:08 UTC