123456|123456777|Green|Grün
123456|123456888|Red|Rot
987654|987654333|Yellow|Gelb
在XML格式中它看起來像這樣。
<Product xmlns="http://F.FlatFileSchema1"/span>>
<Products xmlns="">/span>
<product>123456</product>/span>
<sku>/span>123456777</sku>
<parentcolour_EN>Green</parentcolour_EN>
<parentcolour_DE>/span>Grün</parentcolour_DE>/span>
</產品>/span>
<Products xmlns=""/span>>
<product>123456</product>/span>
<sku>/span>123456888</sku>
<parentcolour_EN>Red</parentcolour_EN>
<parentcolour_DE>旋轉</parentcolour_DE>/span>
</產品>/span>
<Products xmlns=""/span>>
<product>/span>987654</product>/span>
<sku>/span>987654333</sku>
<parentcolour_EN>Yellow</parentcolour_EN>
<parentcolour_DE>/span>Gelb</parentcolour_DE>/span>
</產品>/span>
</產品>/span>
目的是將其轉換為具有以下格式的xml:
<enfinity xsi:schemaLocation="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex catalog.xsd http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt dt. xsd" major="6" minor="1" family="enfinity" branch="enterprise" build="build" xmlns="http: //www. intershop.com/xml/ns/enfinity/7.0/xcs/impex" xmlns:xsi="http://www.w3. org/2001/XMLSchema-instance" xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt">
<offer sku="123456777"/span>>/span>
<custom-attributes>/span>
<custom-attribute name="parentcolour" dt。 dt="string" xml: lang="en-US">/span>Green</custom-attribute>
<custom-attribute name="parentcolour" dt。 dt="string" xml: lang="de-DE">/span>Grün</custom-attribute>
</custom-attributes>/span>
</offer>/span>
<offer sku="123456888"/span>>
<custom-attributes>/span>
<custom-attribute name="parentcolour" dt。 dt="string" xml: lang="en-US">/span>Red</custom-attribute>
<custom-attribute name="parentcolour" dt。 dt="string" xml: lang="de-DE">Rot</custom-attribute>/span>
</custom-attributes>/span>
</offer>/span>
<offer sku="123456"/span>>
<variations>/span>
<mastered-products>
< mastered-products sku="123456777" domain="MasterRepository"/>
< mastered-product sku="123456888" domain="masterRepository"/>
</mastered-products>/span>
</variations>>
</offer>/span>
<offer sku="987654333"/span>>
<custom-attributes>/span>
<custom-attribute name="parentcolour" dt。 dt="string" xml: lang="en-US">Yellow</custom-attribute>/span>
<custom-attribute name="parentcolour" dt。 dt="string" xml: lang="de-DE">Gelb</custom-attribute>/span>
</custom-attributes>/span>
</offer>/span>
<offer sku="987654"/span>>
<variations>/span>
<mastered-products>
< mastered-products sku="987654333" domain="MasterRepository"/>
</mastered-products>/span>
</variations>>
</offer>/span>
</enfinity>
正如你所看到的,所有3個skus確實出現在XML中,但是一個額外的產品也需要出現在skus的最后,即123456出現在123456777和123456888之后,987654出現在987654333之后。 到目前為止,我無法在應用Muenchian分組后顯示產品層面的變化塊。 我目前的XSL看起來是這樣的:
<xsl:styleheet version="1. 0"/span> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/span> xmlns:s0="http://F。 FlatFileSchema1" xmlns:xml="http://www.w3.org/XML/1998/namespace" exclude-result-prefixes="s0">
<xsl:output method="xml" version="1。 0" encoding="UTF-8" indent="yes"/>
<xsl: key name="groupbyproduct" match="offer" use="product"/>
<xsl:template match="/s0:Product">/span>
<enfinity xsi:schemaLocation="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex catalog.xsd http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt dt. xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www. intershop.com/xml/ns/enfinity/7.0/xcs/impex" xmlns:xml="http://www. w3.org/XML/1998/namespace" xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6. 5/core/impex-dt" major="6" minor="1" family="enfinity" branch="enterprise""build">
<xsl:for-each select="Products">
<offer sku="{sku}"/span>>
<custom-attributes>/span>
<custom-attribute name="parentcolour" dt。 dt="string" xml:lang="en-US">
<xsl:value-of select="parentcolour_EN/text()"/span>/>
</custom-attribute>
<custom-attribute name="parentcolour" dt。 dt="string" xml:lang="de-DE">
<xsl:value-of select="parentcolour_DE/text()"/span>/>
</custom-attribute>
</custom-attributes>/span>
</offer>/span>
</xsl:for-each>
<!--為每個獨特的產品創建一個組-->/span>
<xsl:for-each select="offer[ count(. | key('groupbyproduct', product)[1]) = 1]">
<offer sku="{product}">/span>
<variations>/span>
<mastered-products>
<!--為當前組的每個成員-->
<xsl:for-each select="key('groupbyproduct', product)">
< mastered-product sku="{sku}" domain="MasterRepository"/>
</xsl:for-each>
</mastered-products>/span>
</variations>>
</offer>/span>
</xsl:for-each>
</enfinity>
</xsl:template>
</xsl:styleheet>/span>
uj5u.com熱心網友回復:
鍵沒有意義,我想你想要<xsl:key name="groupbyproduct" match="Products" use="product"/>然后代替第二個for-each你想要
<!--為每個獨特的產品創建一個組 -->
<xsl:for-each select="Products[ count(. | key('groupbyproduct', product)[1]) = 1]">
<offer sku="{product}">/span>
<variations>/span>
<mastered-products>
<!--為當前組的每個成員-->
<xsl:for-each select="key('groupbyproduct', product)">
< mastered-product sku="{sku}" domain="MasterRepository"/>
</xsl:for-each>
</mastered-products>/span>
</variations>>
</offer>/span>
</xsl:for-each>/span>
至于你的評論和你想要的完整結果,看起來好像是先分組,然后在里面輸出不同的資料,應該能得到你想要的順序:
<xsl:for-each select="Products[count(. | key('groupbyproduct', product)[1]) = 1]">
<xsl:for-each select="key('groupbyproduct', product)">/span>
<offer sku="{sku}"/span>>
<custom-attributes>/span>
<custom-attribute name="parentcolour" dt。 dt="string" xml:lang="en-US">
<xsl:value-of select="parentcolour_EN/text()"/span>/>
</custom-attribute>
<custom-attribute name="parentcolour" dt。 dt="string" xml:lang="de-DE">
<xsl:value-of select="parentcolour_DE/text()"/span>/>
</custom-attribute>
</custom-attributes>/span>
</offer>/span>
</xsl:for-each>
<offer sku="{product}"/span>>
<variations>/span>
<mastered-products>
<!--為當前組的每個成員-->
<xsl:for-each select="key('groupbyproduct', product)">
< mastered-product sku="{sku}" domain="MasterRepository"/>
</xsl:for-each>
</mastered-products>/span>
</variations>>
</offer>/span>
</xsl:for-each>/span>
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/324039.html
標籤:

