<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
xmlns:mycustomprefix="urn:mycustomprefix"
exclude-result-prefixes="msxml umbraco.library mycustomprefix msxsl" >
<xsl:output method='xml' />
<msxsl:script language="JavaScript" implements-prefix="mycustomprefix">
<![CDATA[
function splitStr(str,spec,num){
return str.split(spec)[num];
}
function replace(str,spec,newSpec){
return str.replace('-','').replace(' ','')
}
]]>
</msxsl:script>
<xsl:template match='/'>
<Orders>
<TotalResults>
<!--<xsl:value-of select="responseContent/getTradeOrders/tradeTotal" />-->
</TotalResults>
<ErrCode>
<xsl:value-of select="root/error" />
</ErrCode>
<ErrMsg>
<xsl:value-of select="root/message" />
</ErrMsg>
<xsl:for-each select="root/result/response/item">
<Order>
<!--交易订单号-->
<NetShopCode>
<xsl:value-of select="order_id" />
</NetShopCode>
<!--订单状态-->
<OrderState>
<xsl:value-of select="status" />
</OrderState>
<!--订单支付时间-->
<Paytime>
<xsl:value-of select="timestamp" />
</Paytime>
<!--订单创建时间-->
<AddTime>
<xsl:value-of select="creation_time" />
</AddTime>
<!--收货人姓名-->
<Consignee>
<xsl:value-of select="receiver_infos/receiver_name" />
</Consignee>
<BuyerID>
</BuyerID>
<BuyerNick>
</BuyerNick>
<!--收货人手机号码-->
<MobilePhone>
<xsl:value-of select="receiver_infos/hp" />
</MobilePhone>
<!--收货人电话号码-->
<FixPhone>
<xsl:value-of select="receiver_infos/phone" />
</FixPhone>
<!--收货人省份-->
<xsl:variable name="province" select="mycustomprefix:splitStr(string(receiver_infos/address),'-',0)" />
<SendProvince>
<xsl:value-of select="$province" />
</SendProvince>
<!--收货人城市-->
<SendCity>
<xsl:choose>
<xsl:when test="mycustomprefix:splitStr(string(receiver_infos/address),'-',1)='市辖区'">
<xsl:variable name="addressEx" select="mycustomprefix:splitStr(string(receiver_infos/address),'-',2)" />
<xsl:value-of select="mycustomprefix:splitStr($addressEx,' ',0)" />
</xsl:when>
<xsl:when test="mycustomprefix:splitStr(string(receiver_infos/address),'-',1)!='市辖区'">
<xsl:value-of select="mycustomprefix:splitStr(string(receiver_infos/address),'-',1)" />
</xsl:when>
</xsl:choose>
</SendCity>
<District>
</District>
<!--收货人地址-->
<SendAddress>
<xsl:variable name="newAddress" select="mycustomprefix:replace(string(receiver_infos/address),'-','')" />
<xsl:value-of select="mycustomprefix:replace($newAddress,' ','')" />
</SendAddress>
<!--收货人邮编-->
<ZipCode>
<xsl:value-of select="receiver_infos/postalcode" />
</ZipCode>
<TransportMode>
</TransportMode>
<!--邮费-->
<DistributeFreight>
<xsl:value-of select="delivery_fee" />
</DistributeFreight>
<IsFreePostage>
</IsFreePostage>
<NetShop>
</NetShop>
<!--收货人备注-->
<BuyerMessage>
<!--<xsl:value-of select="receiverRemark" />-->
</BuyerMessage>
<!--订单备注-->
<SellerRemark>
<xsl:value-of select="orderRemark" />
</SellerRemark>
<SellerNick>
</SellerNick>
<!--交易类型-->
<Type>
<xsl:value-of select="orderType" />
</Type>
<OrderPayment>
<!--用户应付金额-->
</OrderPayment>
<OrderSellerPrice>
<!--订单货款金额-->
<xsl:value-of select="total_products_price"/>
</OrderSellerPrice>
<InvoiceInfo>
<!--发票信息-->
</InvoiceInfo>
<!--订单类型-->
<SaleType>
<!--<xsl:value-of select="saleType" />-->
</SaleType>
<!--商家发货地址-->
<MerchantAddress>
<!--<xsl:value-of select="merchantAddress" />-->
</MerchantAddress>
<!--商家发货时间-->
<DeliveryTime>
<!--<xsl:value-of select="deliveryTime" />-->
</DeliveryTime>
<!--包裹单号-->
<PackageCode>
<!--<xsl:value-of select="packageCode" />-->
</PackageCode>
<Reserved1>
<!--预留字段-->
</Reserved1>
<OrderProducts>
<xsl:for-each select="product_infos">
<OrderProduct>
<!--商品名称-->
<ProductName>
<xsl:value-of select="deal_short_name" />
</ProductName>
<ProductCode>
</ProductCode>
<PhotoUrl>
</PhotoUrl>
<SkuCode>
</SkuCode>
<!--商家商品SKU-->
<ApiSkuId>
<xsl:value-of select="sku_no" />
</ApiSkuId>
<!--商品价格-->
<WebRetailPrice>
<xsl:value-of select="deal_price" />
</WebRetailPrice>
<!--购买商品数量-->
<ProductNumber>
<xsl:value-of select="quantity" />
</ProductNumber>
<!--商品重量-->
<ProductWeight>
<!--<xsl:value-of select="itemWeight" />-->
</ProductWeight>
<OrderItemId>
</OrderItemId>
<!--商品属性-->
<Specifications>
<xsl:value-of select="attribute" />
</Specifications>
</OrderProduct>
</xsl:for-each>
</OrderProducts>
<Coupon>
<CouponDetail>
<NetShopCode>
</NetShopCode>
<ApiSkuId>
</ApiSkuId>
<CouponPrice>
</CouponPrice>
<CouponType>
</CouponType>
</CouponDetail>
</Coupon>
</Order>
</xsl:for-each>
</Orders>
</xsl:template>
</xsl:stylesheet>
转载于:https://www.cnblogs.com/xmyy/articles/3324999.html