已编辑:以下附加信息
我正在尝试使用 < xsl:sort > 对图像进行升序排序,而不必使用 " position () 函数。
我在使用 < xsl:sort > 函数按升序对图像进行排序时遇到问题。
这是我链接到产品ASAMCM195265783.jpg的 XML 输入代码:
<objectImage code="ASAMSCM195265783" name="NX1000 Compact System Camera in White with 20-50mm Lens Product Image (Primary)" imageTypeName="Product Image" imageTypeCode="PRODUCT" objectTypeImageCode="PRIMARY_PRODUCT" objectTypeImageName="Primary Product Image" displayOrder="7">
<imageVersions>
<imageVersion versionTypeCode="PRODUCT_THUMB_SM" width="15" height="15" path="PRODUCT/PRODUCT_THUMB_SM/ASAMSCM195265783.jpg" link=""/>
<imageVersion versionTypeCode="PRODUCT_THUMB_M" width="32" height="32" path="PRODUCT/PRODUCT_THUMB_M/ASAMSCM195265783.jpg" link=""/>
<imageVersion versionTypeCode="PRODUCT_REGULAR" width="170" height="170" path="PRODUCT/PRODUCT_REGULAR/ASAMSCM195265783.jpg" link=""/>
<imageVersion versionTypeCode="PRODUCT_ENLARGED" width="500" height="500" path="PRODUCT/PRODUCT_ENLARGED/ASAMSCM195265783.jpg" link=""/>
<imageVersion versionTypeCode="PRODUCT_THUMB_L" width="36" height="36" path="PRODUCT/PRODUCT_THUMB_L/ASAMSCM195265783.jpg" link=""/>
<imageVersion versionTypeCode="PRODUCT_THUMB_XL" width="150" height="150" path="PRODUCT/PRODUCT_THUMB_XL/ASAMSCM195265783.jpg" link=""/>
<imageVersion versionTypeCode="PRODUCT_THUMB_110" width="110" height="110" path="PRODUCT/PRODUCT_THUMB_110/ASAMSCM195265783.jpg" link=""/>
<imageVersion versionTypeCode="PRODUCT_LARGE" width="300" height="300" path="PRODUCT/PRODUCT_LARGE/ASAMSCM195265783.jpg" link=""/>
<imageVersion versionTypeCode="PRODUCT_THUMB_50x50" width="50" height="50" path="PRODUCT/PRODUCT_THUMB_50x50/ASAMSCM195265783.jpg" link=""/>
<imageVersion versionTypeCode="PRODUCT_THUMB_75x75" width="75" height="75" path="PRODUCT/PRODUCT_THUMB_75x75/ASAMSCM195265783.jpg" link=""/>
</imageVersions>
</objectImage>
我的其他ASAMCM195265783.jpg产品的其他 XML 示例与上面完全相同,但唯一的区别是objectTypeImageCode="OTHER_PRODUCT"而不是PRIMARY_PRODUCT以及displayOrder="8"和"9"。
这是我当前的 XSLT 代码:
<xsl:sort select="displayOrder" data-type="number" order="descending"/>
<li class="prodthumbimg">
<a>
<xsl:attribute name="id">
<xsl:text>thumb</xsl:text>
<xsl:value-of select="position()" />
这是 HTML 中的结果:
<li class="prodthumbimg"><a id="thumb10" href="javascript:void(swap(9));" target=""><img src="http://www.jessops.com/ce-images/PRODUCT/PRODUCT_THUMB_50x50/ASAMSCM195265783_009.jpg" alt="Samsung NX1000 Compact System Camera in White with 20-50mm Lens" title="Samsung NX1000 Compact System Camera in White with 20-50mm Lens"></a></li>
<li class="prodthumbimg"><a id="thumb9" href="javascript:void(swap(8));" target=""><img src="http://www.jessops.com/ce-images/PRODUCT/PRODUCT_THUMB_50x50/ASAMSCM195265783.jpg" alt="Samsung NX1000 Compact System Camera in White with 20-50mm Lens" title="Samsung NX1000 Compact System Camera in White with 20-50mm Lens"></a></li>
<li class="prodthumbimg"><a id="thumb8" href="javascript:void(swap(7));" target=""><img src="http://www.jessops.com/ce-images/PRODUCT/PRODUCT_THUMB_50x50/ASAMSCM195265783_008.jpg" alt="Samsung NX1000 Compact System Camera in White with 20-50mm Lens" title="Samsung NX1000 Compact System Camera in White with 20-50mm Lens"></a></li>
请注意,在我的 HTML 结果的第二行中,产品图片ASAMCM195265783.jpg放错了位置?我试图在我的 HTML 结果的第三行中显示该图像。所以基本上需要交换第 2 行和第 3 行 html 以便产品图像的名称可以按降序正确排序。
当我使用:
<xsl:sort select="position()" data-type="number" order="descending"/>
<li class="prodthumbimg">
<a>
<xsl:attribute name="id">
<xsl:text>thumb</xsl:text>
<xsl:value-of select="position()" />
它完成了这项工作,但仅基于position()(产品的编号),我尝试根据产品名称而不是产品名称中的数字来执行此操作(如果有意义的话)。任何帮助将不胜感激,在此先感谢(如果您需要进一步澄清或任何其他问题,请让我
这是我在 HTML 中想要的结果:
<li class="prodthumbimg"><a id="thumb10" href="javascript:void(swap(9));" target=""><img src="http://www.jessops.com/ce-images/PRODUCT/PRODUCT_THUMB_50x50/ASAMSCM195265783_009.jpg" alt="Samsung NX1000 Compact System Camera in White with 20-50mm Lens" title="Samsung NX1000 Compact System Camera in White with 20-50mm Lens"></a></li>
<li class="prodthumbimg"><a id="thumb9" href="javascript:void(swap(8));" target=""><img src="http://www.jessops.com/ce-images/PRODUCT/PRODUCT_THUMB_50x50/ASAMSCM195265783_008.jpg" alt="Samsung NX1000 Compact System Camera in White with 20-50mm Lens" title="Samsung NX1000 Compact System Camera in White with 20-50mm Lens"></a></li>
<li class="prodthumbimg"><a id="thumb8" href="javascript:void(swap(7));" target=""><img src="http://www.jessops.com/ce-images/PRODUCT/PRODUCT_THUMB_50x50/ASAMSCM195265783.jpg" alt="Samsung NX1000 Compact System Camera in White with 20-50mm Lens" title="Samsung NX1000 Compact System Camera in White with 20-50mm Lens"></a></li>
如果还有其他您认为与在此处发布更相关的信息以进一步澄清此问题,请告诉我,谢谢。