XSLT1.0组/合并/拆分

时间:2016-02-26 18:33:30

标签: xslt

  

我有一个入站xml文件,我需要拆分。

入站XML文件

<BOM>
<Header>
    <row>
        <DocDate>20160101</DocDate>
    </row>
</Header>
<Document_Lines>
    <row>
        <Vendor>V1</Vendor>
        <BaseEntry>11003</BaseEntry>
        <BaseLine>0</BaseLine>
        <BaseType>22</BaseType>
        <ItemCode>ITM00001</ItemCode>
        <Quantity>1000</Quantity>
        <Pieces>5.00000</Pieces>
    </row>
    <row>
        <Vendor>V1</Vendor>
        <BaseEntry>11003</BaseEntry>
        <BaseLine>1</BaseLine>
        <BaseType>22</BaseType>
        <ItemCode>ITM00002</ItemCode>
        <Quantity>100</Quantity>
        <Pieces>1.00000</Pieces>
    </row>
    <row>
        <Vendor>V2</Vendor>
        <BaseEntry>11004</BaseEntry>
        <BaseLine>0</BaseLine>
        <BaseType>22</BaseType>
        <ItemCode>ITM00008</ItemCode>
        <Quantity>200</Quantity>
        <Pieces>1.00000</Pieces>
    </row>
    <row>
        <Vendor>V2</Vendor>
        <BaseEntry>11004</BaseEntry>
        <BaseLine>1</BaseLine>
        <BaseType>22</BaseType>
        <ItemCode>ITM00009</ItemCode>
        <Quantity>1000</Quantity>
        <Pieces>2.00000</Pieces>
    </row>
</Document_Lines>
<BatchNumbers>
    <row>
        <BatchNumber>B0-1</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B0-2</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B0-3</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B0-4</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B0-5</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B1-1</BatchNumber>
        <Quantity>100</Quantity>
        <BaseLineNumber>1</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B2-1</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>2</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B3-1</BatchNumber>
        <Quantity>500</Quantity>
        <BaseLineNumber>3</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B3-2</BatchNumber>
        <Quantity>500</Quantity>
        <BaseLineNumber>3</BaseLineNumber>
    </row>
</BatchNumbers>

  

我需要将其拆分为两个部分,如下所示。

注意:

请查看&#34; Pieces&#34;密切地,这表明&#34; BaseLineNumber&#34;和&#34; Document_Lines / row&#34;。 在拆分段中,BaseLineNumber应始终从0开始。 &#34; BaseEntry&#34;可以用于分组,所以,我尝试使用密钥匹配,但最终失败了:(

(xsl:键名=&#34;群组&#34;匹配=&#34; / BOM / Document_Lines / row&#34;使用=&#34; BaseEntry&#34;)

预期输出:拆分1

<BOM>
<Header>
    <row>
        <Vendor>V1</Vendor>
        <DocDate>20160101</DocDate>
    </row>
</Header>
<Document_Lines>
    <row>
        <Vendor>V1</Vendor>
        <BaseEntry>11003</BaseEntry>
        <BaseLine>0</BaseLine>
        <BaseType>22</BaseType>
        <ItemCode>ITM00001</ItemCode>
        <Quantity>1000</Quantity>
        <Pieces>5.00000</Pieces>
    </row>
    <row>
        <Vendor>V1</Vendor>
        <BaseEntry>11003</BaseEntry>
        <BaseLine>1</BaseLine>
        <BaseType>22</BaseType>
        <ItemCode>ITM00002</ItemCode>
        <Quantity>100</Quantity>
        <Pieces>1.00000</Pieces>
    </row>
</Document_Lines>
<BatchNumbers>
    <row>
        <BatchNumber>B0-1</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B0-2</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B0-3</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B0-4</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B0-5</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B1-1</BatchNumber>
        <Quantity>100</Quantity>
        <BaseLineNumber>1</BaseLineNumber>
    </row>
</BatchNumbers>

预期输出:拆分2

<BOM>
<Header>
    <row>
        <Vendor>V2</Vendor>
        <DocDate>20160101</DocDate>
    </row>
</Header>
<Document_Lines>
    <row>
        <Vendor>V2</Vendor>
        <BaseEntry>11004</BaseEntry>
        <BaseLine>0</BaseLine>
        <BaseType>22</BaseType>
        <ItemCode>ITM00008</ItemCode>
        <Quantity>200</Quantity>
        <Pieces>1.00000</Pieces>
    </row>
    <row>
        <Vendor>V2</Vendor>
        <BaseEntry>11004</BaseEntry>
        <BaseLine>1</BaseLine>
        <BaseType>22</BaseType>
        <ItemCode>ITM00009</ItemCode>
        <Quantity>1000</Quantity>
        <Pieces>2.00000</Pieces>
    </row>
</Document_Lines>
<BatchNumbers>
    <row>
        <BatchNumber>B2-1</BatchNumber>
        <Quantity>200</Quantity>
        <BaseLineNumber>0</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B3-1</BatchNumber>
        <Quantity>500</Quantity>
        <BaseLineNumber>1</BaseLineNumber>
    </row>
    <row>
        <BatchNumber>B3-2</BatchNumber>
        <Quantity>500</Quantity>
        <BaseLineNumber>1</BaseLineNumber>
    </row>
</BatchNumbers>

为了达到这个目的,我做了两个步骤。看下面的输出,Step2就是我想要的,但是BaseLineNumber不正确。 我知道理解这有点复杂。我是这个网站的新手,我不知道如何直接将我的代码放在回复评论中而不是编辑。

第1步:

<BOM>
<CALL id="11003">
    <Document_Lines>
        <row>
            <BaseEntry>11003</BaseEntry>
            <BaseLine>0</BaseLine>
            <BaseType>22</BaseType>
            <ItemCode>ITM08314</ItemCode>
            <ShipDate>20160224</ShipDate>
            <Quantity>3535</Quantity>
            <U_SSAB_LMA_NPCS>5.00000</U_SSAB_LMA_NPCS>
        </row>
    </Document_Lines>
    <BatchNumbers>
        <Row>
            <BatchNumber>B0-1</BatchNumber>
            <Quantity>707</Quantity>
            <BaseLineNumber>0</BaseLineNumber>
            <U_SSAB_BA_LENGTH>10000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>6.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B0-2</BatchNumber>
            <Quantity>707</Quantity>
            <BaseLineNumber>0</BaseLineNumber>
            <U_SSAB_BA_LENGTH>10000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>6.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B0-3</BatchNumber>
            <Quantity>707</Quantity>
            <BaseLineNumber>0</BaseLineNumber>
            <U_SSAB_BA_LENGTH>10000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>6.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B0-4</BatchNumber>
            <Quantity>707</Quantity>
            <BaseLineNumber>0</BaseLineNumber>
            <U_SSAB_BA_LENGTH>10000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>6.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B0-5</BatchNumber>
            <Quantity>707</Quantity>
            <BaseLineNumber>0</BaseLineNumber>
            <U_SSAB_BA_LENGTH>10000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>6.000000</U_SSAB_BA_THCKNS>
        </Row>
    </BatchNumbers>
</CALL>
<CALL id="11003">
    <Document_Lines>
        <row>
            <BaseEntry>11003</BaseEntry>
            <BaseLine>1</BaseLine>
            <BaseType>22</BaseType>
            <ItemCode>ITM07951</ItemCode>
            <ShipDate>20160224</ShipDate>
            <Quantity>566</Quantity>
            <U_SSAB_LMA_NPCS>1.00000</U_SSAB_LMA_NPCS>
        </row>
    </Document_Lines>
    <BatchNumbers>
        <Row>
            <BatchNumber>B1-1</BatchNumber>
            <Quantity>566</Quantity>
            <BaseLineNumber>1</BaseLineNumber>
            <U_SSAB_BA_LENGTH>6000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>8.000000</U_SSAB_BA_THCKNS>
        </Row>
    </BatchNumbers>
</CALL>
<CALL id="11004">
    <Document_Lines>
        <row>
            <BaseEntry>11004</BaseEntry>
            <BaseLine>0</BaseLine>
            <BaseType>22</BaseType>
            <ItemCode>6327</ItemCode>
            <ShipDate>20160224</ShipDate>
            <Quantity>1884</Quantity>
            <U_SSAB_LMA_NPCS>1.00000</U_SSAB_LMA_NPCS>
        </row>
    </Document_Lines>
    <BatchNumbers>
        <Row>
            <BatchNumber>B2-1</BatchNumber>
            <Quantity>1884</Quantity>
            <BaseLineNumber>2</BaseLineNumber>
            <U_SSAB_BA_LENGTH>9600.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>2500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>10.000000</U_SSAB_BA_THCKNS>
        </Row>
    </BatchNumbers>
</CALL>
<CALL id="11004">
    <Document_Lines>
        <row>
            <BaseEntry>11004</BaseEntry>
            <BaseLine>1</BaseLine>
            <BaseType>22</BaseType>
            <ItemCode>2507</ItemCode>
            <ShipDate>20160224</ShipDate>
            <Quantity>4522</Quantity>
            <U_SSAB_LMA_NPCS>2.00000</U_SSAB_LMA_NPCS>
        </row>
    </Document_Lines>
    <BatchNumbers>
        <Row>
            <BatchNumber>B3-1</BatchNumber>
            <Quantity>2261</Quantity>
            <BaseLineNumber>3</BaseLineNumber>
            <U_SSAB_BA_LENGTH>9600.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>2500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>12.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B3-2</BatchNumber>
            <Quantity>2261</Quantity>
            <BaseLineNumber>3</BaseLineNumber>
            <U_SSAB_BA_LENGTH>9600.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>2500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>12.000000</U_SSAB_BA_THCKNS>
        </Row>
    </BatchNumbers>
</CALL>

第二步

<BOM>
<CALL id="11003">
    <Document_Lines>
        <row>
            <BaseEntry>11003</BaseEntry>
            <BaseLine>0</BaseLine>
            <BaseType>22</BaseType>
            <ItemCode>ITM08314</ItemCode>
            <ShipDate>20160224</ShipDate>
            <Quantity>3535</Quantity>
            <U_SSAB_LMA_NPCS>5.00000</U_SSAB_LMA_NPCS>
        </row>
        <row>
            <BaseEntry>11003</BaseEntry>
            <BaseLine>1</BaseLine>
            <BaseType>22</BaseType>
            <ItemCode>ITM07951</ItemCode>
            <ShipDate>20160224</ShipDate>
            <Quantity>566</Quantity>
            <U_SSAB_LMA_NPCS>1.00000</U_SSAB_LMA_NPCS>
        </row>
    </Document_Lines>
    <BatchNumbers>
        <Row>
            <BatchNumber>B0-1</BatchNumber>
            <Quantity>707</Quantity>
            <BaseLineNumber>0</BaseLineNumber>
            <U_SSAB_BA_LENGTH>10000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>6.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B0-2</BatchNumber>
            <Quantity>707</Quantity>
            <BaseLineNumber>0</BaseLineNumber>
            <U_SSAB_BA_LENGTH>10000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>6.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B0-3</BatchNumber>
            <Quantity>707</Quantity>
            <BaseLineNumber>0</BaseLineNumber>
            <U_SSAB_BA_LENGTH>10000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>6.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B0-4</BatchNumber>
            <Quantity>707</Quantity>
            <BaseLineNumber>0</BaseLineNumber>
            <U_SSAB_BA_LENGTH>10000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>6.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B0-5</BatchNumber>
            <Quantity>707</Quantity>
            <BaseLineNumber>0</BaseLineNumber>
            <U_SSAB_BA_LENGTH>10000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>6.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B1-1</BatchNumber>
            <Quantity>566</Quantity>
            <BaseLineNumber>1</BaseLineNumber>
            <U_SSAB_BA_LENGTH>6000.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>1500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>8.000000</U_SSAB_BA_THCKNS>
        </Row>
    </BatchNumbers>
</CALL>
<CALL id="11004">
    <Document_Lines>
        <row>
            <BaseEntry>11004</BaseEntry>
            <BaseLine>0</BaseLine>
            <BaseType>22</BaseType>
            <ItemCode>6327</ItemCode>
            <ShipDate>20160224</ShipDate>
            <Quantity>1884</Quantity>
            <U_SSAB_LMA_NPCS>1.00000</U_SSAB_LMA_NPCS>
        </row>
        <row>
            <BaseEntry>11004</BaseEntry>
            <BaseLine>1</BaseLine>
            <BaseType>22</BaseType>
            <ItemCode>2507</ItemCode>
            <ShipDate>20160224</ShipDate>
            <Quantity>4522</Quantity>
            <U_SSAB_LMA_NPCS>2.00000</U_SSAB_LMA_NPCS>
        </row>
    </Document_Lines>
    <BatchNumbers>
        <Row>
            <BatchNumber>B2-1</BatchNumber>
            <Quantity>1884</Quantity>
            <BaseLineNumber>2</BaseLineNumber>
            <U_SSAB_BA_LENGTH>9600.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>2500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>10.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B3-1</BatchNumber>
            <Quantity>2261</Quantity>
            <BaseLineNumber>3</BaseLineNumber>
            <U_SSAB_BA_LENGTH>9600.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>2500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>12.000000</U_SSAB_BA_THCKNS>
        </Row>
        <Row>
            <BatchNumber>B3-2</BatchNumber>
            <Quantity>2261</Quantity>
            <BaseLineNumber>3</BaseLineNumber>
            <U_SSAB_BA_LENGTH>9600.000000</U_SSAB_BA_LENGTH>
            <U_SSAB_BA_WIDTH>2500.000000</U_SSAB_BA_WIDTH>
            <U_SSAB_BA_THCKNS>12.000000</U_SSAB_BA_THCKNS>
        </Row>
    </BatchNumbers>
</CALL>

添加了对应上面两个步骤的xslt

第1步的XSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/BOM/BO">
    <xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="/BOM/BO/Document_Lines">
<xsl:param name="Pos" select="position()"/>
    <xsl:for-each select="row">
        <xsl:variable name="vPos1" select="position()-1"/>
        <CALL id="{BaseEntry}">
            <Document_Lines>
                <row>
                    <BaseEntry>
                        <xsl:value-of select="BaseEntry"/>
                    </BaseEntry>
                    <BaseLine>
                        <xsl:value-of select="BaseLine"/>
                    </BaseLine>
                    <BaseType>
                        <xsl:value-of select="BaseType"/>
                    </BaseType>
                    <ItemCode>
                        <xsl:value-of select="ItemCode"/>
                    </ItemCode>
                    <ShipDate>
                        <xsl:value-of select="ShipDate"/>
                    </ShipDate>
                    <Quantity>
                        <xsl:value-of select="Quantity"/>
                    </Quantity>
                    <U_SSAB_LMA_NPCS>
                        <xsl:value-of select="U_SSAB_LMA_NPCS"/>
                    </U_SSAB_LMA_NPCS>
                </row>
            </Document_Lines>
            <BatchNumbers>
                <xsl:for-each select="../../BatchNumbers/row[./BaseLineNumber=$vPos1]">
                    <Row>
                        <BaseLineNumber><xsl:value-of select="position()-1"/></BaseLineNumber>
                    </Row>
                </xsl:for-each>
            </BatchNumbers>
        </CALL>
    </xsl:for-each>
</xsl:template>

第2步的XSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="groups" match="/BOM/CALL" use="@id"/>
<xsl:template match="/BOM">
    <xsl:apply-templates select="CALL[generate-id() = generate-id(key('groups', @id))]"/>
</xsl:template>
<xsl:template match="/BOM/CALL">
    <CALL id="{@id}">
        <Document_Lines>
            <xsl:for-each select="key('groups', @id)">
                <xsl:copy-of select="Document_Lines/*"/>
            </xsl:for-each>
        </Document_Lines>
        <BatchNumbers>
            <xsl:for-each select="key('groups', @id)">
                <xsl:copy-of select="BatchNumbers/*"/>
            </xsl:for-each>
        </BatchNumbers>
    </CALL>
</xsl:template>

最后,正如你在这里看到的,我分两步完成,实际上我想在一个.xsl中执行此操作,并且必须更正BaseLineNumber。

TCP/IP

1 个答案:

答案 0 :(得分:0)

我猜你想做这样的事情:

XSLT 1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:key name="row-by-BaseEntry" match="Document_Lines/row" use="BaseEntry" />

<xsl:template match="/BOM">
    <root>
        <xsl:for-each select="Document_Lines/row[count(. | key('row-by-BaseEntry', BaseEntry)[1]) = 1]">
            <xsl:variable name="curr-group" select="key('row-by-BaseEntry', BaseEntry)" />
            <output num="{position()}">
                <BOM>
                    <Header>
                        <row>
                            <xsl:copy-of select="Vendor"/>
                            <xsl:copy-of select="/BOM/Header/row/DocDate"/>
                        </row>
                    </Header>
                    <Document_Lines>
                        <xsl:copy-of select="$curr-group"/>
                    </Document_Lines>
                    <BatchNumbers>
                        <xsl:for-each select="$curr-group">
                            <xsl:variable name="start" select="sum(preceding-sibling::row/Pieces) + 1" />
                            <xsl:variable name="end" select="$start + Pieces" />
                            <xsl:copy-of select="/BOM/BatchNumbers/row[position() >= $start and position() &lt; $end]"/>                            
                        </xsl:for-each>
                    </BatchNumbers>
                </BOM>
            </output>
        </xsl:for-each>
    </root>
</xsl:template>

</xsl:stylesheet>

这会为每个不同的BaseEntry创建一个组,并根据组中每个成员中Pieces的计数将批处理行分配给该组。

应用于您的输入示例,结果将是:

<?xml version="1.0" encoding="UTF-8"?>
<root>
   <output num="1">
      <BOM>
         <Header>
            <row>
               <Vendor>V1</Vendor>
               <DocDate>20160101</DocDate>
            </row>
         </Header>
         <Document_Lines>
            <row>
               <Vendor>V1</Vendor>
               <BaseEntry>11003</BaseEntry>
               <BaseLine>0</BaseLine>
               <BaseType>22</BaseType>
               <ItemCode>ITM00001</ItemCode>
               <Quantity>1000</Quantity>
               <Pieces>5.00000</Pieces>
            </row>
            <row>
               <Vendor>V1</Vendor>
               <BaseEntry>11003</BaseEntry>
               <BaseLine>1</BaseLine>
               <BaseType>22</BaseType>
               <ItemCode>ITM00002</ItemCode>
               <Quantity>100</Quantity>
               <Pieces>1.00000</Pieces>
            </row>
         </Document_Lines>
         <BatchNumbers>
            <row>
               <BatchNumber>B0-1</BatchNumber>
               <Quantity>200</Quantity>
               <BaseLineNumber>0</BaseLineNumber>
            </row>
            <row>
               <BatchNumber>B0-2</BatchNumber>
               <Quantity>200</Quantity>
               <BaseLineNumber>0</BaseLineNumber>
            </row>
            <row>
               <BatchNumber>B0-3</BatchNumber>
               <Quantity>200</Quantity>
               <BaseLineNumber>0</BaseLineNumber>
            </row>
            <row>
               <BatchNumber>B0-4</BatchNumber>
               <Quantity>200</Quantity>
               <BaseLineNumber>0</BaseLineNumber>
            </row>
            <row>
               <BatchNumber>B0-5</BatchNumber>
               <Quantity>200</Quantity>
               <BaseLineNumber>0</BaseLineNumber>
            </row>
            <row>
               <BatchNumber>B1-1</BatchNumber>
               <Quantity>100</Quantity>
               <BaseLineNumber>1</BaseLineNumber>
            </row>
         </BatchNumbers>
      </BOM>
   </output>
   <output num="2">
      <BOM>
         <Header>
            <row>
               <Vendor>V2</Vendor>
               <DocDate>20160101</DocDate>
            </row>
         </Header>
         <Document_Lines>
            <row>
               <Vendor>V2</Vendor>
               <BaseEntry>11004</BaseEntry>
               <BaseLine>0</BaseLine>
               <BaseType>22</BaseType>
               <ItemCode>ITM00008</ItemCode>
               <Quantity>200</Quantity>
               <Pieces>1.00000</Pieces>
            </row>
            <row>
               <Vendor>V2</Vendor>
               <BaseEntry>11004</BaseEntry>
               <BaseLine>1</BaseLine>
               <BaseType>22</BaseType>
               <ItemCode>ITM00009</ItemCode>
               <Quantity>1000</Quantity>
               <Pieces>2.00000</Pieces>
            </row>
         </Document_Lines>
         <BatchNumbers>
            <row>
               <BatchNumber>B2-1</BatchNumber>
               <Quantity>200</Quantity>
               <BaseLineNumber>2</BaseLineNumber>
            </row>
            <row>
               <BatchNumber>B3-1</BatchNumber>
               <Quantity>500</Quantity>
               <BaseLineNumber>3</BaseLineNumber>
            </row>
            <row>
               <BatchNumber>B3-2</BatchNumber>
               <Quantity>500</Quantity>
               <BaseLineNumber>3</BaseLineNumber>
            </row>
         </BatchNumbers>
      </BOM>
   </output>
</root>

恐怕我不理解有关BaseLineNumber的要求。

如果您需要将结果拆分为单独的文档,我建议您单独询问相关问题(并确保解释您正在使用的处理器)。