當我每天在WTF上看到這篇文章時,我大聲笑了起來:http://thedailywtf.com/Articles/WellFormed-XML.aspx,但現在它不再有趣了,因爲我已經開始認識到這個「xml設計模式」頻率。舉例來說,我只是出口從Rational ClearQuest中查詢一些數據,我得到這個:xsl transform for WTF「well formed」example
<?xml version="1.0" encoding="us-ascii"?>
<?xml-stylesheet type="text/xsl" href="http://scm/rational/clearquest/webservice/resultset.xsl"?>
<resultset dbset="CQMaster" dbname="PROD" entitydefname="TR" count="1" name="_my trs">
<header count="3">
<column type="dbid">dbid</column>
<column type="id">id</column>
<column type="short_string">Abstract</column>
</header>
<record>
<field>33607697</field>
<field>PROD00011111</field>
<field>The product has a bug that needs fixed.</field>
</record>
</resultset>
我不是一個XSLT嚮導 - 我可能會想出解決辦法遲早的事情,但它不能傷害問...什麼是最簡單的XSLT樣式變換上述成這樣更有用的東西:
<?xml version="1.0" encoding="us-ascii"?>
<resultset dbset="CQMaster" dbname="PROD" entitydefname="TR" count="1" name="_my trs">
<record>
<dbid type="dbid">33607697</dbid>
<id type="id">PROD00011111</id>
<Abstract type="short_string">The product has a bug that needs fixed.</Abstract>
</record>
</resultset>
問得好(+1)。查看我的答案,獲取完整而簡短的解決方案。 :) – 2010-08-23 20:46:35