Java and XML

Source: Internet
Author: User
Tags object cdata interface object model xsl
Xml

JAXP api--Embedding different interpreters

Sax Interpreter +dom Interpreter +xsl Converter

class for loading XML documents in Javax.xml.parsers:
Documentbuilder
Documentbuildrfactory
SAXParser
SAXParserFactory
=====================================
SAX API

XML interpreter for sax: Apache Xerces or crimson

Interfaces for processing XML documents:
ContentHandler
Entityresolver
Errohandler
Dtdhandler

Declhandler
Lexicalhandler
======================================
DOM API

Two DOM standards: DOM Level1 DOM Level 2 Core

Node
The root of the node-node type interface hierarchy.
Root of document-tree structure
Element-xml element
text within the text-element
Attributes of attr-elements
CDATA Sectionn-cdata
Nodelist-a collection of child nodes
processinginstruction-directives
comment-information that contains comments
Documentfragment-document, for moving nodes in a tree
documenttype-a subset of the document type definition.
Entity tags in entity-dtd
Entityreference-xml entity references in a document
Symbol marks in NOTATION-DTD


There are basically three ways to read an X M L document from a program:
1 read the X M L as a single file and then pick out the label yourself. This is the hacker's method, we do not recommend this way.
You will soon find that dealing with all the special situations (including different character encodings, exception conventions, internal and external entities, lack of provincial nature, etc.) is much more difficult than imagined;
You may not be able to handle all the special situations correctly, so your program receives a very canonical X M L document, but does not handle it correctly.
To avoid this idea: XML parsers don't seem expensive (most are free).
2 You can parse the document with the parser and create a tree-like expression of the contents of the document in memory: The parser passes output to the Document Object model, the DOM.
This allows the program to begin traversing from the top of the tree, using a reference from one tree unit to another to find the information needed.
3 can also use the parser to read the document, when the parser found the label to tell the program it found the label.
For example, it tells when a start tag was found, when some feature data was found, and when an end tag was found.
This is called an event-driven interface, because the parser informs the application of the meaningful events it encounters.
If this is the kind of interface you need, you can use sax.

Sax is read-only
The DOM can read documents from the original XML file, or you can create and modify documents in memory. In contrast, sax is used to read XML documents instead of writing documents.

Extensible Style Language (xsl,extensible sytlesheet Language) is an xml-based language,
It is designed to transform an XML document into another XML document or to convert an XML document into a Translatable object.
The original XSL language has been split into three different languages:
The 1 conversion tool (XSLT) is a language that transforms XML documents into other XML documents
2 Translation tools (xslf-can include the use of x S lt)
3XML Hierarchical Command processing tool (XPath)
XSL has its own root, whether in cascading style sheets (CSS) or in a language called DSSSL (document style semantics and specification language-read ' Deessel ').
As it develops, XSL's style performance becomes closer to CSS and away from Dsssl


This article is not of much use



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.