当前位置:网站首页>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 .
边栏推荐
- Is it safe for golden sun to open an account? Can I open an account free of 5 in case?
- Take a look at semaphore, the current limiting tool provided by JUC
- IDEA配置npm启动
- 【Autosar 十四 启动流程详解】
- What is text mining? "Suggested collection"
- Is it safe to make fund fixed investment on access letter?
- 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
- A2L file parsing based on CAN bus (3)
- EasyCVR授权到期页面无法登录,该如何解决?
- Reading notes of Clickhouse principle analysis and Application Practice (5)
猜你喜欢

Web3.0时代来了,看天翼云存储资源盘活系统如何赋能新基建(下)

Reading notes of Clickhouse principle analysis and Application Practice (5)

Interprocess communication (IPC): shared memory

2022 Alibaba Android advanced interview questions sharing, 2022 Alibaba hand Taobao Android interview questions

AI表现越差,获得奖金越高?纽约大学博士拿出百万重金,悬赏让大模型表现差劲的任务

Ant group open source trusted privacy computing framework "argot": open and universal

RedHat7.4配置yum软件仓库(RHEL7.4)

@Extension, @spi annotation principle

SAP 特征 特性 说明

FCN: Fully Convolutional Networks for Semantic Segmentation
随机推荐
Isprs2020/ cloud detection: transferring deep learning models for cloud detection between landsat-8 and proba-v
Linear table - abstract data type
Share: ZTE Yuanhang 30 Pro root unlock BL magick ZTE 7532n 8040n 9041n brush mask original brush package root method Download
Cronab log: how to record the output of my cron script
Is it safe to make fund fixed investment on access letter?
Chinese postman? Really powerful!
Lombok @builder annotation
如何获取飞机穿过雷达两端的坐标
蚂蚁集团开源可信隐私计算框架「隐语」:开放、通用
Oracle 中文排序 Oracle 中文字段排序
Problems encountered in the project u-parse component rendering problems
瞅一瞅JUC提供的限流工具Semaphore
IDEA配置npm启动
Solutions contents have differences only in line separators
Common time complexity
How to choose the most formal and safe external futures platform?
About statistical power
New words new words new words new words [2]
音视频包的pts,dts,duration的由来.
What is text mining? "Suggested collection"