XML-based portal (1)
Basic XML
Xml document before we discuss a look at the examples:
<person>
Alan Turing
</ Person>
This is a good marker of the xml, and <person> </ person> respectively marked the beginning and end markers.
L start tag: <start to> the end, the middle is the tag name.
L marked the end: </ start to> the end, the middle is the tag name.
NOTE: start marking and marking the end of the corresponding tag name must be the same, but what the actual use of the name does not provide, and this is different from html (html markings are a number of identified), you can use to mark a person , the use of cat to a cat marking.
Marking the middle of Alan Turing is the data, and Alan Turing is the space between data, the data that is marked inside the box will not ignore.
Sometimes, we may not need any data elements (elements that marked the beginning and end markers between the contents of a start tag and end markers, such as the above-mentioned example is the one element), such as the following:
<person> </ Person>
This is a marked air, but we have other more simple marker that empty tag:
<person/>
NOTE: xml is case-sensitive, and html different. <Person> And <PERSON> markings are different, for example, you have an element to <person>, then you can not use </ Person> marked an end.
The above examples contain an element that, we are given examples of a complex point, and then given xml tree concept.
<person>
<name>
<first_name> Alan </ first_name>
<last_name> Turing </ last_name>
</ Name>
<profession> Computer scientist </ profession>
<profession> Mathematician </ profession>
<profession> Cryptographer </ profession>
</ Person>
Obviously the above example is still a person outer elements, but the difference is that previously the element containing four sub-elements, elements of a name and profession three elements. We name that person is the parent element, obviously, he is also the father of profession elements, we can see that the same name is first_name and last_name Father elements.
The above examples we found a marked nested, which is permitted. But overlapping markers are illegal, such as:
<strong> <em> This common example from HTML </ strong> </ em>
Should be:
<strong> <em> This common example from HTML </ em> </ strong>
According to the above example in the relationship between father and son element, and noting any xml document only and only contain a root element (that is not the father elements elements) looks like a tree, Figure:

Now we are given a mixed data of the xml example,
<biography>
<name> <first_name> Alan </ first_name> <last_name> Turing </ last_name>
</ Name> was one of the first people to truly deserve the name
<emphasize> Computer scientist </ emphasize>. Although his contributions
To the field are too numerous to list, his best-known are the
Eponymous <emphasize> Turing Test </ emphasize> and
<emphasize> Turing Machine </ emphasize>.
<definition> The <term> Turing Test </ term> is to this day the standard
Test for determining whether a computer is truly intelligent. This
Test has yet to be passed. </ Definition>
<definition> The <term> Turing Machine </ term> is an abstract finite
State automaton with infinite memory that can be proven equivalent
To any any other finite state automaton with arbitrarily large memory.
Thus what is true for a Turing machine is true for all equivalent
Machines no matter how implemented.
</ Definition>
<name> <last_name> Turing </ last_name> </ name> was also an accomplished
<profession> Mathematician </ profession> and
<profession> Cryptographer </ profession>. His assistance
Was crucial in helping the Allies decode the German Enigma
Machine. He committed suicide on <date> <month> June </ month>
<day> 7 </ day>, <year> 1954 </ year> </ date> after being
Convicted of homosexuality and forced to take female
Hormone injections.
</ Biography>
The example above I do not want to explain, but you have to know that he is a legitimate xml document, that is to say the markup and content can be mixed. But this format xml document processing, very troublesome, it is not recommended.
Then we talk about the attributes (Attributes). See examples:
<Person born = "
Alan Turing
</ Person>
One red markings attribute is born and died. Which is the property name born,
<Person died = '
Alan Turing
</ Person>
The use of single quotation marks is the role you can add the value of the attribute inside double quotes.
Here we found a problem:
<person>
<name First="Alan" last="Turing"/>
<profession Value="computer scientist"/>
<profession Value="mathematician"/>
<profession Value="cryptographer"/>
</ Person>
In this example, I added a person elements inside four sub-elements, each element has its own attributes, as well as the corresponding value, and then this four elements are empty elements. We are in control of the corresponding previous examples, do you think that it is limited to the value of the property inside labeled good or placed directly between well? This is a vexed question, my own view is that you will see the use of which which Shuang. However, to the attention of the same elements, at the same time he could not contain the same name as the number of attributes.
<Person born = "
Alan Turing
</ Person>
The above is illegal xml document.
Then we look at the problems associated with special characters. As <and> are used as a marker, so under normal circumstances, we can not directly part of the data contained in the <and>, but the use <and> In fact, this issue will have a html inside, and html approach is the same, for example, & & we use double quotes "use".
Let us look at Notes, methods and html is the same:
<! - The left is the beginning Notes marking an end to the right of the marker ->
But attention to the content of the Notes can not contain - while inside the Notes of any markings will be neglected! At the same time it should be noted that the Notes can not have a marker elements inside.
We now from the overall perspective xml:
1. Xml statement
All xml document may (should!) From an xml statement (XML Declaration). Although the sound files
That the use of a similar deal with the same command syntax, but technically speaking, in accordance with recommended standards XML is not about them, because
Xml in the statement is part of the reservation.
<? Xml version = "1.0" encoding = "ASCII" standalone = "yes">
<person>
Alan Turing
</ Person>
If including XML statement, it must be in the forefront of document - not in front of any gaps or Notes. Strictly speaking,
In XML which such statements is not required, but we will see that behind when processing documents, it will certainly play a role in some optimization.
These attributes in the XML 1.0 specification has been made in the definition:
? Version-not omitted; value must be "1.
? Encoding-optional; value must be a legitimate form of character encoding, such as "UTF –
"ISO - 8 8 5 9 - 1" (L atin - 1 character encoding). XML parser all require at least support UTF - 8 and UTF - 1 6.
If this property does not include the assumption that "UTF - 8" or "UTF - 1 6" coding, depending on the beginning of "<? Xml" string format.
? Standalone-optional; value must be "yes" or "no" If it is "yes" means all the necessary entities statements contained in the document, if it is "no" means the need for external DTD. DTD will be introduced in the back.
Finally, good xml the relevant requirements:
1. Each start tag must have a matching end labeling
2. Marker can be nested but not overlap
3. Each xml document only a root element
4. Not contain an element of the same name two attributes
5. Notes not appear in marker elements inside
6. Not <or & other similar elements of the characters appear in value or attribute value inside
Tags: XML








0 Comments to “XML-based portal (1)”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.