Element 'assert' is invalid, misplaced, or occurs too often

孤人 提交于 2019-12-05 18:26:51

XSD 1.1 is required for xs:assert, but JAXB only supports XSD 1.0, not XSD 1.1. None of the requests to add support for XSD 1.1 have be addressed (references: here and here).

What to do:

  • Contribute support yourself, or hope that someone else does (unlikely).
  • In the meantime, analyse the XSDs for 1.1 dependencies. If mild, such as only use of xs:assert, write a simple XSLT transformation to strip xs:assert validations so that you can still generate classes. (See XSLT below.) Optionally, as needed, implement the xs:assert checks in Java code manually.

XSLT to strip xs:assert:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="xs:assert"/>
</xsl:stylesheet>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!