W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2004

DOM L3 XPath: effect of mutation after iterator exhausted?

From: Henry Zongaro <zongaro@ca.ibm.com>
Date: Tue, 18 May 2004 16:58:45 -0400
To: www-dom@w3.org
Message-ID: <OF3206EA2C.1810F1DD-ON85256E98.0070D6E4-85256E98.00733DF6@ca.ibm.com>

Hello.

     I was looking at the description of the XPathResult.iterateNext() 
method in the Working Group Note on DOM L3 XPath.[1]  The description of 
that method indicates the following DOMException may be thrown:

  INVALID_STATE_ERR: The document has been mutated since the result was 
returned

Similarly, the description of the invalidIteratorState attribute has this 
to say:

  Signifies that the iterator has become invalid. True if resultType
  is UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE and
  the document has been modified since this result was returned.


     Once the XPathResult.iterateNext() returns the value null, I think it 
would be better if the DOMException no longer had to be thrown on any 
subsequent calls to iterateNext(); similarly, once the iterateNext() 
method returns the value null, I think it be better if 
invalidIteratorState always returned True.

     Here's why:  an obvious mechanism for implementing this sensitivity 
to mutation is for the implementation to register the XPathResult object 
to listen for DOM mutation events.  However, once the iterateNext() method 
returns the last object, it's very unlikely that the XPathResult object 
will continue to be used.  If all such "consumed" XPathResult objects that 
are created have to remain listening for DOM mutation events, just so they 
can set their invalidIteratorState attributes to True, it could prove very 
wasteful.

Thanks,

Henry
[1] 
http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226/xpath.html#XPathResult-iterateNext
[2] 
http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226/xpath.html#XPathResult-invalid-iterator-state

------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com
Received on Tuesday, 18 May 2004 16:59:21 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:57 GMT