XML validation against XSD 1.1 with Xerces in Java

前端 未结 3 1791
Happy的楠姐
Happy的楠姐 2021-01-04 23:10

I have installed Xerces through Maven:


    
        junit
        jun         


        
相关标签:
3条回答
  • 2021-01-04 23:42

    I will add another answer, because for me this dependency did not work (same error as described by OP):

    <dependency>
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</artifactId>
      <version>2.11.0</version>
    </dependency>
    

    I quess 2.11.0 should be newer than 2.11.0.beta, but it seems like xsd1.1 is not supported in that version !

    Instead only the following dependency lead to a working XSD1.1 validation for me:

    <dependency>
        <groupId>org.opengis.cite.xerces</groupId>
        <artifactId>xercesImpl-xsd11</artifactId>
        <version>2.12-beta-r1667115</version>
    </dependency>
    

    ( Found in this SO thread: How to validate XML against XSD 1.1 in Java? )

    0 讨论(0)
  • 2021-01-04 23:50

    I think they have added version 2.11 to maven now. The following dependency in Maven works out-of-the-box:

    <dependency>
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</artifactId>
      <version>2.11.0</version>
    </dependency>
    
    0 讨论(0)
  • 2021-01-04 23:59

    It looks that you need Xerces2 Java 2.11.0 (XML Schema 1.1) (Beta) version, which isn't in maven repository. You can download it from Xerces website, and install it to your local maven repository: mvn install:install-file -Dfile=xercesImpl.jar -DgroupId=xerces -DartifactId=xercesImpl -Dversion=2.11.0.beta -Dpackaging=jar Then you will be able to include it in your Maven project dependencies:

    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.11.0.beta</version>
    </dependency>   
    
    0 讨论(0)
提交回复
热议问题