当前位置:网站首页>XML schema record

XML schema record

2022-06-23 06:53:00 Small code 2016

advantage

  1. Better readability
  2. It supports specifying data types for element contents or attribute values , More functions 、 More powerful
  3. It can be expanded for future needs

Root element

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	
</xs:schema>

xmlns[:xxx] Property is used to specify XML Documents introduce semantic constraints . The attribute value of the attribute is the namespace corresponding to the semantic constraint used by the text .xxx Is an arbitrary Hu ID name , Prefixes all elements defined by the constraint

xmlns:xs="http://www.w3.org/2001/XMLSchema" Is each schema Documentation

Specify the namespace

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3school.com.cn"
xmlns="http://www.w3school.com.cn">


</xs:element>

targetNamespace="http://www.w3school.com.cn" Specify the schema Target namespace for . When it is necessary to quote this XML schema The definition of schema When the component , Usually, you need to use the prefix corresponding to the command space as the qualification
xmlns="http://www.w3school.com.cn" Specify the use of http://www.w3school.com.cn Namespace , No prefix is required to qualify

Whether it's XML The document is still XML schema file , Its root element can accept any number of xmlns[:xxx] attribute , among [:xxx] Part is optional ,xxx It can be any legal identification name .

xmlns:[xxx]="schameNamespace" Specify the use of schameNamespace Namespace , You should use xxx Prefix as qualification

Besides , It can be for schema Element specifies the following two attributes :
elementFormDerfault: The attribute value can be qualified or unqualified, Is used to specify the XML The document uses this schema Whether namespace qualification is required for local elements defined in
attributeFormDerfault: The attribute value can be qualified or unqualified, Is used to specify the XML The document uses this schema Whether namespace qualification is required for local attributes defined in

xml introduce schema

Reference namespace free schema

Add the following two attributes to the document root element :
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:noNamespaceSchemaLocation: Appoint XML Schema Of documents URI

Reference a namespace schema

  1. Every time a namespace is introduced schema, for XML Add a... To the root element xmlns[:xxx] attribute

If XML There is already... In the root element xsi:schemaLocation attribute (xsi The prefix is variable ), Then the attribute value is followed by the XML Schema Add one item , Additional items should be kept schemaNamespace schemaURI The format of .
If XML The root element does not yet have xsi:schemaLocation attribute , Add this attribute to it , And set the attribute value to schemaNamespace schemaURI

One copy XML At most one namespace free... Is introduced into the document XML Schema

data type

schema Not only is there a wealth of built-in data types , It also allows developers to derive new data types from built-in data types .
schema The supported data types fall into two broad categories :
Simple type : It can be used as XML Type of element , It can also be used as XML Type of attribute
Complex type : Only as XML Type of element

The simple type classification :
 Insert picture description here

done

原网站

版权声明
本文为[Small code 2016]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230538128953.html