下面的XSL样式会生成带有自闭标签的空值。 我需要空标签来生成常规的结束标记,就像在html
中一样我尝试将xsl:output方法更改为html。没有成功。
错误:< tag />
我想:<标签> < / tag>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="{{encoding}}" cdata-section-elements="{{cdata_section_elements}}" />
<xsl:param name="country"/>
<xsl:param name="language"/>
<xsl:param name="locale"/>
<xsl:param name="time"/>
<xsl:param name="date"/>
<xsl:param name="date_time"/>
<xsl:param name="currency"/>
<xsl:param name="file_url"/>
<xsl:template name="media_gallery">
<xsl:param name="element_name" />
<xsl:for-each select="multi_attributes">
<xsl:for-each select="media_gallery/image">
<xsl:element name="{$element_name}"><xsl:value-of select="value"/></xsl:element>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="basic_attributes">
<xsl:for-each select="attributes">
<xsl:for-each select="*">
<xsl:call-template name="copy"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="categories">
<xsl:param name="element_name" />
<xsl:for-each select="multi_attributes">
<xsl:for-each select="categories/category">
<xsl:element name="{$element_name}"><xsl:value-of select="name"/></xsl:element>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="copy">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template name="custom_attributes">
<xsl:for-each select="custom_attributes/attribute">
<xsl:element name="{tag}"><xsl:value-of select="value"/></xsl:element>
</xsl:for-each>
</xsl:template>
<xsl:variable name="mainTag"><xsl:text>products</xsl:text></xsl:variable>
<xsl:variable name="itemTag"><xsl:text>product</xsl:text></xsl:variable>
<xsl:template match="/">
<xsl:element name="{$mainTag}">
<xsl:for-each select="/items/item">
<xsl:for-each select="parent|child">
<xsl:element name="{$itemTag}">
<xsl:call-template name="basic_attributes"/>
<xsl:call-template name="custom_attributes"/>
</xsl:element>
</xsl:for-each>
</xsl:for-each>
</xsl:element>
</xsl:template>
<nscdoc>
<common>
<encoding>utf-8</encoding>
<decimal_delimiter>.</decimal_delimiter>
<price_format>standard</price_format>
<datetime_format>standard</datetime_format>
<category_path_delimiter> > </category_path_delimiter>
<link_to_specification>http://www.kieskeurig.nl/document/B9A4D86D505D49709F9319BADC54D987</link_to_specification>
<allow_custom_attributes>1</allow_custom_attributes>
<stock>
<yes>1</yes>
<no>0</no>
<availability></availability>
</stock>
</common>
<attributes>
<attribute>
<code>id</code>
<magento>id</magento>
</attribute>
<attribute>
<code>productgroep</code>
<magento>category_path</magento>
</attribute>
<attribute>
<code>merk</code>
<magento>manufacturer</magento>
</attribute>
<attribute>
<code>type</code>
<magento>model</magento>
</attribute>
<attribute>
<code>toevoeging-type</code>
<magento></magento>
</attribute>
<attribute>
<code>extra-productbeschrijving</code>
<magento>short_description</magento>
<postproc>cdata</postproc>
</attribute>
<attribute>
<code>partnumber</code>
<magento>sku</magento>
</attribute>
<attribute>
<code>ean-code</code>
<magento>ean</magento>
</attribute>
<attribute>
<code>prijs</code>
<magento>price_final_include_tax</magento>
</attribute>
<attribute>
<code>verzendkosten</code>
<magento>shipping_method_price</magento>
</attribute>
<attribute>
<code>afhaalkosten</code>
<magento></magento>
</attribute>
<attribute>
<code>levertijd</code>
<magento>delivery_time</magento>
</attribute>
<attribute>
<code>deeplink</code>
<magento>url</magento>
</attribute>
<attribute>
<code>imagelink</code>
<magento>image</magento>
</attribute>
<attribute>
<code>voorraad</code>
<magento>stock_status</magento>
</attribute>
</attributes>
</nscdoc>
</xsl:stylesheet>