• 热门标签

当前位置: 主页 > 航空资料 > 国外资料 >

时间:2010-08-23 16:10来源:蓝天飞行翻译 作者:admin
曝光台 注意防骗 网曝天猫店富美金盛家居专营店坑蒙拐骗欺诈消费者

carries no information.
In the example:
contact has element content, because it
contains other elements.
XML File
FODM – Introduction to XML 20/44
In a same XML document several
elements can have the same
name, but can relate to different
things
E.g. <name>
XML Elements - Syntax
<contact>
<name>
<firstname>Ronan</firstname>
<name>O’Gara</name>
</name>
<email>
<name>ronan.o-gara </name>
<server>mail.com</server>
</email>
<address>
<name>26 O’Connell St</name>
<postcode>27 011</postcode>
<town>Dublin</town>
<country>Ireland</country>
</address>
In Airbus structured documentation, </contact>
an effort not to use the same names
for two different elements has been
done.
The place where the element is inside the XML tree is an information on what it is.
We can find several tags with the same designation which will not have the same meaning.
FODM – Introduction to XML 21/44
XML Attributes
In XML, attributes provide additional
information about elements:
<img src="computer.gif“ />
<a href="demo.asp“ />
This information is often not part of
the data:
<file type="gif">computer.gif</file>
XML elements can have attributes
Here, the file type is irrelevant to the data, but
important to the software that wants to manipulate
the element.
FODM – Introduction to XML 22/44
Attribute values must always be
enclosed in quotes.
But either single or double
quotes can be used.
<contact sex=“Male”>
<contact sex=‘Male’>
XML Attributes - Syntax
Note 1: If the attribute value itself contains double quotes it is necessary to use single quotes:
E.g. <contact name=‘Ronan "Ron" O Gara'>
Note 2: If the attribute value itself contains single quotes it is necessary to use double quotes:
E.g. <contact name=“Ronan O’Gara">
FODM – Introduction to XML 23/44
Data can be stored in child elements or in attributes.
There are no rules about when to use attributes/elements.
The rule is to use child elements if the information feels like
data.
The DTD already defines the structure of the documents.
The choice between attribute and element has already
been done.
<contact sex=“Male">
<firstname>Ronan</firstname>
<lastname>O'Gara</lastname>
</contact>
<contact>
<sex>Male</sex>
<firstname>Ronan</firstname>
<lastname>O'Gara</lastname>
</contact>
is equivalent to
XML Elements vs Attributes
FODM – Introduction to XML 24/44
XML Elements vs Attributes
Use attributes only to provide information that is not relevant to
the data.
Here are some of limitations about using attributes:
 attributes cannot contain multiple values (child elements can).
 attributes are not easily expandable (for future changes).
 attributes cannot describe structures (child elements can).
 attributes are more difficult to manipulate by program code.
 attribute values are not easy to test against a Document Type Definition (DTD)
which is used to define the legal elements of an XML document .
FODM – Introduction to XML 25/44
ID references can be used to
access XML elements in much
the same way as the NAME or ID
attributes in HTML
<directory>
<contact ID=“C01">
<name>
<firstname>Ronan</firstname>
<name>O'Gara</name>
</name>
</contact>
<contact ID=“C02">
<name>
<firstname>Mick</firstname>
<name>O'Driscoll</name>
</name>
</contact>
The “ID” in these examples is just a counter (a unique </directory>
identifier) to identify the different <notes> in the XML
file, and not a part of the note data.
Therefore, metadata (data about data) should be
stored as attributes, and data itself should be
stored as elements.
XML Elements vs Attributes
FODM – Introduction to XML 26/44
Data itself should be stored as
elements
Metadata (data about data) should be
stored as attributes
XML Elements vs Attributes
 
中国航空网 www.aero.cn
航空翻译 www.aviation.cn
本文链接地址:FODM Training(4)