0

私はアンマーシャルメソッドを持っています:

public static Object unmarshalXmlTo0100(String xmlMsg, String destination, String resource) throws Exception {
    //init unmarshaller
    ByteArrayInputStream input = new ByteArrayInputStream(xmlMsg.getBytes());
    JAXBContext context = JAXBContext.newInstance(destination);
    Unmarshaller unmarshaller = context.createUnmarshaller();

    //init schema
    SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = schemaFactory.newSchema(XmlParser.class.getClassLoader().getResource(resource));
    unmarshaller.setSchema(schema);

    //unmarschal
    Object data = unmarshaller.unmarshal(input);

    //return message
    return data;
 }

何らかの理由で、以下を使用してメソッドを呼び出すと、次のようになります。

processDataObj = MainXMLParser.unmarshalXmlTo0100(processData, "cp.jaxb.planningBericht.classes", "source/xml/cp_md_format_planningBericht.xsd");

すべてうまくいきます。

しかし、私が以下を使用するとき:

processDataObj = MainXMLParser.unmarshalXmlTo0100(processData, "cp.jaxb.beschikbaarheidBericht.classes", "source/xml/cp_md_format_beschikbaarheidBericht.xsd");

unmarshallerは何も返しませんが、実行を継続するため、proccesDataObjは空です...

何が悪いのかわかりません...

4

1 に答える 1

0

上記の場所に他の XSD ファイルが存在しますか? この XSD スキームが実際に「正しい」(たとえば、名前空間やその他のタイプが想定されている) ことを確信していますか?

于 2013-03-14T13:04:24.107 に答える