我試圖使用XSLT將XML轉換爲XML。輸出XML應該根據輸入XML中的ModificationTime元素進行排序。 以下是xml代碼。使用XSLT進行排序後將XML轉換爲XML
<?xml version="1.0" encoding="UTF-8"?>
<Process>
<currentDayAndHour>@Fri16</currentDayAndHour>
<!-- Few elements here. Need to retain them -->
<rowCount>1</rowCount>
<currentRow>1</currentRow>
<ClientList>
<Status>0</Status>
<ServerResponse>
<Code>0</Code>
<Text>OK</Text>
</ServerResponse>
<ServiceStartTime>2012-11-09 16:06:42.786</ServiceStartTime>
<ServiceEndTime>2012-11-09 16:06:42.827</ServiceEndTime>
<Files>
<File>
<Name>test.20121107215230411.txt</Name>
<Size>29</Size>
<Type>Regular</Type>
<Permissions>-rw-r--r--</Permissions>
<ModificationTime>1352343152</ModificationTime>
<Owner>19737</Owner>
<Group>70902</Group>
</File>
<File>
<Name>test.20121107183757513.txt</Name>
<Size>29</Size>
<Type>Regular</Type>
<Permissions>-rw-r--r--</Permissions>
<ModificationTime>1352331478</ModificationTime>
<Owner>19737</Owner>
<Group>70902</Group>
</File>
<File>
<Name>test1.20121107215230500.txt</Name>
<Size>32</Size>
<Type>Regular</Type>
<Permissions>-rw-r--r--</Permissions>
<ModificationTime>1352343152</ModificationTime>
<Owner>19737</Owner>
<Group>70902</Group>
</File>
<File>
<Name>test1.txt</Name>
<Size>32</Size>
<Type>Regular</Type>
<Permissions>-rw-r--r--</Permissions>
<ModificationTime>1352323788</ModificationTime>
<Owner>65174</Owner>
<Group>75431</Group>
</File>
<File>
<Name>HMP_test.txt</Name>
<Size>28</Size>
<Type>Regular</Type>
<Permissions>-rw-r--r--</Permissions>
<ModificationTime>1352199478</ModificationTime>
<Owner>19737</Owner>
<Group>70902</Group>
</File>
<File>
<Name>test1.20121107183757585.txt</Name>
<Size>32</Size>
<Type>Regular</Type>
<Permissions>-rw-r--r--</Permissions>
<ModificationTime>1352331478</ModificationTime>
<Owner>19737</Owner>
<Group>70902</Group>
</File>
<File>
<Name>client_access.20121108101411179.txt</Name>
<Size>4182</Size>
<Type>Regular</Type>
<Permissions>-rw-r--r--</Permissions>
<ModificationTime>1352387653</ModificationTime>
<Owner>19737</Owner>
<Group>70902</Group>
</File>
<File>
<Name>TechMtngAgenda.txt</Name>
<Size>107</Size>
<Type>Regular</Type>
<Permissions>-rw-r--r--</Permissions>
<ModificationTime>1352044842</ModificationTime>
<Owner>19737</Owner>
<Group>70902</Group>
</File>
<File>
<Name>test.txt</Name>
<Size>29</Size>
<Type>Regular</Type>
<Permissions>-rw-r--r--</Permissions>
<ModificationTime>1350063313</ModificationTime>
<Owner>19737</Owner>
<Group>70902</Group>
</File>
</Files>
</ClientList>
<currentDocument>1</currentDocument>
</Process>
我需要輸出XML與所有輸入元素,但文件標記應該包含每個文件以增加的順序ModificationTime。我對XSLT很陌生。我嘗試使用xsl:sort,但無法獲得所需的結果。
的'except'運營商僅在XPath 2.0中可用 - 這是,在XSLT 2.0中。請改正。 –
感謝您的支持。 – nine9ths
另外,它會更好(更可讀和更高效):'not(self :: File)'而不是'not(name()='File')' –