2015-09-04 141 views
0

使用XJC基於個別DTD文件Java源文件生成JAXB上午......自動化XJC命令從多個DTD生成Java SRC文件

當嘗試使用下面的命令行調用:

xjc -dtd -d . -p com.myapp.jaxb *.dtd 

我收到此錯誤信息:

parsing a schema... 
[ERROR] Too many schema files for this schema language. Compile one file at a time. 
unknown location 

Failed to parse a schema. 

有沒有一種方法(通過的Unix shell腳本)來自動生成多個DTD文件?

如果Unix shell腳本可以迭代dir中的整個dtd列表,那將會很好。

此外,會這樣做(自動化xjc)負面影響的ObjectFactory類?

感謝您抽空閱讀本文時...

+0

也許用maven JAXB2插件 – MGorgon

+0

感謝MGorgon,這是爲什麼標記爲-1? –

+0

@Morgon不,不會幫助。它仍然是XJC的中心,所以你會得到相同的「太多架構文件」的錯誤。 – lexicore

回答

0

我通常首先編譯之前來連接的DTD在一個文件中。例如,與maven-antrun-plugin:從一個實際項目編制數的DTD

 <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>concatenate-dtds</id> 
        <phase>generate-sources</phase> 
        <configuration> 
         <target> 
          <concat destfile="src/main/resources/ogc/wms/1.1.0/wms_1_1_0.dtd"> 
           <fileset dir="src/main/resources/ogc/wms/1.1.0" includes="capabilities*.dtd,exception*.dtd"/> 
          </concat> 
         </target> 
        </configuration> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
       <execution> 
        <phase>process-sources</phase> 
        <configuration> 
         <target> 
          <delete dir="${basedir}/target/generated-sources/xjc/WMS_1_1_0"/> 
         </target> 
        </configuration> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

例子:

https://github.com/highsource/ogc-schemas/blob/master/wms/1.1.0/pom.xml#L43-L71