2016-07-12 3 views
2

私はカスタマイズを使用するXJCプラグインを開発しています。問題は、私はここでXJCプラグインのカスタマイズ

[ERROR] compiler was unable to honor this myPlugin:testAnnotation customization. It is attached to a wrong place, or its inconsistent with other bindings. 
    line 16 of file:/C:/JaxbPlugin_jar/withInternalBinding/sampleInlineAnnotation.xsd 

[ERROR] (the above customization is attached to the following location in the schema) 
    line 13 of file:/C:/JaxbPlugin_jar/withInternalBinding/sampleInlineAnnotation.xsd 

を取得するのは、私のスキーマです:

<?xml version='1.0' ?> 
<xs:schema 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:myPlugin="http://www.example.org" 
targetNamespace="http://www.books.org" 
xmlns="http://www.books.org" 

xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
jaxb:extensionBindingPrefixes="xjc myPlugin" 
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
jaxb:version="2.1"> 

    <xs:element name="a" type="xs:string"> 
     <xs:annotation> 
      <xs:appinfo> 
       <myPlugin:testAnnotation>test</myPlugin:testAnnotation> 
      </xs:appinfo> 
     </xs:annotation>  
    </xs:element> 
</xs:schema> 

私はそう

  1. 「それが接続された外部結合の構成(なし-bオプション)を使用していませんよ間違った場所 "
  2. " 他のバインディングと矛盾しています " - カスタマイズは1つしかなく、外部biは使用しませんファイルがありません

だから、<myPlugin:testAnnotation>test</myPlugin:testAnnotation>は間違った場所にあるようです。しかし、それは注釈タグの中にあり、なぜ動作しないのかわかりません。

+0

どのようなプラグインを開発していますか? – lexicore

+0

@lexicoreこれは内部使用のためのプラグインであり、多重化されています。私はxjc用のプラグインがあることを知っていて、それらのうちのいくつかはあなたによって書かれています=) – aderesh

答えて

1

短い答えは、おそらくすべてを正しく行っているということです。あなたはプラグインの実装の次のステップを踏み、XJCにカスタマイズを見たことを伝えるだけです。

このエラーは、いずれのプラグインもカスタマイズを「承認」しないと表示されます。カスタマイズを処理するには、通常、プラグインメソッドのいくつかをオーバーライドし、カスタマイズを処理するときはmarkAsAcknowledgedを呼び出します。

@Override 
public List<String> getCustomizationURIs() { 
    List<String> uris = new ArrayList<>(); 
    uris.add(...); 
    return uris; 
} 

@Override 
public boolean isCustomizationTagName(String nsUri, String localName) { 
    return ...; 
} 


for (CPluginCustomization customization : propertyInfo.getCustomizations()) { 
    if (isCustomizationTagName(customization.element.getNamespaceURI(), 
      customization.element.getLocalName())) { 
     // Apply the customization. 
     ... 

     // Tell XJC that the customization was consumed. 
     customization.markAsAcknowledged(); 
    } 
} 

wrong place言い回しの背後にある考え方は、プラグインが唯一の「プロパティ」レベルでのカスタマイズを探しているかもしれないということであるが、文書は(complexTypeの上で、例えば ')クラスのレベルでそれを持っています。この場合、プラグインコードはそれを見落とします(classInfo上でそれを探していないため)、それが認識されません。

関連する問題