很明显,我对 XML 和 XSLT 的了解相当有限。请有人可以帮助我提供一个翻译文件,该文件将允许传递以下 XML 中的每个 ItemNumber/Sales Order,以便为每个项目生成第二个 XML。换句话说,我需要生成多个输出 xml(每个销售订单一个)。目前,我只为初始 xml 上的最后一个行项目/销售订单获得一个输出 xml。
这是我需要翻译的xml:
<?xml version="1.0" encoding="Windows-1252"?>
<postsalesorderssct Language='05' Language2='EN' CssStyle='' DecFormat='1' DateFormat='01' Role='01' Version='6.1.009' OperatorPrimaryRole=' '>
<Item>
<Key>
<SalesOrder>197588</SalesOrder>
<SourceWarehouse>A3</SourceWarehouse>
<TargetWarehouse>PV</TargetWarehouse>
<CustomerPoNumber/>
</Key>
<ItemNumber>000001</ItemNumber>
</Item>
<Item>
<Key>
<SalesOrder>197589</SalesOrder>
<SourceWarehouse>A3</SourceWarehouse>
<TargetWarehouse>HI</TargetWarehouse>
<CustomerPoNumber/>
</Key>
<ItemNumber>000002</ItemNumber>
</Item>
<Item>
<Key>
<SalesOrder>197590</SalesOrder>
<SourceWarehouse>A3</SourceWarehouse>
<TargetWarehouse>WS</TargetWarehouse>
<CustomerPoNumber/>
</Key>
<ItemNumber>000003</ItemNumber>
</Item>
<Item>
<Key>
<SalesOrder>197591</SalesOrder>
<SourceWarehouse>A4</SourceWarehouse>
<TargetWarehouse>HI</TargetWarehouse>
<CustomerPoNumber/>
</Key>
<ItemNumber>000004</ItemNumber>
</Item>
<Item>
<Key>
<SalesOrder>197592</SalesOrder>
<SourceWarehouse>A4</SourceWarehouse>
<TargetWarehouse>PV</TargetWarehouse>
<CustomerPoNumber/>
</Key>
<ItemNumber>000005</ItemNumber>
</Item>
<Item>
<Key>
<SalesOrder>197593</SalesOrder>
<SourceWarehouse>A4</SourceWarehouse>
<TargetWarehouse>WS</TargetWarehouse>
<CustomerPoNumber/>
</Key>
<ItemNumber>000006</ItemNumber>
</Item>
<StatusOfItems>
<ItemsProcessed>000006</ItemsProcessed>
<ItemsInvalid>000000</ItemsInvalid>
</StatusOfItems>
</postsalesorderssct>
这是我目前使用的翻译文件:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="Windows-1252" omit-xml-declaration="yes" />
<xsl:template match="/">
<Query>
<Key>
<xsl:for-each select = "postsalesorderssct/Item/Key">
<SalesOrder><xsl:value-of select="SalesOrder"/></SalesOrder>
</xsl:for-each>
</Key>
</Query>
</xsl:template>
</xsl:stylesheet>
这是初始 xml 中每个 ItemNumbers 所需的输出。换句话说,我需要为每个销售订单号生成其中一个:
<Query xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="SORQRY.XSD">
<Key>
<SalesOrder>197588</SalesOrder>
<Invoice/>
</Key>
<Option>
<IncludeStockedLines>Y</IncludeStockedLines>
<IncludeNonStockedLines>Y</IncludeNonStockedLines>
<IncludeFreightLines>Y</IncludeFreightLines>
<IncludeMiscLines>Y</IncludeMiscLines>
<IncludeCommentLines>Y</IncludeCommentLines>
<IncludeCompletedLines>Y</IncludeCompletedLines>
<IncludeSerials>N</IncludeSerials>
<IncludeLots>Y</IncludeLots>
<IncludeBins>Y</IncludeBins>
<IncludeAttachedItems>N</IncludeAttachedItems>
<IncludeCustomForms>Y</IncludeCustomForms>
<IncludeDetailLineCustomForms>Y</IncludeDetailLineCustomForms>
<XslStylesheet/>
</Option>
</Query>
感谢你在期待。