xml笔记--xml中的术语和名字空间
时间:2007-06-13 来源:pianoch
XML:
EXtensible Markup Language;describle data;
xmlns: define xml namespace XSL:
EXtensible Stylesheet Language;describes how the XML document should be displayed;XSLT,XSL-FO XSLT:
XSLT is a language for transforming XML documents into other XML documents,like XHTML;
A xml file is linked with a xsl file, browser supporting XSLT can display the content of xml file according to the style described in xsl file, like html and css XSLT不仅仅是显示的问题,它包括转换成其他的语言。 XSL-FO:
Formally named XSL;XSL-FO is an XML-based markup language describing the formatting of XML data for output to screen, paper or other media;XSL-FO need the third software to format the xml document; XPath:
XPath is a language for finding information in an XML document. XPath is used to navigate through elements and attributes in an XML document;
The major element in the XSLT standard;
Node,Atomic Val,Item,Parent,Children,Sibling,Ancestors,Decendant,
Path Expression, which can selects a specific node, attribute, like navigate in a filesystem. A path Expression: bookstore//book XQuery:
XQuery is the language for querying XML data;
XQuery for XML is like SQL for databases;
XQuery is built on XPath expressions An example:
Xlink creating hyperlink in XML;Define namespace xmlns:xlink
XPointer allows the hyperlink to point to more specific parts in the XML; use # DTD:
Document Type Definition,like database schema
The negosiation between sending and recieve;
Verify xml document XSD:
XML Schema Definition
XML-based alternative to DTD XML DOM
The XML Document Object Model (XML DOM) defines a standard way for accessing and manipulating XML documents. 它把xml文档构造成一棵树。 关于名字空间: A namespace is a group of element and attribute names.
A namespace must be declared in the document before you can use it.
xmlns:h="http://www.w3.org/TR/html4/" is namespace declaration.
xml属性表示为<note date="12/11/2002">this is xxx.</note>
使用名字空间后
<h:table xmlns:h="http://www.w3.org/TR/html4/">
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
xmlns 为名字空间声明,h为前缀,然后为名字空间属性的URI,这个URI只是用于给名字空间一个独一无二的名字,并不会被处理xml的程序所用到。
这是自己定义一个名字空间h.
当缺省的时候,可以省略前缀如下:
<table xmlns="http://www.w3.org/TR/html4/"> XML and reserve some namaspace, you have to avoid use it as yourself namespace. 有一些保留的名字空间,避免使用。 很多时候我们要引用已经定义的名字空间,比如当我们定义xml schema的时候
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
...
...
</xs:schema>
上例子中:
xmlns:xs="http://www.w3.org/2001/XMLSchema" 使用官方定义的名字空间xs
EXtensible Markup Language;describle data;
xmlns: define xml namespace XSL:
EXtensible Stylesheet Language;describes how the XML document should be displayed;XSLT,XSL-FO XSLT:
XSLT is a language for transforming XML documents into other XML documents,like XHTML;
A xml file is linked with a xsl file, browser supporting XSLT can display the content of xml file according to the style described in xsl file, like html and css XSLT不仅仅是显示的问题,它包括转换成其他的语言。 XSL-FO:
Formally named XSL;XSL-FO is an XML-based markup language describing the formatting of XML data for output to screen, paper or other media;XSL-FO need the third software to format the xml document; XPath:
XPath is a language for finding information in an XML document. XPath is used to navigate through elements and attributes in an XML document;
The major element in the XSLT standard;
Node,Atomic Val,Item,Parent,Children,Sibling,Ancestors,Decendant,
Path Expression, which can selects a specific node, attribute, like navigate in a filesystem. A path Expression: bookstore//book XQuery:
XQuery is the language for querying XML data;
XQuery for XML is like SQL for databases;
XQuery is built on XPath expressions An example:
doc("books.xml")/bookstore/book/title
XLink and XPointerXlink creating hyperlink in XML;Define namespace xmlns:xlink
XPointer allows the hyperlink to point to more specific parts in the XML; use # DTD:
Document Type Definition,like database schema
The negosiation between sending and recieve;
Verify xml document XSD:
XML Schema Definition
XML-based alternative to DTD XML DOM
The XML Document Object Model (XML DOM) defines a standard way for accessing and manipulating XML documents. 它把xml文档构造成一棵树。 关于名字空间: A namespace is a group of element and attribute names.
A namespace must be declared in the document before you can use it.
xmlns:h="http://www.w3.org/TR/html4/" is namespace declaration.
xml属性表示为<note date="12/11/2002">this is xxx.</note>
使用名字空间后
<h:table xmlns:h="http://www.w3.org/TR/html4/">
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
xmlns 为名字空间声明,h为前缀,然后为名字空间属性的URI,这个URI只是用于给名字空间一个独一无二的名字,并不会被处理xml的程序所用到。
这是自己定义一个名字空间h.
当缺省的时候,可以省略前缀如下:
<table xmlns="http://www.w3.org/TR/html4/"> XML and reserve some namaspace, you have to avoid use it as yourself namespace. 有一些保留的名字空间,避免使用。 很多时候我们要引用已经定义的名字空间,比如当我们定义xml schema的时候
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
...
...
</xs:schema>
上例子中:
xmlns:xs="http://www.w3.org/2001/XMLSchema" 使用官方定义的名字空间xs
标记为斜体的这一段在理解上有问题
Normally, this namespace is bound to the prefix xsd or xs, although this can change as long as the URI stays the same.通常名字空间限定为前缀xsd或者xs,但前缀是可以改变的,只要URI保持一致。
再澄清关于名字空间和shema的一个误会:
名字空间由URI唯一区分;
xml可以使用一个预先定义的名字空间里的元素,而不一定要绑定一个shema;
当需要严格的验证(validation)的时候,才需要绑定schema定义;
比如说:
当我们使用soap message的时候
<SOAP-ENV:Envelope xmlns:SOAP-ENV=
"http://schemas.xmlsoap.org/soap/envelope/">
SOAP-ENV只是表明一个前缀,可以改为其他的名字;
http://schemas.xmlsoap.org/soap/envelope 不能够修改,除非是使用不同的版本;
Envelope:不能修改,他被W3C定义为soap消息的一个元素。
这样理解应该没有问题:当我们要用xml定义一个公共的协议的时候,我们定义一份schema,
你在遵循这个协议的时候,只能用到这个schema中的元素,但你可以不帮定这个schema。当你要严格验证(validation)你的应用是,才需要绑定。
相关阅读 更多 +