xml和xslt的界面設計

     以前一直看到網上有很多同仁在吹捧xml+xslt,說過多長多長時間,這個網頁設計模式將取代現在的html+css,但是一直很少看見有網站使用這個模式設計,最近也看了一下這個頁面設計的方法,下面是一個非常簡單的事例:

    1. xml文件:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="mysimple.xsl"?>
 <breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
- <food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories>
</food>
 <food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>
<calories>900</calories>
</food>
 <food>
<name>French Toast</name>
<price>$4.50</price>
<description>thick slices made from our homemade sourdough bread</description>
<calories>600</calories>
</food>
 <food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
<calories>950</calories>
</food>

</breakfast_menu>

 

  2. xsl文件:

<?xml version="1.0" encoding="ISO-8859-1" ?>
 <!-- Edited with XML Spy v2007 (http://www.altova.com)-->
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<body style="font-family:Arial,helvetica,sans-serif;font-size:12pt; background-color:#EEEEEE">
<xsl:for-each select="breakfast_menu/food">
 <div style="background-color:teal;color:white;padding:4px">
 <span style="font-weight:bold;color:white">
<xsl:value-of select="name" />
</span>
<xsl:value-of select="price" />
</div>
 <div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<xsl:value-of select="description" />
 <span style="font-style:italic">
<xsl:value-of select="calories" />
</span>
</div>
</xsl:for-each>
</body>

</html>

  結果是得到了,在某個程度上確實是優化了,沒有固定的html標記,可以直接將數據保存到xml文件中,但是我有了下面的疑問:

     (1). 用css來描述html只須幾個簡單的樣式(而且可以重用),而用xsl來描述xml是如此的麻煩,必要的時候還需要創建DTD描述文件,

            我還真懷疑它能撼動html+css的地位.

 

 

     (2). 那如何使用高級語言(如c#)來實現後臺的操縱? 就通過xml dom對象和xpath結合訪問或者使用xml訪問接口(SAX)來操縱?效率不是一般的low阿.

 或許是我真的一點都沒有理解,還是現狀就是如此?

 敬請高手指點...

 

 

 

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章