2017-05-02 61 views
0

我嘗試從由Netbeans的一個xsd JAXB類,但即時得到JAXB「語法未指定」

C:\datos\NetBeansProjects\RegistradoresWSSERCON\nbproject\xml_binding_build.xml:15: grammar is not specified 

相對於代碼道:

<xjc destdir="build/generated/jaxbCache/ACK" catalog="catalog.xml"> 

這是XSD我嘗試使用:

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wmh="http://www.wmhelp.com/2003/eGenerator" elementFormDefault="qualified"> 
    <xs:element name="registroResponse">  
     <xs:complexType> 
      <xs:sequence> 
       <xs:element maxOccurs="unbounded" minOccurs="0" name="codigosError" nillable="true" type="tns:registroError"/> 
       <xs:element minOccurs="0" name="idTramite" type="xs:string"/> 
       <xs:element minOccurs="0" name="xml" type="xs:base64Binary"/> 
      </xs:sequence> 
     </xs:complexType> 
    </xs:element> 
    <xs:element name="registroError"> 
     <xs:complexType> 
      <xs:sequence> 
       <xs:element minOccurs="0" name="codigo" type="xs:string"/> 
       <xs:element minOccurs="0" name="descripcion" type="xs:string"/> 
       <xs:element minOccurs="0" name="detalles" type="xs:string"/> 
      </xs:sequence> 
     </xs:complexType> 
    </xs:element> 
</xs:schema> 

任何人都知道發生了什麼事?提前

編輯Tyvm:xml_binding_build.xml

<?xml version="1.0" encoding="UTF-8"?><!-- 
     *** GENERATED FROM xml_binding_cfg.xml - DO NOT EDIT *** 
     *** Configure thru JAXB Wizard.      *** 
    --><project name="RegistradoresWSSERCON_jaxb" default="default" basedir="."> 
<target name="xjc-typedef-target" depends="-init-project"> 
    <typedef classname="com.sun.tools.xjc.XJCTask" name="xjc" xmlns:s="http://xml.netbeans.org/schema/JAXBWizConfig"> 
     <classpath path="${jaxbwiz.xjcdef.classpath}"/> 
    </typedef> 
</target> 
<target name="jaxb-clean-code-generation" depends="clean,jaxb-code-generation"/> 
<target name="jaxb-code-generation" depends="xjc-typedef-target,-do-init,-init-macrodef-javac"> 
    <mkdir dir="${build.generated.sources.dir}/jaxb" xmlns:s="http://xml.netbeans.org/schema/JAXBWizConfig"/> 
    <mkdir dir="build/generated/jaxbCache" xmlns:s="http://xml.netbeans.org/schema/JAXBWizConfig"/> 
    <mkdir dir="build/generated/jaxbCache/ACK"/> 
    <xjc destdir="build/generated/jaxbCache/ACK" catalog="catalog.xml"> 
     <classpath> 
      <pathelement location="${src.dir}"/> 
      <pathelement path="${jaxbwiz.xjcrun.classpath}"/> 
     </classpath> 
     <arg value="-xmlschema"/> 
     <schema file=""/> 
     <depends file=""/> 
     <produces dir="build/generated/jaxbCache/ACK"/> 
    </xjc> 
    <copy todir="${build.generated.sources.dir}/jaxb"> 
     <fileset dir="build/generated/jaxbCache/ACK"/> 
    </copy> 
    <!--*** Web project javac macro does not support sourcepath attribute, so do not pass "sourcepath=${src.dir}"--> 
</target> 

+0

我相信錯誤意味着它無法找到XSD文件。 ---另外,您的XSD文件是否真的以''標籤之前的空格開頭,就像它在這裏顯示的那樣? – Andreas

+0

請發佈整個xjc片段 – Aubin

+0

@Andreas,nope,之前沒有空格,這是一個ident錯誤。 – AMB

回答

2

<schema file=""/>提供空路徑,JAXB有沒有要處理。

xjc任務文檔here

Attribute Description 
------------------------------------------ 
schema  A schema file to be compiled. A file name (can be relative to the build script base directory), or an URL. This or nested <schema> elements are required. 
destdir  Generated code will be written under this directory. If you specify target="abc/def" and package="org.acme", then files are generated to abc/def/org/acme. 
catalog  Specify the catalog file to resolve external entity references. Support TR9401, XCatalog, and OASIS XML Catalog format. See the catalog-resolver sample for details. 

Netbeans JAXB Wizard FAQ is here

This article shows a dialog box of the wizard with a path and a browse button.

+0

OP可以有一個嵌套的''元素。我們可以看到''元素沒有結束,所以我們顯然沒有看到它。 – Andreas

+0

是的,我有但我認爲它是由Netbeans中的jaxb bingind插件自動生成的 – AMB

+0

「」不是有效的路徑...您的問題與xjc片段的生成有關 – Aubin