そのようなフィールドを持つハロークラスを持つ:
private String description; // a lot of text
private long price;
private int count;
price
.. forとcount
@XmlAttribute
が使用されていることがわかりましたが、 description
. なんで?
違いは何ですか?どのように/どこに保存されますか?
そのようなフィールドを持つハロークラスを持つ:
private String description; // a lot of text
private long price;
private int count;
price
.. forとcount
@XmlAttribute
が使用されていることがわかりましたが、 description
. なんで?
違いは何ですか?どのように/どこに保存されますか?
IBMのウェブサイトの非常に良い記事
問題の情報自体が要素でマークアップできる場合は、それを要素に入れます。
情報がアトリビュート フォームに適しているが、同じ要素で同じ名前の複数のアトリビュートになる可能性がある場合は、代わりに子要素を使用します。
情報が ID、IDREF、ENTITY などの標準の DTD に似た属性タイプである必要がある場合は、属性を使用します。
情報を空白で正規化しない場合は、要素を使用します。(XML プロセッサは、属性値の生のテキストを変更できる方法で属性を正規化します。)
Both XmlElement and @XmlAttribute are quite self-documenting.
@XmlElement will be serialized as an Xml Element (Child node of the current node)
@XmlAttribute will be serialized as an Xml attribute.
knowbody's answer is quite clear about when choose one or the other.
So in your example, you should get something like
<halo price="..." count="..." >
<description>...</description>
</halo>