Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用XSLT的XML排序问题_Xml_Xslt_Sorting - Fatal编程技术网

使用XSLT的XML排序问题

使用XSLT的XML排序问题,xml,xslt,sorting,Xml,Xslt,Sorting,我想对xml进行排序 我的xml格式是 <OTA_HotelAvailRS xmlns="http://www.opentravel.org/OTA" EchoToken="" SequenceNmbr="1" Target="Production" TimeStamp="2012-09-28T08:29:44Z" Version="1"> <SummaryResponse> <AdditionalDetails>

我想对xml进行排序

我的xml格式是

<OTA_HotelAvailRS xmlns="http://www.opentravel.org/OTA" EchoToken="" SequenceNmbr="1" Target="Production" TimeStamp="2012-09-28T08:29:44Z" Version="1">
    <SummaryResponse>    
        <AdditionalDetails>    
           <AdditionalDetail Amount="212,20 EUR" Code="TotalPackagePrice" CurrencyCode="EUR" DecPart="20" IntPart="212" Type="PackageInformation"></AdditionalDetail>
          </AdditionalDetails>

    </SummaryResponse>
    <SummaryResponse>

       <AdditionalDetails>
          <AdditionalDetail Amount="212,20 EUR" Code="TotalPackagePrice" CurrencyCode="EUR" DecPart="20" IntPart="500" Type="PackageInformation"></AdditionalDetail>
        </AdditionalDetails>
    </SummaryResponse>
</OTA_HotelAvailRS>

我使用的XSL是

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>

<xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

<xsl:template match="OTA_HotelAvailRS">
  <xsl:copy>   
    <xsl:apply-templates select="SummaryResponse/AdditionalDetails">
       <xsl:sort select="AdditionalDetail/@IntPart" data-type="number" order="descending"/>
    </xsl:apply-templates>
    Value of :<xsl:value-of select="AdditionalDetail/@IntPart" />
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

价值:
我想使用AdditionalDetail的IntPart属性进行排序


请有人帮我解决一下

这实际上不是排序问题,而是名称空间问题!在原始XML中,您指定了一个默认名称空间

<OTA_HotelAvailRS xmlns="http://www.opentravel.org/OTA" 

这实际上不是排序问题,而是名称空间问题!在原始XML中,您指定了一个默认名称空间

<OTA_HotelAvailRS xmlns="http://www.opentravel.org/OTA" 

如果您只想排序
SummaryResponse
元素,此样式表可以:


如果您只想排序
摘要响应
元素,此样式表可以:



您能给出一个您需要的输出示例吗?实际上我想要整个XMl,但只按子属性值排序…您能给出一个您需要的输出示例吗?实际上我想要整个XMl,但只按子属性值排序。。。