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=10926>.
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=10926

Erroneous SAX events (attribute values) in invalid XML instances.

           Summary: Erroneous SAX events (attribute values) in invalid XML
                    instances.
           Product: Xerces2-J
           Version: 2.0.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: SAX
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


SUMMARY :

In Xerces version 2.0.2, org.apache.xerces.parsers.SAXParser does not correctly 
report values of attributes which are not valid against their schema. Note that 
previous versions (2.0.1 and 2.0.0) used to work fine with regard to this 
problem.

SCHEMA SAMPLE(Defined a <person> element with a required "name" attribute of 
type xsd:NCName):

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
        <xsd:element name="person">
                <xsd:complexType>
                        <xsd:attribute name="name" type="xsd:NCName" 
use="required"/>
                </xsd:complexType>
        </xsd:element>
</xsd:schema>



INSTANCE SAMPLE ( the value of "name" attribute is not a NCName) :

<?xml version="1.0" encoding="UTF-8"?>
<person xmlns:xsd="http://www.w3.org/2001/XMLSchema";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:noNamespaceSchemaLocation="file:///C:/cygwin/home/achille/projects/S
ketch/temp/validationTest.xsd"
        name="prefix:NCName"/>




SAMPLE CODE ( print out the value of the "name" attribute) :

package com.ibm.sketch.connection;

import org.apache.xerces.parsers.SAXParser;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
import org.xml.sax.Attributes;

public class XercesTest {

        public static void main(String[] args) throws Exception {
                XMLReader ret = new SAXParser();
                ret.setFeature("http://xml.org/sax/features/namespaces";, true);
                ret.setFeature("http://xml.org/sax/features/namespace-
prefixes", true);
                ret.setFeature("http://xml.org/sax/features/validation";, true);
                ret.setFeature
("http://apache.org/xml/features/validation/schema";, true);

                ret.setFeature(
                        "http://apache.org/xml/features/continue-after-fatal-
error",
                        false);
                ret.setContentHandler(new org.xml.sax.helpers.DefaultHandler() {
                        public void startElement(
                                String uri,
                                String localName,
                                String qName,
                                Attributes attributes)
                                throws SAXException {
                                if (localName.equals("person")) {
                                        System.out.println("name ='" + 
attributes.getValue("", "name") + "'");
                                }
                        }
                });

                ret.parse(args[0]);
        }
}




OUPUT :

name ='file:///C:/cygwin/home/achille/projects/Sketch/temp/validationTest.xsd'
[Error] C:\cygwin\home\achille\projects\Sketch\temp\validationTest.xml:5:24: 
cvc-datatype-valid.1.2.1: 'prefix:NCName' is not a valid 'NCName' value.
[Error] C:\cygwin\home\achille\projects\Sketch\temp\validationTest.xml:5:24: 
cvc-attribute.3: The value 'prefix:NCName' of attribute 'name' on 
element 'person' is not valid with respect to its type.



EXPECTED OUTPUT :

name='prefix:NCName'
[Error] C:\cygwin\home\achille\projects\Sketch\temp\validationTest.xml:5:24: 
cvc-datatype-valid.1.2.1: 'prefix:NCName' is not a valid 'NCName' value.
[Error] C:\cygwin\home\achille\projects\Sketch\temp\validationTest.xml:5:24: 
cvc-attribute.3: The value 'prefix:NCName' of attribute 'name' on 
element 'person' is not valid with respect to its type.

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

Reply via email to