我想用XLST 1.0,以保持低於輸入的層次結構,但改變秩序,使termGrp
節點,其descrip
節點具有屬性@type=Bevorzugt
來在所有其他之前。如何通過複製具有特定屬性的元素首先在XSLT更改訂單1.0
在我的預期輸出中,此更改可看作術語Immatrikulationsfrist
,並在輸入文件Einschreibefrist
(原文如此)中排在Einschreibefrist
之前排序。
我認爲正確的方法是使用身份模板開始,但我不能解決如何排序,以確保首先處理具有特定屬性的元素。我看過<xsl:sort>
,但我只是在學習,我不知道如何解決這個問題,並且非常欣賞一些指針。
INPUT
<?xml version="1.0" encoding="utf-8" ?>
<mtf>
<conceptGrp>
<concept>371</concept>
<transacGrp>
<transac type="origination">
LookUp Admin
</transac>
<date>
2016-05-12T10:12:39
</date>
</transacGrp>
<transacGrp>
<transac type="modification">
LookUp Admin
</transac>
<date>
2016-05-12T10:12:39
</date>
</transacGrp>
<descripGrp>
<descrip type="Definition">The timespan during which you can enrol in a degree programme.</descrip>
</descripGrp>
<descripGrp>
<descrip type="Status">freigegeben</descrip>
</descripGrp>
<languageGrp>
<language lang="DE" type="German" />
<descripGrp>
<descrip type="Context">Nach Ablauf der Immatrikulationsfrist ist es nicht mehr möglich, sich für einen Studiengang einzuschreiben.</descrip>
</descripGrp>
<termGrp>
<term>Einschreibefrist</term>
<descripGrp>
<descrip type="Segmentation">Ein-schrei-be-frist</descrip>
</descripGrp>
<descripGrp>
<descrip type="Part of Speech">Noun</descrip>
</descripGrp>
<descripGrp>
<descrip type="Gender">f.</descrip>
</descripGrp>
<descripGrp>
<descrip type="Term Type">Variant</descrip>
</descripGrp>
<transacGrp>
<transac type="origination">
LookUp Admin
</transac>
</transacGrp>
<transacGrp>
<transac type="modification">
LookUp Admin
</transac>
</transacGrp>
</termGrp>
<termGrp>
<term>Immatrikulationsfrist</term>
<descripGrp>
<descrip type="Segmentation">Im-ma-tri-ku-la-ti-ons-frist</descrip>
</descripGrp>
<descripGrp>
<descrip type="Part of Speech">Noun</descrip>
</descripGrp>
<descripGrp>
<descrip type="Gender">f.</descrip>
</descripGrp>
<descripGrp>
<descrip type="Term Type">fullForm</descrip>
</descripGrp>
<descripGrp>
<descrip type="Bevorzugt">1</descrip>
</descripGrp>
<transacGrp>
<transac type="origination">
LookUp Admin
</transac>
</transacGrp>
<transacGrp>
<transac type="modification">
LookUp Admin
</transac>
</transacGrp>
</termGrp>
</languageGrp>
<languageGrp>
<language lang="EN" type="English" />
<descripGrp>
<descrip type="Context">Please make sure to transfer the semester fee before the enrolment deadline.</descrip>
</descripGrp>
<termGrp>
<term>enrollment deadline</term>
<descripGrp>
<descrip type="Segmentation">en-roll-ment dead-line</descrip>
</descripGrp>
<descripGrp>
<descrip type="Geographical Usage">AmE</descrip>
</descripGrp>
<descripGrp>
<descrip type="Part of Speech">Noun</descrip>
</descripGrp>
<descripGrp>
<descrip type="Term Type">fullForm</descrip>
</descripGrp>
<transacGrp>
<transac type="origination">
LookUp Admin
</transac>
</transacGrp>
<transacGrp>
<transac type="modification">
LookUp Admin
</transac>
</transacGrp>
</termGrp>
<termGrp>
<term>enrolment deadline</term>
<descripGrp>
<descrip type="Segmentation">en-rol-ment dead-line</descrip>
</descripGrp>
<descripGrp>
<descrip type="Geographical Usage">BrE</descrip>
</descripGrp>
<descripGrp>
<descrip type="Part of Speech">Noun</descrip>
</descripGrp>
<descripGrp>
<descrip type="Term Type">fullForm</descrip>
</descripGrp>
<transacGrp>
<transac type="origination">
LookUp Admin
</transac>
</transacGrp>
<transacGrp>
<transac type="modification">
LookUp Admin
</transac>
</transacGrp>
</termGrp>
</languageGrp>
</conceptGrp>
</mtf>
預期輸出
<?xml version="1.0" encoding="utf-8" ?>
<mtf>
<conceptGrp>
<concept>371</concept>
<transacGrp>
<transac type="origination">
LookUp Admin
</transac>
<date>
2016-05-12T10:12:39
</date>
</transacGrp>
<transacGrp>
<transac type="modification">
LookUp Admin
</transac>
<date>
2016-05-12T10:12:39
</date>
</transacGrp>
<descripGrp>
<descrip type="Definition">The timespan during which you can enrol in a degree programme.</descrip>
</descripGrp>
<descripGrp>
<descrip type="Status">freigegeben</descrip>
</descripGrp>
<languageGrp>
<language lang="DE" type="German" />
<descripGrp>
<descrip type="Context">Nach Ablauf der Immatrikulationsfrist ist es nicht mehr möglich, sich für einen Studiengang einzuschreiben.</descrip>
</descripGrp>
<termGrp>
<term>Immatrikulationsfrist</term>
<descripGrp>
<descrip type="Segmentation">Im-ma-tri-ku-la-ti-ons-frist</descrip>
</descripGrp>
<descripGrp>
<descrip type="Part of Speech">Noun</descrip>
</descripGrp>
<descripGrp>
<descrip type="Gender">f.</descrip>
</descripGrp>
<descripGrp>
<descrip type="Term Type">fullForm</descrip>
</descripGrp>
<descripGrp>
<descrip type="Bevorzugt">1</descrip>
</descripGrp>
<transacGrp>
<transac type="origination">
LookUp Admin
</transac>
</transacGrp>
<transacGrp>
<transac type="modification">
LookUp Admin
</transac>
</transacGrp>
</termGrp>
<termGrp>
<term>Einschreibefrist</term>
<descripGrp>
<descrip type="Segmentation">Ein-schrei-be-frist</descrip>
</descripGrp>
<descripGrp>
<descrip type="Part of Speech">Noun</descrip>
</descripGrp>
<descripGrp>
<descrip type="Gender">f.</descrip>
</descripGrp>
<descripGrp>
<descrip type="Term Type">Variant</descrip>
</descripGrp>
<transacGrp>
<transac type="origination">
LookUp Admin
</transac>
</transacGrp>
<transacGrp>
<transac type="modification">
LookUp Admin
</transac>
</transacGrp>
</termGrp>
</languageGrp>
<languageGrp>
<language lang="EN" type="English" />
<descripGrp>
<descrip type="Context">Please make sure to transfer the semester fee before the enrolment deadline.</descrip>
</descripGrp>
<termGrp>
<term>enrollment deadline</term>
<descripGrp>
<descrip type="Segmentation">en-roll-ment dead-line</descrip>
</descripGrp>
<descripGrp>
<descrip type="Geographical Usage">AmE</descrip>
</descripGrp>
<descripGrp>
<descrip type="Part of Speech">Noun</descrip>
</descripGrp>
<descripGrp>
<descrip type="Term Type">fullForm</descrip>
</descripGrp>
<transacGrp>
<transac type="origination">
LookUp Admin
</transac>
</transacGrp>
<transacGrp>
<transac type="modification">
LookUp Admin
</transac>
</transacGrp>
</termGrp>
<termGrp>
<term>enrolment deadline</term>
<descripGrp>
<descrip type="Segmentation">en-rol-ment dead-line</descrip>
</descripGrp>
<descripGrp>
<descrip type="Geographical Usage">BrE</descrip>
</descripGrp>
<descripGrp>
<descrip type="Part of Speech">Noun</descrip>
</descripGrp>
<descripGrp>
<descrip type="Term Type">fullForm</descrip>
</descripGrp>
<transacGrp>
<transac type="origination">
LookUp Admin
</transac>
</transacGrp>
<transacGrp>
<transac type="modification">
LookUp Admin
</transac>
</transacGrp>
</termGrp>
</languageGrp>
</conceptGrp>
</mtf>
在您的XML中沒有包含子元素的'term'元素。 –
謝謝你指出這個錯誤,我誤解了我的文件的結構,並錯誤地使用了這個術語。我現在編輯了我原來的文章,希望現在能夠更清晰地表達我想達到的目標 - 對不起。 – user2564684
你想要的輸出是什麼樣的? – zx485