JAXBの構文解析に苦労しており、いくつかのガイダンスが必要です。JAXB要素に属性を追加する
本質的に、@XmlElementを使用して要素として既に宣言しているクラス変数に属性を追加しようとしています。今のところ@XmlAttributeを使用しようとすると、クラスレベルで属性が設定されます。私はこれを行うにしたいと思い
<DataClass newAttribute="test">
<myElement>I wish this element had an attribute</myElement>
<anotherElement>I wish this element had an attribute too</anotherElement>
</DataClass>
:
<DataClass>
<myElement thisAtt="this is what I'm talking about">This is better</myElement>
<anotherElement thisAtt="a different attribute here">So is this</anotherElement>
</DataClass>
私が見てきた他の記事を使用して、単一の要素に属性を追加
は、私が「現在取得mはこれです@XmlValueは、要素があるときには機能しませんが、複数の要素では機能しません。
これを達成する方法について考えている人はいませんか?
ありがとうございます! ジェイソン
あなたはワットので、関連するJavaコードをポストする必要があります実際に何が起こっているか見ることができます。 –