Hi Andreas,

This has nothing to do with the programming language you choose. Your
schema is invalid. It violates the Unique Particle Attribution [1]
constraint by specifying a choice between two particles which accept the
same input (i.e. "order_no"). Tools which claim such schemas are valid
aren't fully conformant to the XML Schema specification.

Also note that you're not even using Apache Xerces. The
com.sun.org.apache.xerces.* classes are Sun's (aging) fork of the Xerces
codebase which they develop/maintain and release in their JDK. If you were
to encounter a bug with this implementation you would need to pursue it
with Sun. We have nothing to do with it.

Thanks.

[1] http://www.w3.org/TR/xmlschema-1/#cos-nonambig

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

Andreas Riedel <[EMAIL PROTECTED]> wrote on 08/21/2008 08:31:29 AM:

> Hello list.
>
> I've following XSD specification:
>
>
----------------------------------------------------------------------------

> <?xml version="1.0" encoding="utf-8"?>
> <!-- Created with Liquid XML Studio 1.0.8.0 (http://www.liquid-
> technologies.com) -->
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
>   <xsd:element name="data">
>     <xsd:complexType>
>       <xsd:choice>
>         <xsd:group ref="elem1" />
>         <xsd:group ref="elem2" />
>       </xsd:choice>
>     </xsd:complexType>
>   </xsd:element>
>   <xsd:group name="elem1">
>     <xsd:sequence>
>       <xsd:element name="order_no" />
>     </xsd:sequence>
>   </xsd:group>
>   <xsd:group name="elem2">
>     <xsd:sequence>
>       <xsd:element name="order_no" />
>     </xsd:sequence>
>   </xsd:group>
> </xsd:schema>
>
----------------------------------------------------------------------------

>
> on
>
>
----------------------------------------------------------------------------

> final SchemaFactory factory = SchemaFactory.
> newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
> final Schema schema = factory.newSchema(xsd);
>
----------------------------------------------------------------------------

>
> I get the following exception
>
>
----------------------------------------------------------------------------

> org.xml.sax.SAXParseException: cos-nonambig: "":order_no and "":
> order_no (or elements from their substitution group) violate "Unique
> Particle Attribution". During validation against this schema,
> ambiguity would be created for those two particles.
>   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.
> createSAXParseException(ErrorHandlerWrapper.java:236)
>   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.
> error(ErrorHandlerWrapper.java:172)
>   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.
> reportError(XMLErrorReporter.java:382)
>   at com.sun.org.apache.xerces.internal.impl.xs.XSConstraints.
> reportSchemaError(XSConstraints.java:315)
>   at com.sun.org.apache.xerces.internal.impl.xs.XSConstraints.
> fullSchemaChecking(XSConstraints.java:463)
>   at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.
> loadGrammar(XMLSchemaLoader.java:530)
>   at com.sun.org.apache.xerces.internal.jaxp.validation.xs.
> SchemaFactoryImpl.newSchema(SchemaFactoryImpl.java:206)
>   at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:489)
>   at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:505)
>
----------------------------------------------------------------------------

>
> Possibly this is related to the following bug?
>  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4996456
>
> From my point of view reading the W3C Spec, in a choice the group is
> distinct. So we should be able to use it like i did.
>
> Is there a solution or workaround provided by Xerces init self or can
> anybody tell me how to find an solution in an other JAVA library. I
didn't
> work XML validation that often, but in the past I did use some of the
Apache
> Frameworks. But as I can see in the error discription, Apache is already
> involved.
>
> Attention:
>   The original XSD is more complicatated and shared by different
programms
>   in different Languages, C#, .Net, Navision. So, if there is no error in
>   the XSD which will be handled by the other frameworks less strict or
>   leniant, it will be complicated for to me to argue, that we have to
change
>   the XSD so that we can handle it in Java.
>
> TIA
> Andreas
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden
> Schutz gegen Massenmails.
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to