Simple XML tutorial 3

Source: Internet
Author: User
Now you know the future of XML. Indeed, the structure is a bit complex, and DTD has various options for defining the content that a document can contain. But not more. Consider an industry that is important to data exchange, such as a bank. Bank app all

The future of XML
Now you know the XML. Indeed, the structure is a bit complex, and DTD has various options for defining the content that a document can contain. But not more.

Consider an industry that is important to data exchange, such as a bank. Banks use ownership systems to track internal transactions, but if they apply a general XML pattern on the Web, then they must describe the transaction information to another institution or the exploitation procedure (such as Quicken or MS Money ). Of course, they can also present data on web pages. FYI: This tag does not exist. It is called OFEX and the Open Financial Exchange pattern ).

In some cases, if IE 4 on the PC encounters Identifier. a function is started to update installed software. If you are using Windows 98, you may have seen this situation, but you do not know that it is an XML exploitation program.

Here we have three XML exploitation programs, which look different from the addition machine, typewriter, and pencil that Andy Grove saw in 1970s. However, similar to the exploitation program that ultimately appears on a PC, the benefits of XML can be generally described as: "When you use human and machine-readable tags to describe your data, there will be good things."

What are these good things? I don't know. But I don't know what the next generation of programs on my PC will look like. As long as the data is marked with this method, different exploitation can be produced.

Have you considered how much it will expand?

We have a lot of practical use of XML to talk about, and I will talk about them in the near future. Since we are all netizens, we will be XSL (extended Style Language-eXtensible Style Language) in the future.

By the way, this recipe is indeed from my mom, and it is very good. If you use it, add half a cup of shredded coconut.


I wrote this article because I really care about your opinions on me. I am worried: If you have read the XML introduction I have written and are ready to start writing your own XML documents. So you start to look for a created DTD to express your information. You can find one, as shown below:

 

% Attr. lang;

Value CDATA # FIXED 'text'>

Img. type CDATA # REQUIRED

Img. data ENTITY # required'>


Immediately you will think that Jay must be an idiot. He didn't say anything about ATTLIST and ENTITY-no matter what they are.

So let's talk about it with a little patience.

The above rows may not look good, but actually there is nothing. They are used in DTD to define attributes and entities in XML documents. People who know HTML will understand this. An attribute is an entry with an HTML tag to more accurately describe the tag. Frequently rendered attributes include height and width. As you will see later, the application attributes in XML documents are similar.

There is nothing new to the entity. If you have used &, you have mastered the most basic things. A string enclosed by a semicolon (&) is used to represent another character or a set of characters. (A complete list of ISO entities is provided here .)

Of course, attributes and entities in XML have other functions. This inevitably requires the introduction of syntax, though not too many. Once you understand this, you will not have to bother using XML documents.

Simplified recipes

If you read the XML introduction I wrote, you will remember the components in the recipe represented by a simple identifier, such 2 cups flour . After writing that article, I traveled online and found another XML document about recipes. The recipe elements are as follows:


Flour

This method has an actual benefit: data can be easily controlled. In the first method, A token is used to hold a bunch of different information. If I want to extract the list of components without the quantity of each component, I will not do that.

I can use the following structure to achieve a similar effect:


Flour

2

Cups


This can be processed, but there are two headers: first, the item element contains a mixture of text and other tokens. I soon invented a structure that should be avoided as much as possible. The second is that the token has almost no meaning of independence. It is hard to imagine that as long as units is not the actual composition. These entries can be briefly described. I prefer to treat them as attributes.

Attribute names must be noted first. quantity and units are meaningful only when they are processed by the exploitation program that can be translated.

Before being included in a valid document, notify the DTD to promise it. For the above ingredient element, we only include the following code in the DTD:

 


The first line looks familiar-the definition of the scale element that can be seen in any DTD. Each ATTLIST row contains the following information in sequence:


This is an element of attribute attachment.

The attribute name is defined here.

Set the attribute type here. CDATA indicates character data. This means that the processor can get text in the attribute.

The last part defines the default value of the attribute. You can apply the actual value, such as 3. In this way, the attribute value of the vacancy length in XML is 3. The input value will overwrite the default value.

In the above example, I didn't set a specific number, but applied the keyword # REQUIRED of XML. It tells the processor that the secondary attribute must contain a value. Documents will not be processed if they are vacant.

The default value has two other key words. The first one is # FIXED-if the attribute value remains the same in all documents. Assume that I define an image tag attribute. all images are of the same size. for example, 100*50 pixels can be defined in the DTD as follows:


 

Another keyword is # IMPLIED, which indicates that the attribute can contain values or be empty.

Next let's take a look at the attribute type.

If you decide to write your own DTD, you may need a book that describes all the XML combinations in the ATTLIST statement. However, if you borrow a DTD, you may only know the nature of CDATA and the other three attributes.

The first one is ID. The value of its request attribute is not repeated in the document. Anyone who has applied the database knows the necessity of a unique identifier. The dtd attlist statement looks like this:

It is hard to imagine that there is no ID attribute type with the default value of # REQUIRED. In this case, any duplicate or empty ID will force the processor to return an error. The ID must start with a letter or underline and cannot contain any space.

The above naming rules are also applied to the NMTOKEN type. But the promise is repeated. It is used to transmit data to the exploitation program. Most programming languages, including Java and JavaScript, cannot contain spaces in the module name. In most cases, it is best to ensure that attributes comply with their rules.

The enumeration type does not need to be specified. Instead, use the '|' symbol to include the value in parentheses. for example:

If there are limited possible attribute values, you can use this method.

I don't think today's course is boring, so let's continue reading it!



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.