Hi Gareth,

Do you think you could give me a little guidance into how to go about creating this custom error method?

I have seen some information in the mail archives about setting up an error handler for a XercesDOMParser, but I am using a DOMBuilder to parse my file. I do set my own DOMErrorHandler and override the handleError() call. But that is where I get the DOMLocator that returns the DOMText node that isn't useful to me.

Any help would be appreciated.

Thank you for your help
Larry Rosenzweig


Gareth Reakes wrote:


Hi,




<base xml="http://www.w3.org/XML/1998/namespace"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:noNamespaceSchemaLocation="C:/Test/syntax.xsd">
 <foo1>
   <foo3/>
   <foo2/>
 </foo1>
</base>


<xsd:element name="base">
<xsd:complexType >
<xsd:sequence >
<xsd:element name="foo1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="foo2"/> </xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>



Obviously, foo3 is invalid since it isn't even in the schema. In this case it returns me a DOMText node. When I get the parent of that DOMText node, it returns me a DOMElement that represents foo1, where I was expecting it to return the DOMElement that represented foo3.



I think this comes down to semantics. The way I would view this is that the element that has an error it the first element that is invalid that is declared in the schema.





Is there a way to get the foo3 DOMElement when I get these errors for foo3?



You can do this but it would require a small amount of customisation. You would have to call a custom error method that did not access the current node from the parser, but used the one you passed in. This is not to bad as long as it was only a few errors you wanted different nodes reported for. Give us a shout if you need more info.



Gareth






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



Reply via email to