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.

  • 相关阅读:
    MySQL 高可用架构在业务层面的分析研究
    HDU 4983 Goffi and GCD(数论)
    Request中的方法调用
    servlet中不能没有无参构造函数
    ServletConfig、ServletContext属性遍历
    Eclipse格式化代码换行、删除空行
    Spring EL中的类操作符
    Spring集合配置
    spring EL表达式,null-safe表达式
    spring的value,null标签
  • 原文地址:https://www.cnblogs.com/gamix/p/569933.html
Copyright © 2011-2022 走看看