Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the alternatives to have XML Schema 1.1 support by JAXB?

I am getting error while generating Java from WSDL. I wanted to use XML Schema's 1.1 feature (xsd:assert). It is asserting if an element is available in the Web Service Request.

 <xsd:assert test="(count(InstanceDetail[@OrderCodeType eq 'OFFERID']) eq 1)" />

I am using Apache CXF v 2.6.1. I am getting an error while using mvn generate-sources option:

Thrown by JAXB: Unexpected <xsd:assert> appears at line 200 column 3 of schema file:

Researching upon the error, I found out that JAXB only supports XML Schema 1.0 and this feature is available in XML Schema 1.1. If it is true, what are the other options do I have?

like image 323
user1555524 Avatar asked Jan 26 '15 21:01

user1555524


2 Answers

No, current version of JAXB does not support XSD 1.1. See these issues, for instance:

  • https://java.net/jira/browse/JAXB-994
  • https://java.net/jira/browse/JAXB-967

Update:

Concerning the solution. Me personally, I'd run an XSLT which would strip all the XSD 1.1. features and return vanilla XSD 1.0 as the result and compile that with JAXB. Not sure how to do this technically with CXF, though.

like image 183
lexicore Avatar answered Nov 03 '22 02:11

lexicore


You could always use schematron (http://schematron.com/) on top of XSD 1.0. It's a bit tricky but by doing so you will have the conditional validation features of XSD 1.1 and compatibility with the XSD parser.

like image 24
Georgios Markakis Avatar answered Nov 03 '22 02:11

Georgios Markakis