handling of unresolved grammar in preparsing 2004-04-24 - By Jeff Greif
In preparsing this schema which contains an unresolvable namespace
<schema xmlns:bogus="http://hyperspace/" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/ns"> <complexType name="RootType"> <sequence> <element name="ok" type="string"/> <element name="bad" type="bogus:Random"/> </sequence> </complexType> </schema>
using Xerces 2.2.1 (I know, there is a later, better version), I get behavior that is not what I want when I supply an entity resolver to the preparser. If the entity resolver returns null, a non-null grammar is returned from the preparse, and when I create an XSModel from that grammar, there is an anyType node in place of the type that cannot be resolved. What I want is to have an exception thrown, or better, a null grammar returned. Is there a feature or property that can be set on the preparser to achieve this? If not in 2.2.1, is there such a feature or property in later versions of Xerces?
Note that in xerces 2.2.1, I can get the desired behavior by supplying no entity resolver. In that case, XmlSchemaLoader.resolveDocument() throws a NullPointerException, which would probably be considered a bug, but for me, it 's a feature!
Jeff
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 6.00.2800.1400" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT face=Verdana size=2>In preparsing this schema which contains an unresolvable namespace</FONT></DIV> <DIV><FONT face=Verdana size=2></FONT> </DIV> <DIV><FONT face=Verdana size=2><schema xmlns:bogus="<A href="http://hyperspace/">http://hyperspace/</A>"</FONT></DIV> <DIV><FONT face=Verdana size=2> xmlns="http://www.w3.org/2001/XMLSchema"</FONT></DIV> <DIV><FONT face=Verdana size=2> targetNamespace="http://example.com/ns"></FONT></DIV> <DIV><FONT face=Verdana size=2> <complexType name="RootType"></FONT></DIV> <DIV><FONT face=Verdana size=2> <sequence></FONT></DIV> <DIV><FONT face=Verdana size=2> <element name="ok" type="string"/></FONT></DIV> <DIV><FONT face=Verdana size=2> <element name="bad" type="bogus:Random"/></FONT></DIV> <DIV><FONT face=Verdana size=2> </sequence></FONT></DIV> <DIV><FONT face=Verdana size=2> </complexType></FONT></DIV> <DIV><FONT face=Verdana size=2></schema></FONT></DIV> <DIV><FONT face=Verdana size=2></FONT> </DIV> <DIV><FONT face=Verdana size=2>using Xerces 2.2.1 (I know, there is a later, better version), I get behavior that is not what I want when I supply an entity resolver to the preparser. If the entity resolver returns null, a non -null grammar is returned from the preparse, and when I create an XSModel from that grammar, there is an anyType node in place of the type that cannot be resolved. What I want is to have an exception thrown, or better, a null grammar returned. Is there a feature or property that can be set on the preparser to achieve this? If not in 2.2.1, is there such a feature or property in later versions of Xerces?</FONT></DIV> <DIV><FONT face=Verdana size=2></FONT> </DIV> <DIV><FONT face=Verdana size=2>Note that in xerces 2.2.1, I can get the desired behavior by supplying no entity resolver. In that case, XmlSchemaLoader.resolveDocument() throws a NullPointerException, which would probably be considered a bug, but for me, it's a feature!</FONT></DIV> <DIV><FONT face=Verdana size=2></FONT> </DIV> <DIV><FONT face=Verdana size=2>Jeff</FONT></DIV> <DIV><FONT face=Verdana size=2></FONT> </DIV> <DIV><FONT face=Verdana size=2></FONT> </DIV></BODY></HTML>
|
|