2007/08/21 | 學習XSL+CSS+XML+Javascript一點總結
类别(天天向上) | 评论(0) | 阅读(136) | 发表于 20:25

今天有點時間,到http://www.w3schools.com學習了一下XSL+XML的部分,雖然以前也有在用這些,但都是用到哪兒就零零散散的在網上找到哪兒,沒有系統的了解過,很多概念也一知半解,今天花點時間看一下也算入個門了

一: XML與HTML

      之前這兩個東西搞得有點混,認真讀了W3C的說明,才發現以前的理解一直有問題

      The Main Difference Between XML and HTML

      XML was designed to carry data.

     XML is not a replacement for HTML.
     XML and HTML were designed with different goals:

    XML was designed to describe data and to focus on what data is.
    HTML was designed to display data and to focus on how data looks.

    HTML is about displaying information, while XML is about describing information

二: XSL與CSS

     CSS = HTML Style Sheets

     HTML uses predefined tags and the meaning of the tags are well understood.

     The <table> element in HTML defines a table - and a browser knows how to display it.

     Adding styles to HTML elements is simple. Telling a browser to display an element in a special font or color, is easy with CSS. 

    XSL = XML Style Sheets

    XML does not use predefined tags (we can use any tag-names we like), and the meaning of these tags are not well understood.

    A <table> element could mean an HTML table, a piece of furniture, or something else - and a browser does not know how to display it.

    XSL describes how the XML document should be displayed!

    感覺在XSL中包含了兩部分,一個是顯示樣式,另一個是結構,,而CSS裡面大部分時間裏只是有樣式,,因為結構已經被Html Tags表述了, 其實XSL的顯示大體可以理解為HTML + CSS表述如何顯示XML數據,並且其可以通過XPath,XSLT等對XML數據進行篩選,排序,轉換等等操作,,而CSS只能顯示固定結構且不能對數據進行相關操作..

     就傳統的HTML靜態頁面而言,數據和結構是寫在一起的,然後樣式表述被分離出去為CSS文件,所以這個可以認為是兩層結構,,數據/結構層 + 樣式層,,,,而XSL+XML也是兩層,,數據層+表現層(結構+樣式),,很清楚的可以看到完全可以吧樣式繼續分離出去,這樣就成了三層 數據層+結構層+樣式層,,多了這一層出來將對我們非常便利,並且會增加很多應用

三: IE與Mozilla

    為了解決瀏覽器對XSL的支持問題,推薦需要用Javascript來輸出,但是在IE與Mozilla之間對Javascript Dom只持又是不同的,比如ActiveXObject的支持,在Mozilla核心的Browser中創建Document需要: document.implementation.createDocument("","",null),,,,而在IE核心中只需要這樣: new ActiveXObject("Microsoft.XMLDOM"),,今天碰到一個問題沒有解決,,即: transformNode的問題,,,Mozilla中只有transformToDocument和transformToFragement,,即顯示時需要綁定數據到指定ID或TagName結構上,<<Javascript高級程序設計>>中有講如何實現Mozilla中的transformNode,參考著試驗了一下,結果沒有成功,,,留待下次有時間再來了解一下如何解決這個問題

     最後給自己提個醒,技術發展的目的是:降低成本,,提高效率,,提升體驗.......

     所以要時刻保持頭腦清醒

0

评论Comments