Hi Caroline, The last fix checked in addresses a derivation by restriction issue. Checkout the latest source and build it and use that jar. I tested using the latest jar and do not get the error (I got the error using an earlier jar) This is the test program. public class XmlBeansTest { public static void main(String[] args) { String schema = "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\">\n" + " <xs:element name=\"RootElement\">\n" + " <xs:annotation>\n" + " <xs:documentation>Comment describing your root element</xs:documentation>\n" + " </xs:annotation>\n" + " <xs:complexType>\n" + " <xs:sequence>\n" + " <xs:element ref=\"Child\"/>\n" + " <xs:element ref=\"ChildExtended\"/>\n" + " <xs:element ref=\"ChildRestricted\"/>\n" + " </xs:sequence>\n" + " </xs:complexType>\n" + " </xs:element>\n" + " <xs:element name=\"Child\" type=\"MixedType\"/>\n" + " <xs:element name=\"ChildRestricted\" type=\"MixedTypeRestricted\"/>\n" + " <xs:element name=\"ChildExtended\" type=\"MixedTypeExtended\"/>\n" + " <xs:complexType name=\"MixedType\" mixed=\"true\"/>\n" + " <xs:complexType name=\"MixedTypeExtended\" mixed=\"true\">\n" + " <xs:complexContent mixed=\"true\">\n" + " <xs:extension base=\"MixedType\"/>\n" + " </xs:complexContent>\n" + " </xs:complexType>\n" + " <xs:complexType name=\"MixedTypeRestricted\" mixed=\"true\">\n" + " <xs:complexContent mixed=\"true\">\n" + " <xs:restriction base=\"MixedType\"/>\n" + " </xs:complexContent>\n" + " </xs:complexType>\n" + "</xs:schema>"; String testxml = "<RootElement xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + " <Child>text</Child> \n" + " <ChildExtended>text1</ChildExtended>\n" + " <ChildRestricted>text2</ChildRestricted>\n" + "</RootElement>"; try { SchemaTypeSystem sts1 = XmlBeans.compileXsd(new XmlObject[]{XmlObject.Factory.parse(schema)}, XmlBeans.getBuiltinTypeSystem(), null); XmlObject x1 = sts1.parse(testxml, sts1.findDocumentType(new QName("", "RootElement")), null); XmlOptions xo = new XmlOptions(); ArrayList<XmlValidationError> errorlist = new ArrayList<XmlValidationError>(); xo.setErrorListener(errorlist); if (!x1.validate(xo)) { for (XmlValidationError e : errorlist) { System.out.println(e.getMessage()); } } } catch (XmlException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } } regards, Jerry On 6/8/2011 9:06 AM, Caroline Rosin (JIRA) wrote: Mixed and restricted element fails validation ---------------------------------------------Key: XMLBEANS-457 URL: https://issues.apache.org/jira/browse/XMLBEANS-457 Project: XMLBeans Issue Type: Bug Components: Validator Affects Versions: Version 2.4 Environment: jdk1.6.0_25 Reporter: Caroline Rosin Priority: Critical I have noticed that when an element is defined as a restriction from a mixed type, if there is some text in this element the Xmlbeans validation fails.However the same xml file is valid if I run it against schema validation in XmlSpy. Here is the example (I tried to make it as simple as possible): xml schema: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="RootElement"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element ref="Child"/> <xs:element ref="ChildExtended"/> <xs:element ref="ChildRestricted"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Child" type="MixedType"/> <xs:element name="ChildRestricted" type="MixedTypeRestricted"/> <xs:element name="ChildExtended" type="MixedTypeExtended"/> <xs:complexType name="MixedType" mixed="true"/> <xs:complexType name="MixedTypeExtended" mixed="true"> <xs:complexContent mixed="true"> <xs:extension base="MixedType"/> </xs:complexContent> </xs:complexType> <xs:complexType name="MixedTypeRestricted" mixed="true"> <xs:complexContent mixed="true"> <xs:restriction base="MixedType"/> </xs:complexContent> </xs:complexType> </xs:schema> xml file: <RootElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Child>text</Child> <ChildExtended>text1</ChildExtended> <ChildRestricted>text2</ChildRestricted> </RootElement> For XmlSpy, this is valid. Here's what I get when validating with Xmlbeans : Message: Element 'ChildRestricted' with empty content type cannot have text or element content. Location of invalid XML: <xml-fragment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/> I guess this is linked to this issue : http://www.mail-archive.com/dev@xmlbeans.apache.org/msg02004.html -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: dev-h...@xmlbeans.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: dev-h...@xmlbeans.apache.org |
- [jira] [Created] (XMLBEANS-457) Mixed and restricted... Caroline Rosin (JIRA)
- Re: [jira] [Created] (XMLBEANS-457) Mixed and r... Jerry Sy
- [jira] [Commented] (XMLBEANS-457) Mixed and res... Jerry Sy (JIRA)
- [jira] [Commented] (XMLBEANS-457) Mixed and res... Caroline Rosin (JIRA)