• 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阿.

     或许是我真的一点都没有理解,还是现状就是如此?

     敬请高手指点...


  • 相关阅读:
    WPF DataGrid
    邮箱格式验证
    Spring Cloud微服务学习笔记
    你必须知道的MySQL知识点
    你必须掌握的分布式事务知识点
    重试操作下如何实现幂等?
    你必须掌握的关于JVM知识点
    RocketMQ开发者指南
    二分查找解题套路框架
    回溯算法解题套路框架
  • 原文地址:https://www.cnblogs.com/jingridong/p/1351066.html
Copyright © 2020-2023  润新知