smooks edi 到 xml 的多重映射模型

Multiple mapping model for smooks edi to xml

当我只添加一个映射模型时,它工作得很好,但实际上我想添加多个映射模型,因为我已经添加到以下代码中。有人可以帮忙吗我该怎么做。

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>

Test.java

  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();
    }
}

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

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

如果您需要处理不同的 EDI 消息,那么您需要使用具有不同 EDI reader 映射模型配置的不同 smooks 实例。 UNEDIFACT reader 确实支持不同的 EDI 消息作为 "exchange" 的一部分,但这是不同的 reader 并且特定于 UNEDIFACT 协议。