Data Type of the top _ DTD parameter entity and schema -- zhanglong, Shengsi yuan, edited by Xuan Yu
DTD parameter entity |
Data Type |
Entity reference |
Basic Data Type |
Why schema? |
Extended Data Type |
Document Structure |
Features of Data Types |
DTD parameter entity
This entity is not used in a specific instantiation document, but is used inside the DTD document.
For example, we define an object like this:<! Entity % address "Street, city, zip code, Country">
Then, you can use"% Address ;"To reference it:<! Element Contact (person name, phone number, % address;)>
This is the concept of a parameter object.
Type |
Normal entity |
Parameter entity |
Usage |
Used in XML documents |
It is only used in the declaration of elements and attributes in the DTD. |
Statement Method |
Internal |
<! Entity entity name "text content"> |
<! Entity % entity name "text content"> |
External |
<! Entity entity name system "external File URL"> |
<! Entity % entity name system "external File URL"> |
Reference Method |
& Entity name; |
% Entity name; |
Entity reference
In fact, XML already has five built-in entities, that is, the entity reference we often call.
This is to avoid confusion between character data and some special symbols used in tags. Therefore, XML provides entity references.
Character |
Entity reference |
& |
& Amp; |
> |
& Gt; |
< |
& Lt; |
" |
& Quot; |
' |
& Apos; |
Why schema?
Limitations of DTD
1) DTD does not comply with the XML syntax (one syntax is used when writing an XML document instance, and the other syntax is used when writing a DTD)
2) The DTD data type is limited (inconsistent with the database data type)
3) The DTD cannot be expanded.
New Schema Features
1) Schema is based on XML syntax
2) The schema can be processed using a tool that can process the XML smell.
3) The schema greatly expands the data type and can customize the data type.
4) Schema supports element inheritance-object-oriented
5) Schema supports attribute groups.
Schema document structure
<? XML version = "1.0"?> <Xs: schema xmlns: xs = "http://www.w3.org/2001/XMLSchema" targetnamespace = "http: // mynamespace/mychema"> <! -- Put the actual content --> </Xs: schema>
1) <Xs: Schema: indicates that all schema documents use schema as their root element.
2) xmlns: Xs: indicates that the elements and data types used to construct the schema come from http://www.w3.org/2001/xmlschemanamespace
3) targetnamespace: indicates that the elements and data types defined in this schema belong to the http: // mynamespace/mychema namespace
Schema Data Type
Simple Type
1. built-in data types (built-in data types)
1) Basic Data Types
2) Extended Data Types
2. User-defined data types (defined by simpletype)
Complex type (defined by complextype, which is often used in WebServices and is required)
Basic Data Type
Basic Data Type |
Description |
String |
String |
Boolean |
Boolean |
Decimal |
Number representing a specific precision |
Float |
32-bit floating point number with single precision |
Double |
Double-precision 64-bit floating point number |
Duration |
Duration |
Datetime |
Represents a specific time |
Time |
It indicates a specific time, but it is repeated every day. |
Date |
Represents a date |
Hexbinary |
Hexadecimal number |
Anyuri |
Indicates a URI used to locate a file. |
Notation |
Notation type |
Extended Data Type
Extended Data Type |
Description |
ID |
Used to uniquely identify an element |
Idref |
Refer to the element or attribute of ID type |
Entity |
Entity type |
Nmtoken |
Nmtoken type |
Nmtokens |
Nmtoken type set |
Long |
Integer value. The value range is-9223372036854775808 and 9223372036854775807. |
Int |
Integer value. The value range is-2147483648 and 2147483647. |
Short |
Integer value. The value range is-32768 and 32767. |
Byte |
Integer value. The value range is-128 and 127. |
Features of Data Types
Features of Data Types |
Description |
Enumeration |
Select from the specified dataset to specify the user's selection value. |
Totaldigits |
Precisely specify the number of digits |
Fractiondigits |
Limit the maximum decimal point, used to control the precision (must be greater than or equal to zero) |
Length |
Specify the length of data, that is, precisely specify the maximum allowed characters |
Maxlength |
Maximum allowed characters |
Minlength |
Minimum Allowed characters |
Maxexclusive |
Maximum value (less than) of the specified data) |
Maxcompute sive |
Maximum Value of the specified data (less than or equal) |
Minexclusive |
Specify the minimum value (greater) |
Mininclusive |
Specify the minimum value (greater than or equal) |
Pattern |
Specify the data display specification, that is, specify the allowed value mode, similar to a regular expression |
Whitespace |
Blank processing (retain: preserve, replace: replace, merge: Collapse) |