support for <xs:alternative> from XML Schema 1.1
Opened this issue · 2 comments
vandenoever commented
This validator gives an error on an XML Schema 1.1 that contains <xs:alternative/>
.
java -jar xjparse-app-3.0.0.jar -S alternative.xsd test.xml
This is the error:
The content of 'message' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: alternative.
Here is example.xsd
(copied from the XSD 1.1 spec):
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified" vc:minVersion="1.1">
<xs:complexType name="messageType" mixed="true">
<xs:sequence>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="kind">
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="string"/>
<xs:enumeration value="base64"/>
<xs:enumeration value="binary"/>
<xs:enumeration value="xml"/>
<xs:enumeration value="XML"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:attribute>
<xs:anyAttribute processContents="skip"/>
</xs:complexType>
<xs:complexType name="messageTypeString">
<xs:simpleContent>
<xs:restriction base="messageType">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="messageTypeBase64">
<xs:simpleContent>
<xs:restriction base="messageType">
<xs:simpleType>
<xs:restriction base="xs:base64Binary"/>
</xs:simpleType>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="messageTypeXML">
<xs:complexContent>
<xs:restriction base="messageType">
<xs:sequence>
<xs:any processContents="strict"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="message" type="messageType">
<xs:alternative test="@kind='string'" type="messageTypeString"/>
<xs:alternative test="@kind='base64'" type="messageTypeBase64"/>
<xs:alternative test="@kind='binary'" type="messageTypeBase64"/>
<xs:alternative test="@kind='xml'" type="messageTypeXML"/>
<xs:alternative test="@kind='XML'" type="messageTypeXML"/>
<xs:alternative type="messageType"/>
</xs:element>
</xs:schema>
vandenoever commented
After setting the default for xsd11
in com.nwalsh.parsers.XJParser
to true
, the error message changes:
java.lang.IllegalArgumentException: No SchemaFactory that implements the schema language specified by: http://www.w3.org/XML/XMLSchema/v1.1 could be loaded
vandenoever commented
This was tested with two different openjdk version:
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-ga)
OpenJDK 64-Bit Server VM (build 25.212-bga, mixed mode)
and
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.14.0, JRE 11 Linux amd64-64-Bit Compressed References 20190417_202 (JIT enabled, AOT enabled)
OpenJ9 - bad1d4d06
OMR - 4a4278e6
JCL - 5cc996a803 based on jdk-11.0.3+7)