For my SAX Parser class that implements the DefaultHandler, it was noticed that the attribute validation happens while the startElement points to its parent element.
XML File snippet:
<featureRules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FSORulesSchema.xsd">
<featureSet marketCode="" modelYear="2004" featureCode="" >
<rule id="4895" operationType="A">
<featureValue>Yes</featureValue>
<startDate>1967-08-13</startDate>
XSL File Snippet :
<xs:element name="featureRules">
<xs:complexType>
<xs:sequence>
<xs:element ref="featureSet" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="featureSet">
<xs:complexType>
<xs:sequence>
<xs:element ref="rule" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="marketCode" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="NA"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="modelYear" type="xs:short" use="required"/>
<xs:attribute name="featureCode" type="xs:string" use="required"/>
Console Output :
(note : Element name is printed from error() of ErrorHandler. remaining is printed in the startElement() )
Start Local Name : featureRules
Attribute name : xsi:noNamespaceSchemaLocation
Attribute value : FSORulesSchema.xsd
Element name : featureRules
cvc-enumeration-valid: Value '' is not facet-valid with respect to enumeration '[NA]'. It must be a value from the enumeration.
Element name : featureRules
cvc-attribute.3: The value '' of attribute 'marketCode' on element 'featureSet' is not valid with respect to its type, 'null'.
Start Local Name : featureSet
Attribute name : marketCode
Attribute value :
Attribute name : modelYear
Attribute value : 2004
Attribute name : featureCode
Attribute value :
Thanks,
Aneesh