2013-03-14 110 views
0

我有一个解组方法:方法跳过return语句

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"); 

的解组没有返回值,但它并继续运行,所以proccesDataObj是空的...

我不知道是怎么回事错...

+0

您是否调试过代码以查看哪行出错? – 2013-03-14 13:13:47

+0

是的,它创建对象数据时似乎出错 – Luc 2013-03-14 13:15:50

+0

你可能会发布资源,或者某种方式来访问它们吗?你的代码似乎没问题,所以它可能是输入问题。 – 2013-03-14 13:19:03

回答

0

您确定其他XSD文件存在于提及的位置吗?你是积极的,这个XSD方案实际上是“正确的”(例如,有预期的名称空间和其他类型)?

+0

是的,多次检查... – Luc 2013-03-14 13:06:33