当前位置:网站首页>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 .
边栏推荐
- Share: ZTE Yuanhang 30 Pro root unlock BL magick ZTE 7532n 8040n 9041n brush mask original brush package root method Download
- Isprs2020/ cloud detection: transferring deep learning models for cloud detection between landsat-8 and proba-v
- 2022 latest Android interview written examination, an Android programmer's interview experience
- English sentence pattern reference
- MySQL优化六个点的总结
- [HCIA cloud] [1] definition of cloud computing, what is cloud computing, architecture and technical description of cloud computing, Huawei cloud computing products, and description of Huawei memory DD
- Ant group open source trusted privacy computing framework "argot": open and universal
- AI open2022 | overview of recommendation systems based on heterogeneous information networks: concepts, methods, applications and resources
- IDEA配置npm启动
- Use QT to traverse JSON documents and search sub objects
猜你喜欢
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!
ConvMAE(2022-05)
Case sharing | integrated construction of data operation and maintenance in the financial industry
瞅一瞅JUC提供的限流工具Semaphore
Let more young people from Hong Kong and Macao know about Nansha's characteristic cultural and creative products! "Nansha kylin" officially appeared
LeetCode 6109. 知道秘密的人数
使用JMeter录制脚本并调试
5. 数据访问 - EntityFramework集成
SAP feature description
案例分享|金融业数据运营运维一体化建设
随机推荐
2022最新Android面试笔试,一个安卓程序员的面试心得
Electron installation problems
爬虫01-爬虫基本原理讲解
Is it safe to open an account, register and dig money? Is there any risk? Is it reliable?
Einstein sum einsum
Simple query cost estimation
sample_rate(采样率),sample(采样),duration(时长)是什么关系
The worse the AI performance, the higher the bonus? Doctor of New York University offered a reward for the task of making the big model perform poorly
EasyCVR电子地图中设备播放器loading样式的居中对齐优化
使用文件和目录属性和属性
2022 Alibaba Android advanced interview questions sharing, 2022 Alibaba hand Taobao Android interview questions
SAP feature description
Precautions for RTD temperature measurement of max31865 module
MySQL优化六个点的总结
ViewPager + RecyclerView的内存泄漏
怎么自动安装pythn三方库
常见时间复杂度
【HCIA-cloud】【1】云计算的定义、什么是云计算、云计算的架构与技术说明、华为云计算产品、华为内存DDR配置工具说明
U-Net: Convolutional Networks for Biomedical Images Segmentation
rust统计文件中单词出现的次数