XSD2DB error when processing USPTO xsd file

Help
2009-07-27
2013-04-25
  • Hi ,  the USPTO has published their PatentApplicationData.xsd file
    "http://www.uspto.gov/ebc/portal/pair/xsd/PatentApplicationData.xsd"

    Trying to generate the schema leads to the following error:

    xsd2db.bat --xsdURL="http://www.uspto.gov/ebc/portal/pair/xsd/PatentApplicationData.xsd"
    0 [main] INFO org.hibernate.cfg.Environment  - Hibernate 3.0.5
    0 [main] INFO org.hibernate.cfg.Environment  - hibernate.properties not found
    0 [main] INFO org.hibernate.cfg.Environment  - using CGLIB reflection optimizer
    0 [main] INFO org.hibernate.cfg.Environment  - using JDK 1.4 java.sql.Timestamp
    handling

    Downloading PatentApplicationData.xsd...
    Download successful...
    Cannot find CatalogManager.properties
    info: org.xml.sax.SAXParseException: Using Xerces from jar:file:/C:/Program%20Fi
    les/Java/jdk1.5.0_18/jre/lib/rt.jar!/com/sun/org/apache/xerces/internal/impl/Ver
    sion.class
    Error: org.xml.sax.SAXParseException: A class/interface with the same name "us.g
    ov.uspto.pair.ContinuityType" is already in use. Use a class customization to re
    solve this conflict.
    Error: org.xml.sax.SAXParseException: (Relevant to above error) another "Continu
    ityType" is generated from here.
    Unable to parse schema
    info: org.xml.sax.SAXParseException: generating code
    Error: There was an error with the hyperjaxb addon or xjc comipler.
    null
    java.lang.NullPointerException
            at com.sun.tools.xjc.generator.SkeletonGenerator.<init>(SkeletonGenerator.java:137)
            at com.sun.tools.xjc.generator.SkeletonGenerator.generate(SkeletonGenerator.java:125)
            at com.sun.tools.xjc.Driver.generateCode(Driver.java:394)
            at edu.lmu.xmlpipedb.xsd2db.Xsd2db.run(Xsd2db.java:245)
            at edu.lmu.xmlpipedb.xsd2db.Xsd2dbCommandLine.run(Xsd2dbCommandLine.java:162)
            at edu.lmu.xmlpipedb.xsd2db.Xsd2dbCommandLine.main(Xsd2dbCommandLine.java:150)
    3500 [main] INFO org.hibernate.dialect.Dialect  - Using dialect: org.hibernate.dialect.DB2Dialect
    3531 [main] INFO org.hibernate.cfg.Configuration  - processing extends queue
    3531 [main] INFO org.hibernate.cfg.Configuration  - processing collection mappings
    3531 [main] INFO org.hibernate.cfg.Configuration  - processing association property references
    3546 [main] INFO org.hibernate.cfg.Configuration  - processing foreign key constraints
    3546 [main] INFO org.hibernate.cfg.Configuration  - processing extends queue
    3546 [main] INFO org.hibernate.cfg.Configuration  - processing collection mappings
    3546 [main] INFO org.hibernate.cfg.Configuration  - processing association property references
    3546 [main] INFO org.hibernate.cfg.Configuration  - processing foreign key constraints
    3546 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport  - Running hbm2ddl schema export
    3546 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport  - writing generated schema to file: db-gen\sql\schema.sql
    3546 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport  - schema export complete
    found build file
    Build Finished!

    Any idea how to fix it?

     
    • dondi
      dondi
      2009-07-27

      Greetings Franck,

      Yes, we're aware that some XSDs produce this result.  The issue has to do with naming; XSD naming rules are less restrictive than in Java, and so this error shows up when the default 1-to-1 conversion from XSD to Java causes conflicts on the Java side (note how in your particular case, "ContinuityType" already appears to be in use).

      The solution, though admittedly one we haven't tried ourselves yet, is to use "class customizations" (as suggested in the error message).  This is a feature of the HyperJAXB library that we use.  My understanding is that "class customizations" are a file/configuration that modifies the name mapping from XSD to Java.  Documentation on this should be available with HyperJAXB.

      Hope this helps...FWIW, this is something that we'd like to try ourselves on some of the XSDs we're interested in, but we just haven't gotten around to it yet.