PLEASE DO NOT REPLY TO THIS MESSAGE. TO FURTHER COMMENT ON THE STATUS OF THIS BUG PLEASE FOLLOW THE LINK BELOW AND USE THE ON-LINE APPLICATION. REPLYING TO THIS MESSAGE DOES NOT UPDATE THE DATABASE, AND SO YOUR COMMENT WILL BE LOST SOMEWHERE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3228 *** shadow/3228 Wed Aug 22 08:16:55 2001 --- shadow/3228.tmp.14356 Wed Aug 22 08:16:55 2001 *************** *** 0 **** --- 1,178 ---- + +============================================================================+ + | Re-usable XML Schema attribute groups are not being evaluated correctly. | + +----------------------------------------------------------------------------+ + | Bug #: 3228 Product: Xerces-J | + | Status: NEW Version: 1.4.2 | + | Resolution: Platform: Other | + | Severity: Major OS/Version: Other | + | Priority: Other Component: Schema-Structures | + +----------------------------------------------------------------------------+ + | Assigned To: [EMAIL PROTECTED] | + | Reported By: [EMAIL PROTECTED] | + | CC list: Cc: | + +----------------------------------------------------------------------------+ + | URL: | + +============================================================================+ + | DESCRIPTION | + When attempting to validate the following simple xml document using the + SAXParser object: + + <?xml version = "1.0" encoding = "UTF-8"?> + <Voice xmlns = "http://adwuk007/XMLSchema/Test" + xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation = "http://adwuk007/XMLSchema/Test + http://adwuk007/XMLSchema/Test.xsd" + countryCode = "44" areaCode = "0118" number = "9387028"/> + + Using this simple schema: + + <?xml version = "1.0" encoding = "UTF-8"?> + <xsd:schema xmlns = "http://adwuk007/XMLSchema/Test" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace = "http://adwuk007/XMLSchema/Test" + version = "5.0" + elementFormDefault = "unqualified" + attributeFormDefault = "unqualified"> + <xsd:attribute name = "countryCode" type = "xsd:nonNegativeInteger"/> + <xsd:attribute name = "areaCode" type = "xsd:nonNegativeInteger"/> + <xsd:attribute name = "number" type = "xsd:nonNegativeInteger"/> + + <xsd:attributeGroup name = "PhoneNumber"> + <xsd:attribute ref = "countryCode" use = "required"/> + <xsd:attribute ref = "areaCode" use = "required"/> + <xsd:attribute ref = "number" use = "required"/> + </xsd:attributeGroup> + <xsd:element name = "Voice"> + <xsd:complexType> + <xsd:attributeGroup ref = "PhoneNumber"/> + <xsd:attribute name = "leaveMessage" type + = "xsd:boolean" default = "false"/> + </xsd:complexType> + </xsd:element> + </xsd:schema> + + The following errors are reported (using my own ErrorHandler): + + ------------------------------------------------------------ + + ERROR : Attribute "countryCode" is required and must be specified for element + type "Voice". + + LINE : 5 + + COLUMN : 65 + + ------------------------------------------------------------ + + ERROR : Attribute "areaCode" is required and must be specified for element + type "Voice". + + LINE : 5 + + COLUMN : 65 + + ------------------------------------------------------------ + + ERROR : Attribute "number" is required and must be specified for element + type "Voice". + + LINE : 5 + + COLUMN : 65 + + ------------------------------------------------------------ + + ERROR : Attribute "countryCode" must be declared for element type "Voice". + + LINE : 5 + + COLUMN : 65 + + ------------------------------------------------------------ + + ERROR : Attribute "areaCode" must be declared for element type "Voice". + + LINE : 5 + + COLUMN : 65 + + ------------------------------------------------------------ + + ERROR : Attribute "number" must be declared for element type "Voice". + + LINE : 5 + + COLUMN : 65 + + I've checked the schema using IBMs schema quality checking utility and it finds + no errors. I've also loaded the schema into TIBCOs XML Authority without + problems. I'm using the TogetherSofts Together product to compile and execute + the routine. Here's the source code I'm using: + + import org.apache.xerces.parsers.SAXParser; + + import org.xml.sax.InputSource; + import org.xml.sax.SAXParseException; + import org.xml.sax.SAXException; + import org.xml.sax.SAXNotRecognizedException; + + import java.io.IOException; + import java.lang.Exception; + + + /** + * Title: XMLValidator.java + * Description: SAX Schema Validation + * Date: 20 August 2001 + * Copyright: Copyright (c) 2001 + * Company: Adeptra + * @author James Kavanagh/Dan Macfarlane + * @version 1.0 + */ + + public class XMLValidator { + + public static void main(String [] args){ + + String file = args[0]; + + System.out.println("Attempting to parse document : " + args[0].toString()); + + try { + SAXParser parser = new SAXParser(); + 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/schema-full-checking", true); + parser.setFeature("http://apache.org/xml/features/validation/warn-on- + undeclared-elemdef", true); + + parser.setErrorHandler(new MySaxErrorHandler()); + + InputSource in2 = new InputSource(args[0]); + + parser.parse(in2); + + System.out.println("XML Parsed successfully"); + + } + catch (SAXNotRecognizedException snre) { + System.out.println("SaxNotRecognizedException : " + snre.getMessage()); + } + catch (SAXParseException spe) { + System.out.println("SaxParseException : " + spe.getMessage()); + } + catch (SAXException se) { + System.out.println("IOException : " + se.getMessage()); + } + catch (IOException ioe) { + System.out.println("IOException : " + ioe.getMessage()); + } + + } + + } + + Regards, + James Kavanagh --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
