Definition Entity for DTD syntax (understand it)
- Entities are divided into general entities and parametric entities .
Defining entities: Defining variables
Referencing entities: Using variables
- General Entities : Define entities in DTDs, entity references in XML.
- parameter Entities : Define entities in the DTD, entity references in the DTD (internal DTD is not a row).
- Define General entities : <! Entity entity name solid value > reference generic solid :
- Example: <! ENTITY big Beauty "Li Bing" >
<student number = "id_1001" name = "Harry" friend= "id_1002" school= "&itcast;" />
File name: student3.xml
1 <?XML version= "1.0" encoding= "GB2312" standalone= "no"?>2 <!--Hello everyone, I'm the note. -3 <!--2015.12.29 -4 <!DOCTYPE students SYSTEM "STUDENT3.DTD">5 6 7 <Students>8 <Student Number= "id_1001"name= "Zhang San"/>9 <Student Number= "id_1002"name= "John Doe"Sex= "Male"/>Ten <Student Number= "id_1003"name= "Harry"Sex= "female"friend= "id_1002"/> One <Student Number= "id_1004"name= "&itcast;"/> A </Students>
File name: student3.dtd
<!--Hello everyone, I'm the note. -<!--2015.12.29 -<!ELEMENT Students (student+)><!ELEMENT Student EMPTY><!attlist student number ID #REQUIRED><!attlist student name CDATA #REQUIRED><!attlist Student Sex (male | famale) "Male"><!attlist student friend IDREF #IMPLIED><!ENTITY itcast "When the Fu is produced">
- Defining parameter Entities : <! Entities% Entity name "Entity value" >
Example: <! ENTITY% Big Beauty "Li Bing" >
- Reference parameter entity :
<! Attlist% BBW >
Equivalent
<! Attlist Bing >
In the actual running process, with the Cheetah browser results error:
Baidu to the result is:
The current browser has insufficient support for DTD entities and is not fully compatible with its standards.
The same code will not go wrong in IE11, but the entity will not show,
In Chrome, you'll see undefined entities,
For the entity to display correctly, the DTD must be built into the XML rather than as a separate file.
Open with IE browser, sure enough, no problem:
"Code note" XML in-depth learning: DTD constraints and DTD syntax (2)