jaxb を使用 して、この xsd定義で XML ファイルをアンマーシャルしたいと考えています。
Eclipse の右クリック、jaxb クラスの生成などを使用して Java クラスを生成しました。XML ファイルのアンマーシャリングに問題はありません。
問題は、MetadataType をマーシャリング (マップ?) する方法がわからないことです。以下は、metadataType と生成されたクラスの xsd 定義です。
<complexType name="metadataType">
<annotation>
<documentation>Metadata must be expressed in XML that complies
with another XML Schema (namespace=#other). Metadata must be
explicitly qualified in the response.</documentation>
</annotation>
<sequence>
<any namespace="##other" processContents="strict"/>
</sequence>
</complexType>
このタイプの生成されたクラスは次のとおりです。
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.11.08 at 05:28:26 PM PST
//
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlType;
/**
* Metadata must be expressed in XML that complies
* with another XML Schema (namespace=#other). Metadata must be
* explicitly qualified in the response.
*
* <p>Java class for metadataType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="metadataType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <any namespace='##other'/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "metadataType", propOrder = {
"any"
})
public class MetadataType {
@XmlAnyElement(lax = true)
protected Object any;
/**
* Gets the value of the any property.
*
* @return
* possible object is
* {@link Object }
*
*/
public Object getAny() {
return any;
}
/**
* Sets the value of the any property.
*
* @param value
* allowed object is
* {@link Object }
*
*/
public void setAny(Object value) {
this.any = value;
}
}
の外部 xsd はこちら
整列化されていない XML ドキュメントは、次のように生成します。
アップデート:
また、外部xsdからクラスを生成しました:
OaiDcType.java ElementType.java
これらのクラスには、MetadataType オブジェクトのデータが含まれている必要があります。
自分の OaiDcType オブジェクトに変換したいのですが、これを行う正しい/最良の方法はどれですか?