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=8967>. 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=8967 Default element behaviour is incorrect (schema only) Summary: Default element behaviour is incorrect (schema only) Product: Xerces-C++ Version: 1.7.0 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Major Priority: Other Component: Validating Parser (Schema) (Xerces 1.5 or up only) AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] If an element has a default value, the default value should be supplied whenever the element occurs but is empty. Testing on NT4 SP6a with Xerces- c1_7_0 shows a bug. The default value is being supplied by a 'characters' event but is out of sequence with the appropriate 'startElement' and 'endElement' events. The three examples below demonstrate this bug. I have only tested on NT4 but after examining the code I suspect that this bug will occur on all platforms. Example 1: An example of where the element's default value appears before the start tag: This is the schema:- <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.element-examples.org" xmlns="http://www.element-examples.org" elementFormDefault="qualified"> <!-- ************************************** --> <!-- Version #1 --> <!-- ************************************** --> <xsd:element name="ElementExamples"> <xsd:complexType> <xsd:sequence> <xsd:element name="aircraft" default="Boeing 747" maxOccurs="2" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> This is the xml:- <?xml version="1.0"?> <ElementExamples xmlns="http://www.element-examples.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://www.element-examples.org ElementExamplesVersion01.xsd"> <!-- ************************************** --> <!-- Version #1 --> <!-- ************************************** --> <aircraft/> <!-- Using the default value --> <aircraft>F-16</aircraft> <!-- Not using the default value --> </ElementExamples> Output from Sax2Print:- 'Boeing 747' appears before the start tag. <?xml version="1.0" encoding="LATIN1"?> <ElementExamples xsi:schemaLocation="http://www.element- examples.org ElementWithDefault.xsd"> Boeing 747<aircraft></aircraft> <aircraft>F-16</aircraft> </ElementExamples> Example 2: An example of where the element's default value appears after the end tag. This is the schema:- ( same schema as in example 1 ) <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.element-examples.org" xmlns="http://www.element-examples.org" elementFormDefault="qualified"> <!-- ************************************** --> <!-- Version #1 --> <!-- ************************************** --> <xsd:element name="ElementExamples"> <xsd:complexType> <xsd:sequence> <xsd:element name="aircraft" default="Boeing 747" maxOccurs="2" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> This is the xml:- The here is <aircraft></aircraft> instead of <aircraft/> <?xml version="1.0"?> <ElementExamples xmlns="http://www.element-examples.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://www.element-examples.org ElementExamplesVersion01.xsd"> <!-- ************************************** --> <!-- Version #1 --> <!-- ************************************** --> <aircraft></aircraft> <!-- Using the default value --> <aircraft>F-16</aircraft> <!-- Not using the default value --> </ElementExamples> Output from Sax2Print:- 'Boeing 747' appears after the end tag. <?xml version="1.0" encoding="LATIN1"?> <ElementExamples xsi:schemaLocation="http://www.element- examples.org ElementExamplesVersion01.xsd"> <aircraft></aircraft>Boeing 747 <aircraft>F-16</aircraft> </ElementExamples> Example 3: Another example of where the element default value appears before the start tag, this demonstrates a situation where the default value would be interpreted as part of a block text in a mixed element rather than the value of a particular element. Clearly this is incorrect. This is the schema:- <?xml version="1.0"?> <xsd:schema targetNamespace="http://www.element-examples.org" xmlns="http://www.element-examples.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xsd:element name="ElementExamples"> <xsd:complexType> <xsd:sequence> <xsd:element name="parent1"> <xsd:complexType mixed="true"> <xsd:sequence> <xsd:element name="child1" type="xsd:string" minOccurs="0"/> <xsd:element name="parent2"> <xsd:complexType mixed="true"> <xsd:sequence> <xsd:element name="child2" type="xsd:string" minOccurs="0"/> <xsd:element name="parent3"> <xsd:complexType mixed="true"> <xsd:sequence> <xsd:element name="aircraft" type="xsd:string" default="Default Aircraft" maxOccurs="2"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> This is the xml:- <?xml version="1.0"?> <ElementExamples xmlns="http://www.element-examples.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.element-examples.org MixedWithDefault.xsd"> <parent1> Some text between parent 1 and parent 2 <parent2> Some text between parent 2 and parent 3 <parent3>Some Text before aircraft <aircraft/> some text after first aircraft <!-- Using the default value --> <aircraft>F-16</aircraft> <!-- Not using the default value --> </parent3> </parent2> </parent1> </ElementExamples> Output from Sax2Print:- 'Default Aircraft' should appear between the <aircraft> and </aircraft> tags. <?xml version="1.0" encoding="LATIN1"?> <ElementExamples xsi:schemaLocation="http://www.element- examples.org MixedWithDefault.xsd"> <parent1> Some text between parent 1 and parent 2 <parent2> Some text between parent 2 and parent 3 <parent3>Some Text before aircraft Default Aircraft<aircraft></aircraft> some text after first aircraft <aircraft>F-16</aircraft> </parent3> </parent2> </parent1> </ElementExamples> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
