使用xmlat排序xml嵌套元素

时间:2013-04-29 10:59:08

标签: xml xslt

* 亲爱的所有人, 我需要排序以下xml文档netted ul节点,每个节点包含年份的id属性,后跟月,日和标题。 *

xml document

<?xml version="1.0" ?>
<div class="css-treeview">
<ul id="2007">
                            ** id attribute  year**
<li>
<input type="checkbox" id="item-0" />
<label for="item-0" class="taxonomy">2008</label>
<ul id="2">
                            ** id attribute month** 

<li>
<input type="checkbox" id="item-0" />
<label for="item-0" class="taxonomy">2</label>
<ul id="23"> 

** id属性日**

<li>
<input type="checkbox" id="item-0" />
<label for="item-0" class="taxonomy">23</label>
<ul id="Open Office"> 

** id属性标题**

<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Office Open XML - Copy">Office Open XML - Copy</a>
</label>
<ul>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Front Matter">Front Matter</a>
</li>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/2_Table_of_Contents/topic.htm', '1', '1')" title="Table of Contents">Table of Contents</a>
</li> 
</ul>
</li>
</ul>
<ul id="Oxford XML">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="1842eab3" onclick="doContentLoad(this,'1842eab3_Office_Open_ XML/topics/1_Front_Matter/topic.htm', '1', '1')" title="Office Open XML">Office Open XML</a>
</label>
<ul>
<li>
<a class="lnkTopic" data-pid="1842eab3" onclick="doContentLoad(this,'1842eab3_Office_Open_ XML/topics/1_Front_Matter/topic.htm', '1', '1')" title="Front Matter">Front Matter</a>
</li>
<li>
<a class="lnkTopic" data-pid="1842eab3" onclick="doContentLoad(this,'1842eab3_Office_Open_ XML/topics/2_Table_of_Contents/topic.htm', '1', '1')" title="Table of Contents">Table of Contents</a>
</li>
<li>
<a class="lnkTopic" data-pid="1842eab3" onclick="doContentLoad(this,'1842eab3_Office_Open_ XML/topics/3_Scope/topic.htm', '1', '1')" title=" Scope"> Scope</a>
</li> 
</ul>
</li>
</ul>
<ul id="Office XML">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Office Open XML - Copy">Office Open XML - Copy</a>
</label>
<ul>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Front Matter">Front Matter</a>
</li>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/2_Table_of_Contents/topic.htm', '1', '1')" title="Table of Contents">Table of Contents</a>
</li>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/3_Scope/topic.htm', '1', '1')" title=" Scope"> Scope</a>
</li> 
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/pdf/Office Open XML - Copy.pdf', '1', '1')" title="Office Open XML - Copy (pdf)">Office Open XML - Copy (pdf)</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul id="10">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0" class="taxonomy">10</label>
<ul id="23">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0" class="taxonomy">23</label>
<ul id="Open Office">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Office Open XML - Copy">Office Open XML - Copy</a>
</label>
<ul>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Front Matter">Front Matter</a>
</li>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/2_Table_of_Contents/topic.htm', '1', '1')" title="Table of Contents">Table of Contents</a>
</li>
</ul>
</li>
</ul> 
</li>
</ul>
<ul id="2">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="1842eab3" onclick="doContentLoad(this,'1842eab3_Office_Open_ XML/topics/1_Front_Matter/topic.htm', '1', '1')" title="2">2</a>
</label>
<ul id="Oxford XML">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="1842eab3" onclick="doContentLoad(this,'1842eab3_Office_Open_ XML/topics/1_Front_Matter/topic.htm', '1', '1')" title="Office Open XML">Office Open XML</a>
</label>
<ul>
<li>
<a class="lnkTopic" data-pid="1842eab3" onclick="doContentLoad(this,'1842eab3_Office_Open_ XML/topics/1_Front_Matter/topic.htm', '1', '1')" title="Front Matter">Front Matter</a>
</li>
<li>
<a class="lnkTopic" data-pid="1842eab3" onclick="doContentLoad(this,'1842eab3_Office_Open_ XML/topics/2_Table_of_Contents/topic.htm', '1', '1')" title="Table of Contents">Table of Contents</a>
</li>
<li>
<a class="lnkTopic" data-pid="1842eab3" onclick="doContentLoad(this,'1842eab3_Office_Open_ XML/topics/3_Scope/topic.htm', '1', '1')" title=" Scope"> Scope</a>
</li>
</ul>
</li>
</ul>
<ul id="Office XML">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Office Open XML - Copy">Office Open XML - Copy</a>
</label>
<ul>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Front Matter">Front Matter</a>
</li>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/2_Table_of_Contents/topic.htm', '1', '1')" title="Table of Contents">Table of Contents</a>
</li>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/3_Scope/topic.htm', '1', '1')" title=" Scope"> Scope</a>
</li>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/pdf/Office Open XML - Copy.pdf', '1', '1')" title="Office Open XML - Copy (pdf)">Office Open XML - Copy (pdf)</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul id="10">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="1842eab3" onclick="doContentLoad(this,'1842eab3_Office_Open_ XML/topics/1_Front_Matter/topic.htm', '1', '1')" title="10">10</a>
</label>
<ul id="Office XML">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Office Open XML - Copy">Office Open XML - Copy</a>
</label>
<ul>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Front Matter">Front Matter</a>
</li>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/2_Table_of_Contents/topic.htm', '1', '1')" title="Table of Contents">Table of Contents</a>
</li>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/topics/3_Scope/topic.htm', '1', '1')" title=" Scope"> Scope</a>
</li>
<li>
<a class="lnkTopic" data-pid="e10ab2ab" onclick="doContentLoad(this,'e10ab2ab_Office_Open_ XML_-_Copy/pdf/Office Open XML - Copy.pdf', '1', '1')" title="Office Open XML - Copy (pdf)">Office Open XML - Copy (pdf)</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul id="2010">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0" class="taxonomy">2007</label>
<ul id="8">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0" class="taxonomy">8</label>
<ul id="20">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0" class="taxonomy">20</label>
<ul id="2c507bbd">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/1_Front_Matter/topic.htm', '1', '1')" title="Project consult newsletter en">Project consult newsletter en</a>
</label>
<ul>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/1_Front_Matter/topic.htm', '1', '1')" title="Front Matter">Front Matter</a>
</li>
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2_Enterprise_&amp;_products/topic.htm', '1', '1')" title="Enterprise &amp; products">Enterprise &amp; products</a>
</label>
<ul data-id="rootTopic">
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.1_ContentServ_introduces_version_5.0_on_the_CeBI T/topic.htm', '1', '1')" title="ContentServ introduces version 5.0 on the CeBIT">ContentServ introduces version 5.0 on the CeBIT</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.2_Easy_on_the_CeBIT/topic.htm', '1', '1')" title="Easy on the CeBIT">Easy on the CeBIT</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.3_e-Docs_takes_totally_Imaging_Solutions/topic.htm', '1', '1')" title="e-Docs takes totally Imaging Solutions">e-Docs takes totally Imaging Solutions</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.4_EMC_and_Microsoft/topic.htm', '1', '1')" title="EMC and Microsoft">EMC and Microsoft</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.5_InterRed_with_a_new_version_9.0/topic.htm', '1', '1')" title="InterRed with a new version 9.0">InterRed with a new version 9.0</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.6_Iron_Mountain__new_storage_service/topic.htm', '1', '1')" title="Iron Mountain: new storage service">Iron Mountain: new storage service</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.7_KnowledgeTree/topic.htm', '1', '1')" title="KnowledgeTree">KnowledgeTree</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.8_Microsoft_attacks_Google/topic.htm', '1', '1')" title="Microsoft attacks Google">Microsoft attacks Google</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.9_Oracle_takes_Hyperion/topic.htm', '1', '1')" title="Oracle takes Hyperion">Oracle takes Hyperion</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.10_SDL_with_new_terminology_management_solution/topic.htm', '1', '1')" title="SDL with new terminology management solution">SDL with new terminology management solution</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/2.11_TYPO3_Association_publishes_version_4.1/topic.htm', '1', '1')" title="TYPO3 Association publishes version 4.1">TYPO3 Association publishes version 4.1</a>
</li>
</ul>
</li>
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/3_In_the_discussion/topic.htm', '1', '1')" title="In the discussion">In the discussion</a>
</label>
<ul data-id="rootTopic">
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/3.1_Folksonomy,_Taxonomy_&amp;_climbing_pinch_Sear ch/topic.htm', '1', '1')" title="Folksonomy, Taxonomy &amp; climbing pinch Search">Folksonomy, Taxonomy &amp; climbing pinch Search</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/3.2_A_couple_of_new_acronyms/topic.htm', '1', '1')" title="A couple of new acronyms">A couple of new acronyms</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/3.3_Electronic_signature_-_preventive_measure/topic.htm', '1', '1')" title="Electronic signature - preventive measure">Electronic signature - preventive measure</a>
</li>
</ul>
</li>
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/4_Markets_&amp;_trends/topic.htm', '1', '1')" title="Markets &amp; trends">Markets &amp; trends</a>
</label>
<ul data-id="rootTopic">
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/4.1_Flashspeicher_&amp;_hard_disks/topic.htm', '1', '1')" title="Flashspeicher &amp; hard disks">Flashspeicher &amp; hard disks</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/4.2_Rechargeable_certificates_for_smart_cards/topic.htm', '1', '1')" title="Rechargeable certificates for smart cards">Rechargeable certificates for smart cards</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/4.3_Renaissance_of_the_microfilm_/topic.htm', '1', '1')" title="Renaissance of the microfilm?">Renaissance of the microfilm?</a>
</li>
</ul>
</li>
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/5_Fairs_&amp;_conventions/topic.htm', '1', '1')" title="Fairs &amp; conventions">Fairs &amp; conventions</a>
</label>
<ul data-id="rootTopic">
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/5.1_ECM_on_the_CeBIT_in_2007,_a_small_tour/topic.htm', '1', '1')" title="ECM on the CeBIT in 2007, a small tour">ECM on the CeBIT in 2007, a small tour</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/5.2_Silicon.de__Forum_to_information_management/topic.htm', '1', '1')" title="Silicon.de: Forum to information management">Silicon.de: Forum to information management</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/5.3_KölnMesse__DM_EXPO_IN_2007/topic.htm', '1', '1')" title="KölnMesse: DM EXPO IN 2007">KölnMesse: DM EXPO IN 2007</a>
</li>
</ul>
</li>
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/6_Norms_&amp;_standards/topic.htm', '1', '1')" title="Norms &amp; standards">Norms &amp; standards</a>
</label>
<ul data-id="rootTopic">
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/6.1_AIIM_guidelines_for_EDMS/topic.htm', '1', '1')" title="AIIM guidelines for EDMS">AIIM guidelines for EDMS</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/6.2_UN_CEFACT_common_business_Process_Catalog/topic.htm', '1', '1')" title="UN/CEFACT common business Process Catalog">UN/CEFACT common business Process Catalog</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/6.3_DIN_BELOW_EXPECTATIONS_61355/topic.htm', '1', '1')" title="DIN BELOW EXPECTATIONS 61355">DIN BELOW EXPECTATIONS 61355</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/6.4_SML_service_Modeling_Language/topic.htm', '1', '1')" title="SML service Modeling Language">SML service Modeling Language</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/6.5_UNESCO_study_of_CDs_DVDs/topic.htm', '1', '1')" title="UNESCO study of CDs/DVDs">UNESCO study of CDs/DVDs</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/6.6_UOF_universal_Object_format/topic.htm', '1', '1')" title="UOF universal Object format">UOF universal Object format</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/6.7_XDOMEA_1.0/topic.htm', '1', '1')" title="XDOMEA 1.0">XDOMEA 1.0</a>
</li>
</ul>
</li>
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/7_Right_&amp;_law/topic.htm', '1', '1')" title="Right &amp; law">Right &amp; law</a>
</label>
<ul data-id="rootTopic">
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/7.1_GDPdU__Questions_and_answers_catalog_of_Januar y_2007/topic.htm', '1', '1')" title="GDPdU: Questions and answers catalog of January 2007">GDPdU: Questions and answers catalog of January 2007</a>
</li>
</ul>
</li>
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/8_Article/topic.htm', '1', '1')" title="Article">Article</a>
</label>
<ul data-id="rootTopic">
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/8.1_The_information_management_in_the_change/topic.htm', '1', '1')" title="The information management in the change">The information management in the change</a>
</li>
</ul>
</li>
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/9_Project_management/topic.htm', '1', '1')" title="Project management">Project management</a>
</label>
<ul data-id="rootTopic">
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/9.1_Project_management_glossary/topic.htm', '1', '1')" title="Project management glossary">Project management glossary</a>
</li>
</ul>
</li>
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/10_„DTX__–_PROJECT_CONSULT_Document_Technology_Ind ex/topic.htm', '1', '1')" title="„DTX“ – PROJECT CONSULT Document Technology Index">„DTX“ – PROJECT CONSULT Document Technology Index</a>
</label>
<ul data-id="rootTopic">
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/10.1_DTX_20070329/topic.htm', '1', '1')" title="DTX 20070329">DTX 20070329</a>
</li>
</ul>
</li>
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/11_PROJECT_CONSULT_News/topic.htm', '1', '1')" title="PROJECT CONSULT News">PROJECT CONSULT News</a>
</label>
<ul data-id="rootTopic">
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/11.1_Veranstaltungen_mit_PROJECT_CONSULT/topic.htm', '1', '1')" title="Veranstaltungen mit PROJECT CONSULT">Veranstaltungen mit PROJECT CONSULT</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/11.2_CDIA+_certification_for_document_management_p rofessionals/topic.htm', '1', '1')" title="CDIA+ certification for document management professionals">CDIA+ certification for document management professionals</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/11.3_ECM_top_Ten/topic.htm', '1', '1')" title="ECM top Ten">ECM top Ten</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/11.4_Newsletter_subscriber_service/topic.htm', '1', '1')" title="Newsletter subscriber service">Newsletter subscriber service</a>
</li>
</ul>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/12_Marlene_s_web_links/topic.htm', '1', '1')" title="Marlene's web links">Marlene's web links</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/topics/13_Publication_data/topic.htm', '1', '1')" title="Publication data">Publication data</a>
</li>
<li>
<a class="lnkTopic" data-pid="2c507bbd" onclick="doContentLoad(this,'2c507bbd_Project_cons ult_newsletter_en/pdf/Project consult newsletter en.pdf', '1', '1')" title="Project consult newsletter en (pdf)">Project consult newsletter en (pdf)</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul id="7">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0" class="taxonomy">7</label>
<ul id="14">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0" class="taxonomy">14</label>
<ul id="c5e6eb7e">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="c5e6eb7e" onclick="doContentLoad(this,'c5e6eb7e_SharePointSe rver2007_ProductGuide_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="SharePointServer2007 ProductGuide - Copy">SharePointServer2007 ProductGuide - Copy</a>
</label>
<ul>
<li>
<a class="lnkTopic" data-pid="c5e6eb7e" onclick="doContentLoad(this,'c5e6eb7e_SharePointSe rver2007_ProductGuide_-_Copy/topics/1_Front_Matter/topic.htm', '1', '1')" title="Front Matter">Front Matter</a>
</li>
<li>
<a class="lnkTopic" data-pid="c5e6eb7e" onclick="doContentLoad(this,'c5e6eb7e_SharePointSe rver2007_ProductGuide_-_Copy/topics/2_Table_of_Contents/topic.htm', '1', '1')" title="Table of Contents">Table of Contents</a>
</li>
<li>
<a class="lnkTopic" data-pid="c5e6eb7e" onclick="doContentLoad(this,'c5e6eb7e_SharePointSe rver2007_ProductGuide_-_Copy/pdf/SharePointServer2007 ProductGuide - Copy.pdf', '1', '1')" title="SharePointServer2007 ProductGuide - Copy (pdf)">SharePointServer2007 ProductGuide - Copy (pdf)</a>
</li>
</ul>
</li>
</ul>

<ul id="1483f916">
<li>
<input type="checkbox" id="item-0" />
<label for="item-0">
<a class="lnkPub" data-pid="1483f916" onclick="doContentLoad(this,'1483f916_SharePointSe rver2007_ProductGuide/topics/1_Front_Matter/topic.htm', '1', '1')" title="SharePointServer2007 ProductGuide">SharePointServer2007 ProductGuide</a>
</label>
<ul>
<li>
<a class="lnkTopic" data-pid="1483f916" onclick="doContentLoad(this,'1483f916_SharePointSe rver2007_ProductGuide/topics/1_Front_Matter/topic.htm', '1', '1')" title="Front Matter">Front Matter</a>
</li>
<li>
<a class="lnkTopic" data-pid="1483f916" onclick="doContentLoad(this,'1483f916_SharePointSe rver2007_ProductGuide/topics/2_Table_of_Contents/topic.htm', '1', '1')" title="Table of Contents">Table of Contents</a>
</li>
<li>
<a class="lnkTopic" data-pid="1483f916" onclick="doContentLoad(this,'1483f916_SharePointSe rver2007_ProductGuide/pdf/SharePointServer2007 ProductGuide.pdf', '1', '1')" title="SharePointServer2007 ProductGuide (pdf)">SharePointServer2007 ProductGuide (pdf)</a>
</li>
</ul>
</li>
</ul>

</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>

我的xslt如下

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:strip-space elements="*"/>
<xsl:template match="*|@*|text()">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()" />
</xsl:copy>
</xsl:template>

<xsl:template match="div">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()">
<xsl:sort select="@id" order="descending" data-type="number"/>

</xsl:apply-templates>

</xsl:copy>
</xsl:template>

<xsl:template match="div/ul/li">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()">
<xsl:sort select="@id" order="descending" data-type="number"/>

</xsl:apply-templates>

</xsl:copy>
</xsl:template>

<xsl:template match="div/ul/li/ul/li">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()">
<xsl:sort select="@id" order="descending" data-type="number"/>

</xsl:apply-templates>

</xsl:copy>
</xsl:template>

<xsl:template match="div/ul/li/ul/li/ul/li">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()">
<xsl:sort select="@id" />

</xsl:apply-templates>

</xsl:copy>
</xsl:template>

**我能够成功地排序,但缺少高亮度的元素。你能不能让我知道我在哪里做错了

part of output** 

<div>
<ul id="2010">
<li>
<input type="checkbox" /> 
<label for="item-0" class="taxonomy">2007</label> 
<ul id="8">
<li>
<ul id="20">

1 个答案:

答案 0 :(得分:0)

您需要做的就是通过 @id 属性对父元素中的 ul 元素进行排序。

因此,您首先要将元素与 ul 元素作为子元素进行匹配

<xsl:template match="*[ul[@id]]">

在此范围内,您将首先输出任何非ul元素

然后你会输出 ul 元素,按照 @id 属性的顺序对它们进行排序

 <xsl:apply-templates select="ul">
     <xsl:sort select="number(@id)" />
     <xsl:sort select="@id" />
 </xsl:apply-templates>

试试这个XSLT

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

   <xsl:template match="*[ul[@id]]">
      <xsl:copy>
         <xsl:apply-templates select="@*|node()[not(self::ul)]"/>
         <xsl:apply-templates select="ul">
            <xsl:sort select="number(@id)" />
            <xsl:sort select="@id" />
         </xsl:apply-templates>
      </xsl:copy>
   </xsl:template>

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

此XSLT的一个问题是,如果在排序的 ul 元素之后出现任何其他元素,则它们将在排序的 ul 元素之前移动。

另一种方法是匹配第一次出现的 ul 元素

<xsl:template match="ul[@id][1]">

然后,您将选择当前元素和任何后续兄弟并对其进行排序

     <xsl:for-each select="self::ul|following-sibling::ul">
        <xsl:sort select="number(@id)" />

您需要的另一件事是与其他 ul 元素相匹配的模板,以阻止它们输出两次

<xsl:template match="ul[@id][position() > 1]" />

尝试以下XSLT,也应该给出相同的结果

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

   <xsl:template match="ul[@id][1]">
        <xsl:for-each select="self::ul|following-sibling::ul">
           <xsl:sort select="number(@id)" />
           <xsl:sort select="@id" />
           <xsl:call-template name="identity" />
        </xsl:for-each>
   </xsl:template>

      <xsl:template match="ul[@id][position() > 1]" />
      <xsl:template match="@*|node()" name="identity">
      <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
   </xsl:template>
</xsl:stylesheet>