1

アンマーシャリングを行うために次のコードを使用しています。

     @Override
public String marshal(Object document) throws JAXBException {

    Class clazz = document.getClass();
    JAXBContext context =
        JAXBContext.newInstance( clazz.getPackage().getName() );
    Marshaller marshaller = context.createMarshaller();
    marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
    StringWriter sw = new StringWriter();
    marshaller.marshal(document, sw);
    String xml = sw.toString();
    return xml;

}

結果は次のようになります。

 <IlpQuoteInput  QuoteId="2888284000185" xmlns="http://www.abc.com">
<Common IlpSellerId="0001">
    <Quotation QuotationDt="20130711"/>
    <Product CurrencyCd="E">
etc etc

それはすべて良いですが、実際には出力にxmlnsを入れたくないのですが、どうすればよいですか? ありがとうPS私はJAXBとJava 6の最新バージョンを使用しています。

4

1 に答える 1

1

あなたのマッピングでは@XmlSchema、次のようなパッケージ情報クラスにアノテーションを提供した可能性が最も高いです:

@XmlSchema(
    namespace = "http://www.abc.com",
    elementFormDefault = XmlNsForm.QUALIFIED)
package example;

import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;

XML 出力から名前空間修飾を削除するには、最初にそれを発生させるために入れたメタデータを削除するだけで済みます。

詳細については

于 2013-07-15T15:05:35.433 に答える