DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10271>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10271

W3C XML Schema validation error when using a DTD in conjunction with 
http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation property





------- Additional Comments From [EMAIL PROTECTED]  2002-06-27 04:28 -------
Sorry about the last post. I submitted before I was ready...
So, here are my test files:

(DOCTYPE_with_SCHEMALOC.dtd)
----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT PhysicalAddress (Street, Suburb, State, PostCode)>
<!ATTLIST PhysicalAddress xmlns:xsi CDATA #IMPLIED
                          xsi:noNamespaceSchemaLocation CDATA #IMPLIED>
<!ELEMENT Street          (Unit, Name)>
<!ELEMENT Name            (#PCDATA)>
<!ATTLIST Name            Type CDATA "Street">
<!ELEMENT Unit            (#PCDATA)>
<!ELEMENT Suburb          (#PCDATA)>
<!ELEMENT State           (#PCDATA)>
<!ELEMENT PostCode        (#PCDATA)>

(INVALID.xsd)
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
        <xs:complexType name="Street_Type">
                <xs:sequence>
                        <xs:element name="Unit" type="xs:integer"/>
                        <xs:element name="Name">
                                <xs:complexType>
                                        <xs:simpleContent>
                                                <xs:extension base="xs:string">
                                                        <xs:attribute name="Type" 
type="xs:string" use="required"/>
                                                </xs:extension>
                                        </xs:simpleContent>
                                </xs:complexType>
                        </xs:element>
                </xs:sequence>
        </xs:complexType>
        <xs:complexType name="PhysicalAddress_Type">
                <xs:sequence>
                        <xs:element name="Street" type="Street_Type"/>
                        <xs:element name="Suburb" type="xs:string"/>
                        <xs:element name="PostCode" type="xs:string"/>
                </xs:sequence>
        </xs:complexType>
        <xs:element name="PhysicalAddress" type="PhysicalAddress_Type"/>
</xs:schema>

(W3C_with_DOCTYPE_with_SCHEMALOC.xml)
-------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE PhysicalAddress SYSTEM "DOCTYPE_with_SCHEMALOC.dtd">
<PhysicalAddress xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="INVALID.xsd">
  <Street>
    <Unit>31</Unit>
    <Name>Pyrmont</Name>
  </Street>
  <Suburb>Pyrmont</Suburb>
  <State>NSW</State>
  <PostCode>2009</PostCode>
</PhysicalAddress>

The idea is that the DTD defaults the attribute Type on the Name element which
is required by the W3C XML Schema. Now I run this through SAX with the following
configuration:

reader.setFeature("http://xml.org/sax/features/validation";, true);
reader.setFeature("http://apache.org/xml/features/validation/schema";, true); 
reader.setFeature("http://apache.org/xml/features/validation/schema-full-checking";,
true);

This will validate correctly and give me an error in the XML document:

"Invalid content starting with element 'State'. The content should match
'((("":Street),("":Suburb)),("":PostCode))'."

which is good because the XML instance is indeed invalid against the schema but
I don't get an error on the missing Type attribute because it's been defaulted
through DTD validation.

The problem occurs when I try to validate the above by setting the schema
location through the
http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation
property instead of as an xsi:noNamespaceSchemaLocation attribute in the
instance. So, this time the instance document look like this:

(W3C_with_DOCTYPE_no_SCHEMALOC.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE PhysicalAddress SYSTEM "DOCTYPE_with_SCHEMALOC.dtd">
<PhysicalAddress>
        <Street>
                <Unit>31</Unit>
                <Name>Pyrmont</Name>
        </Street>
        <Suburb>Pyrmont</Suburb>
        <State>NSW</State>
        <PostCode>2009</PostCode>
</PhysicalAddress>

and my SAX configuration is:

reader.setFeature("http://xml.org/sax/features/validation";, true);
reader.setFeature("http://apache.org/xml/features/validation/schema";, true);  
reader.setFeature("http://apache.org/xml/features/validation/schema-full-checking";,
true);
reader.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";,
"INVALID.xsd");

This should produce the same error as the example above but I don't get any
errors at all and Xerces says the above is valid even though schema validation
should produce an error. It seems validation stops when DTD validation has been
performed and that schema validation isn't performed at all.

Cheers,
/Eddie

All the files are attached

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

Reply via email to