XML concepts, constraints, and notes

Source: Internet
Author: User
Tags cdata xml parser

XML learning:
1. xml introduction and Syntax:
2. xml constraints:
DTD
Schema
3. XML parsing: (***** Focus)
XML:
What: Extensible Markup Language (Extensible Markup Language .) <Dog> </dog>
* HTML: hypertext markup language. markup language: some tags are available. <HTML> Why:
* It is used to process a large amount of related data.

Where:
* Used as the software configuration file (SSH --- all configuration files are XML)
* Used to store data (as a small database)
* Used for asynchronous system data transmission.

How:

XML Syntax:
Document declaration: (at first glance)
* Note: the location where the document declaration appears. The position of the first column in the first line of XML.
<? XML version = "1.0"?>
Version: Version 1.0 and the version attribute is required.
Encoding: Optional attribute of the sequence set
Standalone: whether other documents are required. Yes/No

<? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?>
Elements: (important)
Element: tag.
Tag Syntax:
<Span> </span>
Label nesting:
Must be correctly nested
<A> <B> </a> </B> --- incorrect
<A> <B> </B> </a> --- correct

XML must have only one tag.

Element naming rules:
* Case sensitive.
* It cannot start with a number or _.
* It cannot start with XML.
* The element name cannot contain spaces or colons.

<A> <person>...
Attribute: (important)
<Input type = "" name = ""> input: Both element (TAG) type and name are called attributes.

<Input>
<Type> </type>
<Name> </Name>
</Input>
Note: (not always)
Note: <! -- Comment content -->

* *** NOTE: Annotations cannot be nested. Annotations cannot be written before the document declaration.
Special characters and CDATA area: (it will be displayed at a Glance)
Escape characters:
<Span> 3 <5 </span>
<& Lt;
> & Gt;
& Amp;
"& Quot;
'& Apos;

CDATA zone: --- expand something: it is not considered as a tag, it is considered as a common text (string ).
<! [CDATA [think it is a common text]>

* Statement <! [CDATA []>

Processing Command (PI): (I forgot after reading it)
* <? XML-stylesheet type = "text/CSS" href = "1.css"?>

Replacing HTML with XML: XML syntax is complicated. xhmtl ---- HTML5 ---
========================================================== ========================================================== ==========================================
Develop a framework:
Configuration File: What are the advantages of a file: you do not need to modify the source code of the program.
Properties: Used as the software configuration file.
Key = value ---- format file.
Com. login. = cn. itcast. Test

XML: Used as the software configuration file.
XML can better describe the hierarchical relationship.
<Web-app>
<Servlet>
<Servlet-Name> </servlet-Name>
</Servlet>
</Web-app>

Because XML is a scalable Markup Language
<Web-app>
<Servlet>
<Cat> </CAT>
<Servlet-Name> </servlet-Name>
</Servlet>
</Web-app>

XML constraints: DTD and XML Schema (mainly understood)
(***** What are the XML constraints? What is the difference ?)

XML followed by the XML Syntax: well-formed XML.
The XML syntax is followed by the constraints document definition: Valid XML

DTD: Document Type Definition:
Use DTD to constrain XML documents. Quick Start.
To write a DTD, follow these steps:
1. What labels and quantities are required in the XML document? Six
<! Element element name element type>
2. query what type is in the XML element.
Simple or complex
3. You need to introduce DTD in XML.

The method of introducing DTD:
Internal document
<! Doctype bookshelf [
<! Element bookshelf (Book +)>
<! Element book (title, author, price, introduction)>
<! Element name (# pcdata)>
<! Element author (# pcdata)>
<! Price of element (# pcdata)>
<! Element introduction (# pcdata)>
]>
Document external
* Local
<! Doctype bookshelf System "book. DTD">
* Network
<! Doctype bookshelf public "DTD name" "DTD path">

DTD Syntax:
Element Definition
Syntax: <! Element element name element type>
Element type:
# Pcdata: parsed character data
Child element:
Empty: Empty Element
Any: Any element

Number of child elements
+: One or more times
*: Zero or multiple times
? : Zero or one
Subelement order
,: Sub-elements must appear in order.
|: The child element is in the or relationship.
Attribute definition: attribute -- attribute
Syntax: <! ATTLIST element name attribute type attribute constraint>
* <! ATTLIST Book Publishing House CDATA # required>

Property type:
CDATA: character data (string)
Enumeration: Enumeration type
ID: unique

Property constraints:
# Required: the attribute must appear.
# Implied: the attribute is optional.
# Fixed: the attribute uses a fixed value.
Default Value:
Entity Definition
Syntax: <! Entity Object Name entity value>
<! Entity bookname "sunflower Collection">
========================================================== ========================================================== ==========================================
XML programming (emphasis...) crud
XML parsing technology?
(***** What are the XML parsing technologies? What is the difference ?)
* *** XML parsing techniques are commonly used in Dom and sax.
DOM: Document Object Model. load XML into the memory at a time to form a tree structure.
Sax: Simple API for XML. You do not need to load documents to the memory at a time, read and parse documents, and use event-driven methods.

JAXP: Sun. Provided API.
1. Create an XML parser.
2. Use the parser to parse XML --- document.
3. Use document to get the nodes for the operation.

Crud.

Sax: event-driven method. parse while reading.
// Create a parser
// Processor.
* *** Dom4j: an open-source organization. (important)

XPath: nodes that facilitate XML query. dom4j supports XPath.

JDOM: open-source organization.

 

XML concepts, constraints, and notes

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.