XML parsing, JAXP (Java API for XML Processing)

Source: Internet
Author: User
Tags xsl

Dom, sax, and JAXP

DOM: Document Object Model

Sax: Simple API for XML

 

Is there a way for us to replace the parser without having to release it?ProgramWhat about any changes? Jaxp api can help us achieve this. sun has developed the JAXP (Java API for XML Processing) specification to block implementations by specific vendors and allow Java developers to program XML in a standard way. JAXP does not provide a new method for parsing XML, nor does it provide new functions for XML processing. It only encapsulates an abstraction layer on the parser, allows developers to access XML data by calling APIs independent from vendors.

JAXP is developed by javax. XML package and its sub-package, org. w3C. dom package and its sub-package, org. XML. A sax package and its sub-packages. in javax. XML. the parsers package defines several factory classes for loading Dom and sax implementation classes. JAXP is composed of interfaces, abstract classes, and some auxiliary classes. The parser complying with JAXP specifications implements interfaces and abstract classes. Developers only need to use JAXP APIs for programming, the underlying parser can be switched randomly.

 

 

Dom represents XML documents in the form of a node tree in the memory. Because the tree is persistent in the memory, you can navigate the nodes in the tree at any time and modify them. the disadvantage of Dom is that parsing and loading the entire document will be very slow for very large documents and will consume a lot of resources.

Sax is an event-driven API. the SAX Parser can trigger a series of events when parsing XML documents. When a tag is found, it can activate a callback method to tell the method to find a tag. sax does not store previous data, so it cannot modify XML documents. fast sax resolution and low memory requirements, which is an advantage for large documents.

 

Dom4j has many similarities with JDOM, but it is more powerful and has better performance. dom4j integrates XPath support in APIs and provides an event-based processing model for large documents. dom4j comes with a SAX Parser aelfred2, which will be used when no other parser is available.

 

 

XSL conversion XSL (Extensible Stylesheet Language)-extensible style sheet language, mainly used to convert an XML document into another document (XML document, HTML document ), and define the display appearance of the converted document. XSL actually contains three languages:

1. XSL conversion (XSL transformations, XSLT)

2. XML Path Language (XPath)

3. XSL format object.

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.