xsl中的if语句

时间:2019-07-12 10:49:48

标签: xslt

如果parent_item_id不包含值,则尝试仅包含以下代码行。

<xsl:value-of select="$sepstart" /><xsl:value-of select="parent_item_id"/><xsl:value-of select="$sepend" /> 

就上下文而言-这是Magento 2的销售出口。

我尝试用if语句包装它,但是我不知道自己在做什么!

<xsl:if parent_item_id= ''">
... 
</xsl:if>

如果有帮助,这是完整的代码。

<xsl:template match="/">

<xsl:text>"Merchant Identifier","Order Ref","Date","Product Search Code","Parent","Description","Customer Name","Customer Email"&#xD;&#xA;</xsl:text> <!-- This is the header line of the CSV file. It gets output once only, the &#xD;&#xA; characters represent a line break that gets output after the header line. -->

<xsl:for-each select="objects/object"> <!-- for-each means that the template will loop through the objects/object nodes in the XML processed. So for every object (order, invoice, ...) the code below will be applied. -->
<xsl:for-each select="items/item"> <!-- Loop through items ordered -->
<!-- This means, loop through all items of an object and output the following: -->
<xsl:value-of select="$sepstart" />fff<xsl:value-of select="$sepend" /> 
<xsl:value-of select="$sepstart" /><xsl:value-of select="../../increment_id"/><xsl:value-of select="$sepend" /> <!-- The $sepstart variable outputs " to start a new field in the CSV file. Then using xsl:value-of select="../../increment_id" the "increment_id" field is pulled from the object level. ../../ means to get data from the "parent" level (we are looping through items and not through objects (orders). The $sepend variable then outputs ", to denote the end of the field in the CSV file. -->
<xsl:value-of select="$sepstart" /><xsl:value-of select="../../created_at"/><xsl:value-of select="$sepend" /><!-- Order date -->
<xsl:value-of select="$sepstart" /><xsl:value-of select="product_attributes/sku"/><xsl:value-of select="$sepend" /> <!-- Get the "sku" field  -->
<xsl:value-of select="$sepstart" /><xsl:value-of select="parent_item_id"/><xsl:value-of select="$sepend" /> <!-- Get the "sku" field  -->

<xsl:value-of select="$sepstart" /><xsl:value-of select="name"/><xsl:value-of select="$sepend" /> <!-- Get the "sku" field on item level -->
<xsl:value-of select="$sepstart" /><xsl:value-of select="../../shipping/prefix"/><xsl:text> </xsl:text><xsl:value-of select="../../shipping/firstname"/><xsl:text> </xsl:text><xsl:value-of select="../../shipping/lastname"/><xsl:value-of select="$sepend" /><!-- Name (prefix, forename, surname) -->
<xsl:value-of select="$sepstart" /><xsl:value-of select="../../customer_email"/><xsl:value-of select="$sepend" /><!-- customer email -->
<xsl:text>&#xD;&#xA;</xsl:text>

</xsl:for-each> <!-- End item foreach -->



</xsl:for-each> <!-- End object foreach -->

</xsl:template>
</xsl:stylesheet>
</file>
</files>

0 个答案:

没有答案