激情欧美日韩一区二区|国产18在线播放|黄的日本免费大片|国产色在线 | 亚洲|青青操夜夜操

CHAPTER 12 DOM LEVELS 2 AND 3 DOM CHANGES 的翻譯

歡歡歡歡 發表于 2016-9-16 11:12

The purpose of the DOM Levels 2 and 3 Core is to expand the DOM API to encompass all of the requirements of XML and to provide for better error handling and feature detection. For the most part, this means supporting the concept of XML namespaces. DOM Level 2 Core doesn’t introduce any new types; it simply augments the types defined in DOM Level 1 to include new methods and properties. DOM Level 3 Core further augments the existing types and introduces several new ones.

翻譯:

DOM Levels 2 和 3的內核是為了拓展DOM API來擁抱XML的所有需求以及提供更好的錯誤處理和屬性檢測的能力。要這么做,最主要的就是支持XML的命名空間概念。DOM Level 2 Core沒有沒有引入新的類型,只是簡單的增強了DOM Level 1中已經定義的類型,讓它們包含新了的方法和屬性。DOM Level 3Core進一步增強了已經存在的類型,同時引入一些新的類型。

 

XML Namespaces

XML namespaces allow elements from different XML-based languages to be mixed together in a single, well-formed document without fear of element name clashes. Technically, XML namespaces are not supported by HTML but supported in XHTML; therefore, the examples in this section are in XHTML.

翻譯:

XML命名空間允許來自不同的基于XML的語言的元素被混編的一起,形成一個單一的,有良好結構的文檔而不用擔心元素命名沖突。單從技術上講,HTML不支持XML命名空間,XHTML才支持。因此這一章的示例都是基于XHTML。

 

The class attribute in this example is prefi xed with xhtml. Namespacing isn’t really necessary when only one XML-based language is being used in a document; it is, however, very useful when mixing two languages together. Consider the following document containing both XHTML and SVG:

翻譯:

在這個示例中,class屬性錢加一個了xhtml的前綴。當文檔中只有一種XML語言的時候,命名空間前綴真的沒有必要。然而當兩種XML余元混用的時候,它還是非常有用的。看看下面這個同時包含了XHTML和SVG的文檔:

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Example XHTML page</title>
</head>
<body>
<svg xmlns=”http://www.w3.org/2000/svg” version=”1.1”
viewBox=”0 0 100 100” style=”width:100%; height:100%”>
<rect x=”0” y=”0” width=”100” height=”100” style=”fi ll:red” />
</svg>
</body>
</html>
 
 
In this example, the element is indicated as foreign to the containing document by setting its own namespace. All children of the element, as well as all attributes of the elements, are considered to be in the http://www.w3.org/2000/svg namespace. Even though the document is technically an XHTML document, the SVG code is considered valid because of the use of namespaces.
翻譯:
在這個例子里,相對于最外圍文檔,SVG元素通過設置它自己的命名空間被分辨了出來。SVG所有的子元素以及子元素的所有屬性都被認為在命名空間http://www.w3.org/2000/svg里面。即便這個文檔技術性的被認為是XHTML,但是由于命名空間的使用,SVG的代碼也是有效的。
The interesting problem with a document such as this is what happens when a method is called on the document to interact with nodes in the document. When a new element is created, which namespace does it belong to? When querying for a specifi c tag name, what namespaces should be included in the results? DOM Level 2 Core answers these questions by providing namespace-specifi c versions of most DOM Level 1 methods.
翻譯:
有趣的問題是,在這樣的一個文檔中,當一個和文檔中節點交互的方法被調用的時候會發生什么。當一個新的元素被創建,它又屬于哪一個命名空間。當查詢指定的標簽的時候,什么命名空間應當被包含在結果里。通過提供和DOMLevel 1Core 類似的帶命名空間的方法 , DOM Level 2Core回答了這些問題。
 
DOM Level 2
localName namespaceURI prefix
 
DOM Level 3
isDefaultNamespace(namespaceURI)
lookupNamespaceURI(prefi x)
lookupPrefix(namespaceURI)
 
Changes to Document
createElementNS(namespaceURI, tagName)
createAttributeNS(namespaceURI, attributeName)
getElementsByTagNameNS(namespaceURI, tagName)
 
想學習SVG,想到之前拜讀的這本經典書籍里有提到,就先看看,畢竟對這本說已經產生了依賴感了!!!