当前位置:网站首页>XML basic knowledge concept
XML basic knowledge concept
2022-07-05 18:45:00 【User 7741497】
XML Basic knowledge concepts
attribute
Name value pairs in the following form :
ID="QD5690"Attributes are in elements , As shown below , An element can have any number of attributes .
<Patient ID="QD5690">Cromley,Marcia N.</Patient>CDATA Area
Represents text that should not be validated , As shown below :
<myelementname><![CDATA[
Non-validated data goes here.
You can even have stray "<" or ">" symbols in it.
]]></myelementname> One CDATA( Character data ) A section cannot contain a string ]]>, Because this string marks the end of the section . It also means that CDATA Sections cannot be nested .
Be careful ,CDATA The content of part must conform to XML The code specified by the document ,XML The same is true for the rest of the document .
comment
No XML Insert instructions for a part of the document master data . The comment is like this :
<!--Output for the class: GXML.PersonNS7-->content model
Yes XML An abstract description of the possible contents of an element . Possible content models are as follows :
- Empty content model ( Child elements or text nodes are not allowed )
- Simple content model ( Only text nodes are allowed )
- Complex content model ( Only child elements )
- Mixed content model ( Allow child elements and text nodes )
In all cases , Elements may or may not have attributes ; The phrase content model does not involve the existence or non existence of attributes in elements .
default namespace
The namespace to which any unqualified element in a given context belongs . The added default namespace has no prefix . for example :
<Person xmlns="http://www.person.org">
<Name>Isaacs,Rob G.</Name>
<DOB>1981-01-29</DOB>
</Person> Because this namespace declaration does not use a prefix , therefore <Person>、<Name> and <DOB> Elements belong to this namespace .
Be careful , Below XML The default namespace is not used , It is actually equivalent to the previous example :
<s01:Person s01:xmlns="http://www.person.org">
<s01:Name>Isaacs,Rob G.</s01:Name>
<s01:DOB>1981-01-29</s01:DOB>
</s01:Person>DOM
Document object model (DOM) Is said XML And object models in related formats .
DTD( Document type definition )
Included in XML A series of text instructions in a document or external file . It defines all valid elements and attributes that can be used in documents . dtd Don't use XML grammar .
element
An element is usually marked by two ( A start tag and an end tag ) form , May contain text and other elements . The content of the element is everything between these two tags , Include text and any child elements . Here is a complete XML Elements , Include start tag 、 Text content and end tag :
<Patient>Cromley,Marcia N.</Patient>An element can have any number of attributes and any number of child elements .
An empty element can contain a start tag and an end tag , It can also contain only one tag . The following example is equivalent :
<EndDate></EndDate>
<EndDate/>In practice , Elements are likely to reference different parts of the data record , for example
<Student level="undergraduate">
<Name>Barnes,Gerry</Name>
<DOB>1981-04-23</DOB>
</Student>entity
( stay XML In file ) A text unit that represents one or more characters . An entity has the following structure :
&characters;global element
The concepts of global and local elements apply to documents that use namespaces . The name of the global element and the name of the local element are placed in a separate symbol space . A global element is an element whose type has a global scope , That is, its type is in the corresponding XML Elements defined at the top level of the schema . As <xs:schema> The element declaration of a child element of an element is considered a global declaration . Any other element declaration is a local element , Unless it passes ref Attribute references the global declaration , This actually makes it a global element .
Attributes can be global , It can also be partial .
local element
It's not the whole thing XML Elements . Local elements do not explicitly belong to any namespace , Unless the element is qualified . See qualifying elements and global elements .
namespace
A namespace is a unique string that defines a domain for an identifier , So as to be based on xml Your application will not confuse one type of document with another . It usually uses URL( Unified resource location ) The form of gives a URI( Unified resource indicator ), It may be related to the actual web The address corresponds to , It may not correspond to . for example ,“http://www.w3.org” It's a namespace .
Use one of the following syntax to include namespace declarations :
xmlns="your_namespace_here"
pre:xmlns="your_namespace_here"In both cases , Namespaces are only used in the context of inserting namespace declarations . In the latter case , Namespace and given prefix (pre) Related to . If and only if the element or attribute also has this prefix , The element or attribute belongs to this namespace . for example :
<s01:Person xmlns:s01="http://www.person.com">
<Name>Ravazzolo,Roberta X.</Name>
<DOB>1943-10-24</DOB>
</s01:Person> Namespace declaration uses s01 Prefix . <Person> Element also uses this prefix , So this element belongs to this namespace . however ,<Name> and <DOB> The element does not explicitly belong to any namespace .
A processing instruction (PI)
An instruction ( In the preface ), Designed to tell applications how to use XML Document or how to deal with it . An example ; This associates style sheets with documents .
<?xml-stylesheet type="text/css" href="mystyles.css"?>prolog
XML The part before the root element in the document . Preface with XML Statement ( Indicates the use of XML edition ) Start , Then it may include DTD Declarations or schema declarations and processing instructions . ( Technically speaking , Unwanted DTD Or mode . Besides , Technically speaking , You can put both in the same file .)
root, root element, document element
Every XML Documents require only one element at the outermost layer . This is called the root element 、 Root element or document element . The root element is after the preface .
qualified
If you explicitly assign elements or attributes to namespaces , Then the element or attribute is qualified . Consider the following example , among <Person> The elements and attributes of are unlimited :
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<s01:Person xmlns:s01="http://www.person.com" GroupID="J1151">
<Name>Frost,Sally O.</Name>
<DOB>1957-03-11</DOB>
</s01:Person>
</Root> ad locum , Namespace declarations use s01 Prefix . There is no default namespace . <Person> Element also uses this prefix , So this element belongs to this namespace . <Name> and <DOB> Element or <GroupID> Attribute has no prefix , So they don't explicitly belong to any namespace .
contrary , Consider the following , among <Person> The elements and attributes of are qualified :
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Person xmlns="http://www.person.com" GroupID="J1151">
<Name>Frost,Sally O.</Name>
<DOB>1957-03-11</DOB>
</Person>
</Root> In this case ,<Person> Element defines a default namespace , This namespace applies to child elements and attributes .
Be careful :XML Mode properties elementFormDefault Properties and attributeFormDefault Attributes control whether elements and attributes are qualified in a given schema . stay InterSystems IRIS XML Supporting , Use class parameters to specify whether the element qualifies .
schema
One is a group XML Document specifies the document of meta information , Can be used as DTD An alternative . And DTD equally , You can use patterns to validate specific XML The content of the document . For some applications ,XML The pattern provides a connection with dtd Several advantages over , Include :
- XML The pattern is effective XML file , Therefore, it is easier to develop tools for operation mode .
- XML Patterns can specify a richer set of features , And contain the type information of the value .
Formally , The schema document is consistent with W3 XML Pattern specification XML file ( stay https://www.w3.org/XML/Schema). It obeys XML The rules , And use some extra syntax . Usually , The file extension is .xsd.
style sheet
use XSLT Written documents , Describe how the given XML Convert document to another XML Or others “ Human readable ” Documents .
text node
One or more characters contained between the start element and the corresponding end element . for example :
<SampleElement>
sample text node
</SampleElement>type
Limitations on data interpretation . stay XML In the pattern , The definition of each element and attribute corresponds to a type .
The type can be simple , It can also be complex .
Each attribute has a simple type . Simple types also mean that there are no attributes and child elements ( Only text nodes ) The elements of . Complex types represent other elements .
The following pattern fragment shows some type definitions :
<s:complexType name="Person">
<s:sequence>
<s:element name="Name" type="s:string" minOccurs="0" />
<s:element name="DOB" type="s:date" minOccurs="0" />
<s:element name="Address" type="s_Address" minOccurs="0" />
</s:sequence>
<s:attribute name="GroupID" type="s:string" />
</s:complexType>
<s:complexType name="s_Address">
<s:sequence>
<s:element name="City" type="s:string" minOccurs="0" />
<s:element name="Zip" type="s:string" minOccurs="0" />
</s:sequence>
</s:complexType>unqualified
If you don't explicitly assign elements or attributes to namespaces , Then the element or attribute is unqualified .
well-formed XML
follow XML Regular XML Document or fragment , For example, there is an end tag to match a start tag .
XML declaration
Indicates the XML edition ( And optional character sets ) The sentence of . If you include , It must be the first line in the document . An example :
<?xml version="1.0" encoding="UTF-8"?>XPath
XPath (XML Path to the language ) It's based on XML The expression language of , For from XML Get data in the document . The result can be scalar , It can also be the original document XML subtree .
XSLT
XSLT( Extensible stylesheet language conversion ) It's based on XML Language , Used to describe how a given XML Convert document to another XML Or others “ Human readable ” file .
边栏推荐
- ROS installation error sudo: rosdep: command not found
- Introduction to Resampling
- 如何写出好代码 - 防御式编程
- 2022 Alibaba Android advanced interview questions sharing, 2022 Alibaba hand Taobao Android interview questions
- Writing writing writing
- [detailed explanation of AUTOSAR 14 startup process]
- Quickly generate IPA package
- How to obtain the coordinates of the aircraft passing through both ends of the radar
- 开户注册股票炒股安全吗?有没有风险的?靠谱吗?
- Interprocess communication (IPC): shared memory
猜你喜欢

Isprs2022/ cloud detection: cloud detection with boundary nets

Word查找红色文字 Word查找颜色字体 Word查找突出格式文本

RedHat7.4配置yum软件仓库(RHEL7.4)
![2022 latest intermediate and advanced Android interview questions, [principle + practice + Video + source code]](/img/c9/f4ab4578029cf043155a5811a64489.png)
2022 latest intermediate and advanced Android interview questions, [principle + practice + Video + source code]

SAP 特征 特性 说明

企业数字化转型之路,从这里开始

Interprocess communication (IPC): shared memory

案例分享|金融业数据运营运维一体化建设

IDEA配置npm启动

小程序 修改样式 ( placeholder、checkbox的样式)
随机推荐
Various pits of vs2017 QT
CDB 实例的启动与关闭
A2L file parsing based on CAN bus (3)
7-2 keep the linked list in order
The 11th China cloud computing standards and Applications Conference | cloud computing national standards and white paper series release, and Huayun data fully participated in the preparation
How to write good code defensive programming
使用JMeter录制脚本并调试
vulnhub之darkhole_2
2022 latest Android interview written examination, an Android programmer's interview experience
Word查找红色文字 Word查找颜色字体 Word查找突出格式文本
企业数字化转型之路,从这里开始
在通达信上做基金定投安全吗?
Clickhouse (03) how to install and deploy Clickhouse
一朵云开启智慧交通新未来
New words new words new words new words [2]
Take a look at semaphore, the current limiting tool provided by JUC
进程间通信(IPC):共享内存
企业级数据安全,天翼云是这样理解的
The 2022 China Xinchuang Ecological Market Research and model selection evaluation report released that Huayun data was selected as the mainstream manufacturer of Xinchuang IT infrastructure!
使用文件和目录属性和属性