如何在Smooks中正确嵌套segmentGrop标签

时间:2014-02-24 08:55:40

标签: maven edi smooks edifact

我正在尝试使用Smooks(1.5版本)进行EDI到XML映射。我有5个段可能会出现几次,我想将它们放入组中,但有些错误正在上升:

Caused by: org.xml.sax.SAXParseException; cvc-complex-type.2.4.a: 
Invalid content was found starting with element 'medi:segmentGroup'. 
One of '{"http://www.milyn.org/schema/edi-message-mapping-1.0.xsd":segment}' is expected.

我的映射:

<?xml version="1.0" encoding="UTF-8"?>
<medi:edimap xmlns:medi="http://www.milyn.org/schema/edi-message-mapping-1.0.xsd">

    <medi:description name="DVD Order" version="1.0" />

    <medi:delimiters segment="'!$" field="+" component=":" sub-component="~" />
    <medi:segments xmltag="Order">




        <medi:segment segcode="BGM" xmltag="header" >
            <medi:field xmltag="order-id" />
            <medi:field xmltag="status-code" />
            <medi:field xmltag="net-amount" />
        </medi:segment>



        <medi:segment segcode="DTM" xmltag="customer-details">
            <medi:field xmltag="abc" >
                <medi:component xmltag="1"/>
                <medi:component xmltag="2"/>
                <medi:component xmltag="3"/>      
            </medi:field>
        </medi:segment>
        <medi:segment segcode="NAD" xmltag="customer-details" maxOccurs="-1">
            <medi:field xmltag="asd"></medi:field>
            <medi:field xmltag="abc" >
                <medi:component xmltag="1"/>
                <medi:component xmltag="2"/>
                <medi:component xmltag="3"/>      
            </medi:field>
        </medi:segment>

        <medi:segment xmltag="CURRENCY" segcode="CUX">
            <medi:field xmltag="1st">
                <medi:component xmltag="nth"/>
                <medi:component xmltag="currency"/>
            </medi:field>
            <medi:field xmltag="number"/>
        </medi:segment>

        **<medi:segmentGroup>**
            <medi:segment xmltag="Linia" segcode="PIA">
                <medi:field xmltag="dig"  />
                <medi:field xmltag="item"/>
                <medi:field xmltag="c">
                    <medi:component xmltag="1"/>
                    <medi:component xmltag="2"/>
                    <medi:component xmltag="3"/>
                    <medi:component xmltag="4"/>
                </medi:field>
            </medi:segment>

            <medi:segment xmltag="Linia2" segcode="PIA">
                <medi:field xmltag="item"/>
                <medi:field xmltag="c">
                    <medi:component xmltag="1"/>
                    <medi:component xmltag="2"/>
                    <medi:component xmltag="3"/>
                    <medi:component xmltag="4"/>
                </medi:field>
            </medi:segment>

            <medi:segment xmltag="prim" segcode="PRI">
                <medi:field xmltag="c">
                    <medi:component xmltag="1"/>
                    <medi:component xmltag="2"/>
                    <medi:component xmltag="3"/>
                    <medi:component xmltag="4"/>
                    <medi:component xmltag="5"/>
                    <medi:component xmltag="6"/>
                </medi:field>
            </medi:segment>
            <medi:segment xmltag="SCC" segcode="SCC" >
                <medi:field xmltag="1"/>
            </medi:segment>
            <medi:segment xmltag="QTY" segcode="QTY" >
                <medi:field xmltag="qty">
                    <medi:component xmltag="1"/>
                    <medi:component xmltag="2"/>
                    <medi:component xmltag="3"/>
                </medi:field>
            </medi:segment>
            <medi:segment xmltag="DTM" segcode="DTM">
                <medi:field xmltag="dtm">
                    <medi:component xmltag="1"/>
                    <medi:component xmltag="2"/>
                    <medi:component xmltag="3"/>
                </medi:field>
            </medi:segment>
        **</medi:segmentGroup>**
    </medi:segments>
</medi:edimap>

我阅读了关于smooks.org的文档,示例看起来很相似。也许某些导入或POM文件有问题?请帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

edi-message-mapping的版本出现问题。版本1.0不支持segmentGroups。应该看起来像:

<medi:edimap xmlns:medi="http://www.milyn.org/schema/edi-message-mapping-1.5.xsd">
相关问题