XML Schema °ïÖúÎĵµ4
XML Schema import ÔªËØ
¶¨ÒåºÍÓ÷¨
import ÔªËØÓÃÓÚÏòÒ»¸öÎĵµÌí¼Ó´øÓв»Í¬Ä¿±êÃüÃû¿Õ¼äµÄ¶à¸ö schema¡£
ÔªËØÐÅÏ¢
³öÏÖ´ÎÊý
ÎÞÏÞÖÆ
¸¸ÔªËØ
schema
ÄÚÈÝ
annotation
Óï·¨
<import
id=ID
namespace=anyURI
schemaLocation=anyURI
any attributes
>
(annotation?)
</import>
ÊôÐÔ
ÃèÊö
id
¿ÉÑ¡¡£¹æ¶¨¸ÃÔªËصÄΨһµÄ ID¡£
namespace
±ØÐè¡£¹æ¶¨Òªµ¼ÈëµÄÃüÃû¿Õ¼äµÄ URI¡£
schemaLocation
¿ÉÑ¡¡£¹æ¶¨±»µ¼ÈëµÄÃüÃû¿Õ¼äµÄ URI¡£
any attributes
¿ÉÑ¡¡£¹æ¶¨´øÓÐ non-schema ÃüÃû¿Õ¼äµÄÈκÎÆäËûÊôÐÔ¡£
£¨? ·ûºÅÉùÃ÷ÔÚ import ÔªËØÖУ¬¸ÃÔªËؿɳöÏÖÁã´Î»òÒ»´Î¡££©
ʵÀý
ÏÂÃæµÄÀý×Óչʾµ¼ÈëÒ»¸öÃüÃû¿Õ¼ä£º
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.w3school.com.cn/schema"/>
..
..
..
</xs:schema>
XML Schema include ÔªËØ
¶¨ÒåºÍÓ÷¨
include ÔªËØÓÃÓÚÏòÒ»¸öÎĵµÌí¼Ó´øÓÐÏàͬĿ±êÃüÃû¿Õ¼äµÄ¶à¸ö schema¡£
ÔªËØÐÅÏ¢
³öÏÖ´ÎÊý
ÎÞÏÞÖÆ
¸¸ÔªËØ
schema
ÄÚÈÝ
annotation
Óï·¨
<include
id=ID
schemaLocation=anyURI
any attributes
>
(annotation?)
</include>
ÊôÐÔ
ÃèÊö
id
¿ÉÑ¡¡£¹æ¶¨¸ÃÔªËصÄΨһµÄ ID¡£
schemaLocation
±ØÐè¡£¹æ¶¨ÔÚ°üº¬ schema µÄÄ¿±êÃüÃû¿Õ¼äÖУ¬Òª°üÀ¨µÄ schema µÄ URI¡£
any attributes
¿ÉÑ¡¡£¹æ¶¨´øÓÐ non-schema ÃüÃû¿Õ¼äµÄÈκÎÆäËûÊôÐÔ¡£
£¨? ·ûºÅÉùÃ÷ÔÚ include ÔªËØÖУ¬¸ÃÔªËؿɳöÏÖÁã´Î»òÒ»´Î¡££©
ʵÀý
ͨ¹ý±»°üÀ¨µÄ schema£¬±»°üÀ¨µÄÎļþ±ØÐëÈ«²¿ÒýÓÃÏàͬµÄÄ¿±êÃüÃû¿Õ¼ä¡£Èç¹û schema Ä¿±êÃüÃû¿Õ¼ä²»Æ¥Å䣬Ôò°üÀ¨²»»áÓÐЧ£º
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3school.com.cn/schema">
<xs:include schemaLocation="http://www.w3school.com.cn/schema/customer.xsd"/>
<xs:include schemaLocation="http://www.w3school.com.cn/schema/company.xsd"/>
..
..
..
</xs:schema>
XML&
Ïà¹ØÎĵµ£º
XMLÊÇÒ»ÖÖ¿ÉÀ©Õ¹ÖñêÓïÑÔ£¬ÓֳƿÉÀ©Õ¹µÄ±à¼ÓïÑÔ¡£XMLÎĵµµÄ¶¨Òå¸ñʽÓÐÁ½ÖÖ£ºDTDºÍSchema¸ñʽ£¬ÓÉÓÚSchemaÊÇxml±¾ÉíµÄ£¬ËùÒÔÓ¦Óõķdz£Æձ顣xmlµÄ×÷ÓÃÊÇÎļþµÄ¶Áд£¬ËùÒÔÔÚweb¿ª·¢ÖÐÒ²µÃµ½Á˹㷺ӦÓã¬×÷ΪһÖÖÅäÖÃÎļþ£¬³ä·Ö·¢»ÓÁËËü¶ÁдµÄ¹¦ÄÜ¡£XMLµÄ½âÎö·½Ê½ÓÐËÄÖÖ£ºDOM£¬SAX£¬JDOM£¬DOM4J¡£ ......
(Ò») ÏȽ²Ò»ÏÂXMLÖеÄÎïÊâ×Ö·û£¬ÊÖ¶¯ÌîдʱעÒâһϡ£
×Ö·û ×Ö·ûʵÌå
& ......
¿ÉÄÜÄúÒѾÌý˵ÁË£¬±¾ÖÜÊÇ Microsoft ÊÂÒµ²¿ºÜ¹Ø¼üµÄÒ»ÖÜ¡£ÔÚ±¾ÖÜÔçЩʱºò£¬ÎÒÃÇÐû²¼½«¹«¿ª·¢ÐÐ Microsoft Office 2010 Beta¡£ÄúÊÇ·ñÔøÏ£ÍûÓëÍŶÓÒ»ÆðÔÚ Word Öй²Í¬´´×÷Ò»·ÝÎĵµ£¿ÄúÊÇ·ñÔøÏ£ÍûÔÚ Excel ÖÐͬʱ·ÖÎö³É¶ÑµÄÊý¾Ý£¿»òÕßÔÚ PowerPoint ÑÝʾÎĸåÖÐÍ»ÆƶàýÌåµÄÏÞÖÆ£¿ÄÇô£¬¸Ï¿ìÊÔÊÔ Beta °æ±¾°É¡£
¶ÔÓÚ±ê×¼ÉçÇø£ ......
//¶ÁÈ¡XMLÎļþ
//1¡¢LoadfromFile×°ÈëXMLÎļþ
//2¡¢Ö¸¶¨Â·¾¶£¬¼¤»î¶ÁÈ¡
//3¡¢´ÓÄÚ´æÁ÷¶ÁÈ¡
//4¡¢´ÓÍøÂçÉÏÖ±½Ó»ñÈ¡
//1¡¢LoadfromFile×°ÈëXMLÎļþ
procedure TForm1.Button1Click(Sender: TObject);
begin
XMLDocument1.LoadfromFile('c:\temp\test.xml');
// XMLDocument1.Active := True;
Memo1.Lines := X ......
XML Schema attributeGroup ÔªËØ
¶¨ÒåºÍÓ÷¨
attributeGroup ÔªËØÓÃÓÚ¶ÔÊôÐÔÉùÃ÷½øÐÐ×éºÏ£¬ÕâÑùÕâЩÉùÃ÷¾ÍÄܹ»ÒÔ×éºÏµÄÐÎʽºÏ²¢µ½¸´ÔÓÀàÐÍÖС£
ÔªËØÐÅÏ¢
³öÏÖ´ÎÊý
ÎÞÏÞÖÆ
¸¸ÔªËØ
attributeGroup¡¢complexType¡¢schema¡¢restriction (simpleContent)¡¢extension (simpleContent)¡¢rest ......