zoukankan      html  css  js  c++  java
  • Xml的一些基本概念

    Document element (also can be called as root element) is needed for a valid xml document.

    Xml namespace is done by defining the Universal Resource Indicator (URIs) which includes Uniform Resource Locators (URL) and Uniform Resource Numbers (URN).

    There are 2 ways to define a namespace:
    1). Default namespace: define it using the xmlns attribute without a prefix. For example: <html xmlns="http://www.w3.org/1999/xhtml">
    2). Prefixed namespace: define it using the xmlns attribute with a prefix. For example: <blist:books xmlns:blist="http://www.wrox.com/books/xml">

    DTD may either be stored internally as part of the XML document or externally in a separate file, accessible via a URL.
    an internal example:

    <?xml version=”1.0” ?>
    <!-- DTD is not parsed as XML, but read by parser for validation -->
    <!DOCTYPE book [
    <!ELEMENT book (title, chapter+)>
    <!ATTLIST book author CDATA #REQUIRED>
    <!ELEMENT title (#PCDATA)>
    <!ELEMENT chapter (#PCDATA)>
    <!ATTLIST chapter id #REQUIRED>
    ]>

    Extensible Stylesheet Language Transformation (XSLT) is a language used for converting XML documents from one format to another. The two below are used mainly:
    1) Converting XML into HTML
    2) Converting XML into another XML

    Document Object Model (DOM): this API will laod the whole xml document into the RAM to do the parsing work. It is well suited for traversing and modifying an XML document, but provides little support for finding an arbitrary element or attribute. Of course it has the lower performance.

    Simple API for XML (SAX): it loads the document as a stream of data parts instead of aggregation. It's straight-forward only.

    Difference between SAX and DOM:
    1) DOM uses a parallel approach to the document, it can access several different level nodes with one method. SAX only can starting at the beginning and responding to its contents once for each node and in the order they appear in the document.
    2) DOM needs larger memory and has a lower performance. SAX needs smaller memory and has a higher performance. So if reading a very big xml document, using SAX is better.

    As DOM doesn't support well for finding an arbitrary element or attribute, XPath can help us to do the work. It is a navigational query language for locating data within an XML document.

  • 相关阅读:
    无限风光 : 近来地形算法学习小结
    上帝的天空之岛
    Layered>Variance>Shadow Map
    好事多磨:Ogre1.7 编译记
    蒙特卡罗(Monte Carlo)方法(转自百度百科)
    linux下压缩打包命令合辑
    Ubuntu Linux 环境搭建|adnroid篇
    个人知识管理(转)
    ubuntu 跳强技巧(转)
    Ubuntu Linux环境搭建|Java篇
  • 原文地址:https://www.cnblogs.com/gamix/p/569933.html
Copyright © 2011-2022 走看看