1
<?xml version="1.0" encoding="UTF-8"?>
<accountList>
<previousAccount>
<account>
<lastName>NASH</lastName>
<accountStatus>REMOVED</accountStatus>
<accNo>8D</accNo>
</account>
<account>
<lastName>ADOGA</lastName>
<accountStatus>REMOVED</accountStatus>
<accNo>8A</accNo>
</account>
<account>
<lastName>LUCAS</lastName>
<accountStatus>HOLD</accountStatus>
<accNo>9A</accNo>
</account>
<account>
<lastName>DONALD</lastName>
<accountStatus>HOLD</accountStatus>
<accNo>10D</accNo>
</account>
<account>
<accountStatus>HOLD</accountStatus>
<lastName>LONDON</lastName>
<accNo>10B</accNo>
</account>
</previousAccount>
<account>
<Title>Mr</Title>
<firstName>RICHARD</firstName>
<lastName>JOHN</lastName>
<city>london</city>
<accNo>5A</accNo>
</account>
<account>
<Title>Mr</Title>
<firstName>xxx</firstName>
<lastName>JOHN</lastName>
<city>London</city>
<accNo>5D</accNo>
</account>
<account>
<Title>Mr</Title>
<firstName>HEWIT</firstName>
<lastName>JOHN</lastName>
<city>LONDON</city>
<accNo>20B</accNo>
</account>
<account>
<Title>Mr</Title>
<firstName>xxx</firstName>
<lastName>JOHN</lastName>
<city>LONDON</city>
<accNo>21D</accNo>
</account>
<account>
<Title>Mr</Title>
<firstName>KEVIN</firstName>
<lastName>PETE</lastName>
<city>LONDON</city>
<accNo>5F</accNo>
</account>
</accountList>
XSLT代碼由字母數字格式從多個節點進行排序
<xsl:stylesheet version="2.0"
xsi:schemaLocation="http://www.w3.org/1999/XSL/Transform file:/C:/Users/n434947/Desktop/workspace/SonicXSLT/BA xslt page.xsd"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="text"/>
<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>
<xsl:template match="accountList">
<xsl:for-each-group select="descendant::account" group-starting-with="*[firstName != 'xxx' or lastName != preceding-sibling::*[1]/lastName]">
<xsl:sort select="accNo" data-type="number"/>
<xsl:value-of select="accNo"/>
<xsl:text> </xsl:text>
<xsl:value-of select="accountStatus"/>
<xsl:text> </xsl:text>
<xsl:value-of select="lastName"/>
<xsl:value-of select="$newline"/>
</xsl:for-each-group>
</xsl:template>
在我的要求,我得到了排序ACCNO它們是不同的nodes.I想我會做的更好的代碼解釋這不是也就是說, 爲accountList/previousAccount /帳號/ ACCNO 爲accountList /帳號/ ACCNO
我用的後裔,這是不工作的罰款,我requirement.Here我用了兩個換分別用於兩個節點和分類separtedly.Last但至少我去t按字母數字組合排序。
實際輸出
8D REMOVED NASH
8A REMOVED ADOGA
9A HOLD LUCAS
10D HOLD DONALD
10B HOLD LONDON
5A JOHN
20B JOHN
5F PETE
期待輸出
5A JOHN
5F PETE
8A REMOVED ADOGA
8D REMOVED NASH
9A HOLD LUCAS
10B HOLD LONDON
10D HOLD DONALD
20B JOHNaccNo will be in sorted manner.
的主要問題是由像圖2A的字母數字的組合時無法排序,2B,3B,3G