Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

xml parsing with sax against xsd with error, but no error detected !!???

843834May 5 2008
hi all

I'm intentionality sending and xml with an error in the attribute name, but the parse doesn't detect it

this is the xsd file
<?xml version="1.0" encoding="utf-8" ?>
  <xs:element name="TM_ROOT">
    <xs:annotation>
      <xs:documentation>FID Transaction Message Root</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:attribute name="MessageType" use="required">
        <xs:annotation>
          <xs:documentation>message type send</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:length value="4" />
            <xs:enumeration value="0200" />
            <xs:enumeration value="0400" />
            <xs:enumeration value="0600" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="Process code" use="required">
        <xs:annotation>
          <xs:documentation>process code to be run</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:long">
            <xs:minInclusive value="0" />
            <xs:maxInclusive value="9999999" />
            <xs:totalDigits value="6" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="CommerceNumber" use="required">
        <xs:annotation>
          <xs:documentation>commerce number code</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:decimal">
            <xs:minInclusive value="1" />
            <xs:maxInclusive value="9999999999" />
            <xs:totalDigits value="10" />
            <xs:fractionDigits value="0" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
</xs:schema>
and this is the xml to validate
<?xml version="1.0" encoding="UTF-8"?>
<TM_ROOT MessageType="0200" ProcessCode="100099" CommerceNumber="10125">
	<TM0200100099 IdTerminal="3300100112" TerminalAditNumber="1234">
	</TM0200100099>
</TM_ROOT>
this is the sax configuration
SAXParser parser = new SAXParser();
parser.setErrorHandler(new SIFXMLDefaultHandlerManager());

parser.setFeature("http://xml.org/sax/features/namespaces", true);
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://apache.org/xml/features/validation/schema", true);
parser.setFeature("http://apache.org/xml/features/validation/dynamic", true);
parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
      
parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", getXSDFileURL());
if I change the MessageType for MessageTypeXXX I don't have any error returned

any ideas
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 2 2008
Added on May 5 2008
0 comments
126 views