何時間も検索しましたが、最初の位置を最低にする例は見つかりませんでした。返される値の代わりに「False」を取得しています....
XML の例:
<?xml version="1.0"?>
<GetLowestOfferListingsForASINResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<GetLowestOfferListingsForASINResult ASIN="0470067802" status="Success">
<AllOfferListingsConsidered>false</AllOfferListingsConsidered>
<Product xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd">
<LowestOfferListings>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>Used</ItemCondition>
<ItemSubcondition>Good</ItemSubcondition>
</Qualifiers>
<Price>
<LandedPrice>
<Amount>15.71</Amount>
</LandedPrice>
</Price>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>Used</ItemCondition>
<ItemSubcondition>Good</ItemSubcondition>
</Qualifiers>
<Price>
<LandedPrice>
<Amount>16.71</Amount>
</LandedPrice>
</Price>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>Used</ItemCondition>
<ItemSubcondition>Good</ItemSubcondition>
</Qualifiers>
<Price>
<LandedPrice>
<Amount>18.71</Amount>
</LandedPrice>
</Price>
</LowestOfferListing>
</LowestOfferListings>
</Product>
</GetLowestOfferListingsForASINResult>
</GetLowestOfferListingsForASINResponse>
正しく動作しない XSLT の例:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:amz="http://mws.amazonservices.com/schema/Products/2011-10-01" exclude-result-prefixes="amz">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="MIN_Landed">
<xsl:for-each select="//Amount">
<xsl:sort data-type="number" order="ascending"/>
<xsl:if test="position()=1"><xsl:value-of select="."/></xsl:if>
</xsl:for-each>
</xsl:variable>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="" NAME="" VERSION=""/>
<DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="" RECORDS="1" TIMEFORMAT="h:mm:ss a"/>
<METADATA>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="DATA" TYPE="TEXT"/>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Min_Landed" TYPE="TEXT"/>
</METADATA>
<RESULTSET>
<xsl:attribute name="FOUND">1</xsl:attribute>
<xsl:for-each select="amz:GetLowestOfferListingsForASINResponse/amz:GetLowestOfferListingsForASINResult/amz:Product/amz:LowestOfferListings/amz:LowestOfferListing">
<ROW>
<xsl:attribute name="MODID">0</xsl:attribute>
<xsl:attribute name="RECORDID">1</xsl:attribute>
<COL>
<DATA>
<xsl:value-of select="amz:Qualifiers/amz:ItemCondition"/>
</DATA>
</COL>
<COL>
<DATA>
<xsl:value-of select="$MIN_Landed"/>
</DATA>
</COL>
</ROW>
</xsl:for-each>
</RESULTSET>
</FMPXMLRESULT>
</xsl:template>
</xsl:stylesheet>
助けてください!
私は本当に多くの Amazon コードを投稿したくありませんでしたが、ここでは必要最小限の応答に切り詰められています。
どうやら順序は重要です......
動作する XSLT の例:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:amz="http://mws.amazonservices.com/schema/Products/2011-10-01" exclude-result-prefixes="amz">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="MIN_Landed">
<xsl:for-each select="//Amount">
<xsl:sort data-type="number" order="ascending"/>
<xsl:if test="position()=1"><xsl:value-of select="."/></xsl:if>
</xsl:for-each>
</xsl:variable>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="" NAME="" VERSION=""/>
<DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="" RECORDS="1" TIMEFORMAT="h:mm:ss a"/>
<METADATA>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="DATA" TYPE="TEXT"/>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Min_Landed" TYPE="TEXT"/>
</METADATA>
<RESULTSET>
<xsl:attribute name="FOUND">1</xsl:attribute>
<xsl:for-each select="amz:GetLowestOfferListingsForASINResponse/amz:GetLowestOfferListingsForASINResult/amz:Product/amz:LowestOfferListings/amz:LowestOfferListing">
<ROW>
<xsl:attribute name="MODID">0</xsl:attribute>
<xsl:attribute name="RECORDID">1</xsl:attribute>
<COL>
<DATA>
<xsl:value-of select="$MIN_Landed"/>
</DATA>
</COL>
<COL>
<DATA>
<xsl:value-of select="amz:Qualifiers/amz:ItemCondition"/>
</DATA>
</COL>
</ROW>
</xsl:for-each>
</RESULTSET>
</FMPXMLRESULT>
</xsl:template>
</xsl:stylesheet>