1
나는 현재처럼 보이는 젠토 생성 된 XML 파일, 정렬하고있어
:XSL 정렬하지만, 특정 속성이 false 인 경우에만
<xsl:template match="/">
<xsl:apply-templates select="/products/product">
<xsl:sort select="populariteit" order="ascending" data-type="number"/>
</xsl:apply-templates>
</xsl:template>
: XSL의 다음 블록을 사용
<products>
<product>
<productnaam>Example item 1</productnaam>
<populariteit>27845</populariteit>
<imagelink>http://www.example.com/image1.jpg</imagelink>
</product>
<product>
<productnaam>Example item 2</productnaam>
<populariteit>12687</populariteit>
<imagelink>http://www.example.com/image1.jpg</imagelink>
</product>
<product>
<productnaam>Example item 3</productnaam>
<populariteit>32574</populariteit>
<imagelink>http://www.example.com/media/catalog/productno_selection</imagelink>
</product>
<products>
을
인기 (XML에서 "populariteit")로 항목을 정렬하고 다음 코드 블록에서 가장 인기있는 항목을 표시 할 수 있도록 목록의 첫 번째 항목을 가져옵니다.
<xsl:template match="product">
<xsl:if test="position()=1">
<xsl:value-of select="productnaam"/>
<img>
<xsl:attribute name="src">
<xsl:value-of select='imagelink'/>
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
문제는, 그 경우, <imagelink>
-attribute 항상유효한 사진입니다, 그러나, 때로는 거기입니다 : 내가 원하는 것은 목록을 정렬하는 것입니다
<imagelink>http://www.example.com/media/catalog/productno_selection</imagelink>
, 지금 내가하는 방식이지만, <imagelink>
이 위에 표시된 것과 동일한 모든 항목을 건너 뜁니다.
내가 좋아하는 일을 시도했다 :
<xsl:sort select="populariteit" order="ascending" data-type="number" test="not(imagelink = 'http://www.fietspunt.nl/media/catalog/productno_selection')">
하지만 그건 작동하지 않습니다.
위 예제에서 'Example item 3'이 가장 많이 사용되었지만 <imagelink>
-attribute가 잘못 되었기 때문에 'Example item 1'이 필요합니다.
정렬 코드를 변경하려면 어떻게해야합니까?