Hi,

On Mon, 22 Sep 2003, Larry Rosenzweig wrote:

> Hello,
> 
> I am having a problem with Xerces C++ 2.3.0 where I am getting back a DOMText node 
> from
> DOMLocator::getErrorNode(), instead of a DOMElement that I was expecting. I need to 
> store all of the
> DOMElement nodes that generate errors when parsing (using a DOMBuilder), so I can 
> refer to them later
> in my application. I am setting up my own error handler, which catches all of the 
> errors as I
> expected, but then when I call getErrorNode() from the DOMLocator object that I get 
> from the DOMError
> object passed into handleError(), it always returns a DOMTEXT node instead of a 
> DOMElement node.


The spec says to return a DOMNode. There is not to much more information
about what should be returned apart from that. For example, if your
invalid element was caused due to the content of the element not matching
the pattern from the datatype, should the text node be returned or the
element node? We may well need to decide on that behaviour. If you do have
the text node you can always get its parent which, if it was the content
of an element, would be that element.

Take a quick look at the test data below:

<base xmlns="http://theborg.org"; 
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
xsi:schemaLocation="http://theborg.org test.xsd"> 
<foo1 />
<foo2 >sdas</foo2>
</base>

<xs:element name="base"  >
  <xs:complexType >
    <xs:sequence >
       <xs:element name="foo1" type="xs:integer" />
       <xs:element name="foo2" type="xs:integer"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>



The foo elements are obviously invalid. In the first the DOMElement itself 
is returned as it is the node available that is invalid. In the second 
example the DOMText is returned as it has failed validation. I agree that 
this behaviour may seem a touch unintuitive. Maybe we should think about a 
consistent policy, or at least thoroughly document the problem.


Gareth


-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to