smooks edi到xml的多重映射模型

smooks edi到xml的多重映射模型,xml,java-ee-6,smooks,Xml,Java Ee 6,Smooks,当我只添加一个mappingmodel时,它工作得非常完美,但实际上我想添加多个mappingmodel,正如我在下面的代码中添加的那样。有人能帮忙吗?我该怎么做 Smooks-config.xml <?xml version="1.0"?> <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:edi="http://www.milyn.org/xsd/smook

当我只添加一个mappingmodel时,它工作得非常完美,但实际上我想添加多个mappingmodel,正如我在下面的代码中添加的那样。有人能帮忙吗?我该怎么做

Smooks-config.xml

<?xml version="1.0"?>
<smooks-resource-list
    xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
    xmlns:edi="http://www.milyn.org/xsd/smooks/edi-1.1.xsd">

    <edi:reader mappingModel="/example/edi-to-xml-author-full-mapping.xml" />
    <edi:reader mappingModel="/example/edi-to-xml-author-full-map.xml" /

</smooks-resource-list>

恐怕这行不通。smooks配置中只能有一个顶级EDI读取器

如果您想对配置进行模块化,那么您可以这样做,并在EDI映射模型本身中使用导入

如果需要处理不同的EDI消息,则需要使用不同的smooks实例和不同的EDI读取器映射模型配置。作为“交换”的一部分,UNEDIFACT读卡器确实支持不同的EDI消息,但这是一个不同的读卡器,特定于UNEDIFACT协议

  protected static String runSmooksTransform() throws IOException, SAXException, SmooksException {
        Locale.setDefault(new Locale("en", "IE"));


    Smooks smooks = new Smooks("smooks-config.xml");
    try {

        ExecutionContext executionContext = smooks.createExecutionContext();

        StringResult result = new StringResult();
        smooks.filterSource(executionContext, new StreamSource(new ByteArrayInputStream(messageIn)), result);

        return result.getResult();
    } finally {
        smooks.close();
    }
}