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

Erroneous SAX events for attribute whose type is a list type

           Summary: Erroneous SAX events for attribute whose type is a list
                    type
           Product: Xerces2-J
           Version: 2.0.2
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: SAX
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Xerces validating SAX parser version 2.0.2 incorrectly reports the value of an 
attribute whose type is a list type. Note that this problem does not occur when 
the validation is turned off, and did not exist in previous versions of Xerces.


SAMPLE SCHEMA (define a <person> element with a "refs" attribute of type list 
of NCNames)
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema  xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
        <xsd:simpleType name="listOfNCNames">
                <xsd:list itemType="xsd:NCName"/>
        </xsd:simpleType>
        <xsd:element name="person">
                <xsd:complexType>       
                        <xsd:attribute name="refs" type="listOfNCNames"/>
                </xsd:complexType>
        </xsd:element>
</xsd:schema>


SAMPLE INSTANCE :
<?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:/temp/XercesTest.xsd"
        refs="a b c d"/>

SAMPLE CODE : (print out the value of the "refs" attribute of <person>)
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("refs ='" + 
attributes.getValue("", "refs") + "'");
                                }
                        }
                });

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


OUTPUT: 
refs ='d'


EXPECTED OUTPUT:
refs ='a b c d'

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

Reply via email to