輸入XML的XML:排序使用XSLT
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
<wsse:Username>User</wsse:Username>
<wsse:Password>Password</wsse:Password>
</wsse:Security>
</soap-env:Header>
<soap-env:Body>
<soap-env:CustomerRs>
<Information>
<Identity Code="DFW">
<User LoginID="123456" />
</Identity>
<User>
<Customer Gender="Male">
<Person>
<GivenName>Tester2</GivenName>
<LastName>Tester</LastName>
</Person>
<Telephone Type="Business" InfoNo="1" SeqNo="1">
<Number Area="456" Phone="7878787" />
</Telephone>
<Info InfoNo="2" SeqNo="1">
<LastName>Wilson</LastName>
<GivenName>Kelley</GivenName>
</Info>
<Info InfoNo="4" SeqNo="1">
<LastName>Graham</LastName>
<GivenName>Tom</GivenName>
</Info>
<Info InfoNo="1" SeqNo="3">
<LastName>Fisher</LastName>
<GivenName>Elaine</GivenName>
</Info>
<Info InfoNo="1" SeqNo="2">
<LastName>Gary</LastName>
<GivenName>Jerry</GivenName>
</Info>
<Info InfoNo="1" SeqNo="1">
<LastName>Timothy</LastName>
<GivenName>Kathy</GivenName>
</Info>
<Info InfoNo="3" SeqNo="1">
<LastName>Tim</LastName>
<GivenName>Kerry</GivenName>
</Info>
<Info InfoNo="1" SeqNo="4">
<LastName>Rob</LastName>
<GivenName>Tony</GivenName>
</Info>
<Address Type="Business" InfoNo="1" SeqNo="1">
<Line1>Menands Ln</Line1>
<City>Albany</City>
</Address>
</Customer>
<Order type="S">
<Ref>ABC123</Ref>
<OrderedBy>
<Debtor code="BLABLA"></Debtor>
</OrderedBy>
<DeliveryMethod code="Barefoot"></DeliveryMethod>
<OrderLine line="1">
<Item code="QQQ123456"></Item>
<Quantity>1</Quantity>
</OrderLine>
</Order>
</User>
</Information>
</soap-env:CustomerRs>
</soap-env:Body>
</soap-env:Envelope>
期望輸出XML響應:
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
<wsse:Username>User</wsse:Username>
<wsse:Password>Password</wsse:Password>
</wsse:Security>
</soap-env:Header>
<soap-env:Body>
<soap-env:CustomerRs>
<Information>
<Identity Code="DFW">
<User LoginID="123456" />
</Identity>
<User>
<Customer Gender="Male">
<Person>
<GivenName>Tester2</GivenName>
<LastName>Tester</LastName>
</Person>
<Telephone Type="Business" InfoNo="1" SeqNo="1">
<Number Area="456" Phone="7878787" />
</Telephone>
<Info InfoNo="1" SeqNo="1">
<LastName>Timothy</LastName>
<GivenName>Kathy</GivenName>
</Info>
<Info InfoNo="1" SeqNo="2">
<LastName>Gary</LastName>
<GivenName>Jerry</GivenName>
</Info>
<Info InfoNo="1" SeqNo="3">
<LastName>Fisher</LastName>
<GivenName>Elaine</GivenName>
</Info>
<Info InfoNo="1" SeqNo="4">
<LastName>Rob</LastName>
<GivenName>Tony</GivenName>
</Info>
<Info InfoNo="2" SeqNo="1">
<LastName>Wilson</LastName>
<GivenName>Kelley</GivenName>
</Info>
<Info InfoNo="3" SeqNo="1">
<LastName>Tim</LastName>
<GivenName>Kerry</GivenName>
</Info>
<Info InfoNo="4" SeqNo="1">
<LastName>Graham</LastName>
<GivenName>Tom</GivenName>
</Info>
<Address Type="Business" InfoNo="1" SeqNo="1">
<Line1>Menands Ln</Line1>
<City>Albany</City>
</Address>
</Customer>
<Order type="S">
<Ref>ABC123</Ref>
<OrderedBy>
<Debtor code="BLABLA"></Debtor>
</OrderedBy>
<DeliveryMethod code="Barefoot"></DeliveryMethod>
<OrderLine line="1">
<Item code="QQQ123456"></Item>
<Quantity>1</Quantity>
</OrderLine>
</Order>
</User>
</Information>
</soap-env:CustomerRs>
</soap-env:Body>
</soap-env:Envelope>
我的XSLT是做轉型:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="/*[local-name()='Envelope']">
<xsl:copy>
<xsl:apply-templates select="@*|node()">
<xsl:sort select="/*[local-name()='Info']/@*[local-name()='InfoNo']" data-type="number" order="ascending" />
<xsl:sort select="/*[local-name()='Info']/@*[local-name()='SeqNo']" data-type="number" order="ascending" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
我用這個樣式表進行排序並安排,但仍然生產相同的輸入。我做錯了什麼,我無法得到答覆。