"Code note" XML in-depth learning: DTD constraints and DTD syntax (2)

Source: Internet
Author: User

Definition Entity for DTD syntax (understand it)

    1. Entities are divided into general entities and parametric entities .

Defining entities: Defining variables

Referencing entities: Using variables

    1. General Entities : Define entities in DTDs, entity references in XML.
    2. parameter Entities : Define entities in the DTD, entity references in the DTD (internal DTD is not a row).
    3. 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">
    1. Defining parameter Entities : <! Entities% Entity name "Entity value" >

Example: <! ENTITY% Big Beauty "Li Bing" >

    1. 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)

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.