Вы находитесь на странице: 1из 16

XML Schema 1.1: 1.

XML Schema 1.0,


IBM

26.05.2010

IBM

IBM

IBM
XML Schema ,
, , .
XML Schema
1.1, W3C.
XML Schema 1.0.
, , XML Schema
1.1, , ,
, .

XML Schema 2001 ,


W3C. W3C
XML Schema. 2005 ,
,
Copyright IBM Corporation 2010
XML Schema 1.1: 1.


1 16

developerWorks

ibm.com/developerWorks/ru/

XSLT, XQuery WSDL, W3


,
. ,
, XML-,
XML Schema 1.1.

W3C: World Wide Web


WSDL: Web-
XML:
XSLT:

XML Schema 1.1,


, .
" XML" (XML Schema Definition Language).
XSD,
"XML Schema" "", .
, XML Schema 1.1
,
W3C.

XML Schema 1.0


XML- . ,
.
, .
XML Schema
1.0, XML Schema 1.1, .
.


.
, , :
<xs:sequence>, <xs:choice> <xs:all>.
,
. ,

.
XML Schema 1.0 , 25
,
. :

;
XML Schema 1.1: 1.

2 16

ibm.com/developerWorks/ru/

developerWorks

,
, .
1 derived,
tns:a, base. ,
, XML Schema 1.0.

1. ,

<complexType name="base">
<complexContent>
<sequence>
<element ref="tns:a" minOccurs="0" maxOccurs="1"/>
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="tns:b"/>
<element ref="tns:c"/>
</choice>
</sequence>
</complexContent>
</complexType>
<complexType name="derived">
<complexContent>
<restriction base="tns:base">
<sequence>
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="tns:b"/>
<element ref="tns:c"/>
</choice>
</sequence>
</restriction>
</complexContent>
</complexType>

XML Schema 1.1 25 ,


, ", , ".
,
XML Schema 1.1.


XML- ,
, : " min
max" " size".
(coconstraints).
XML Schema 1.0 ,
Java XML-
. ,
( ).

XML, Schematron Relax NG (. ""),
, XSD.
XML Schema 1.1: 1.

3 16

developerWorks

ibm.com/developerWorks/ru/

XML Schema 1.1 .


<xs:assert> XPath 2.0
(. ""). 2.

2. XML
Schema 1.1
<xs:complexType name="intRange">
<xs:attribute name="min" type="xs:int"/>
<xs:attribute name="max" type="xs:int"/>
<xs:assert test="@min <= @max"/>
</xs:complexType>


, , ,
XML . XML Schema
. ,
.
, :
(Unique
Particle Attribution UPA) ;
",
";
,
.
XML Schema 1.1 , ,
. UPA
. ,
,
. , ,
, .
,
: " userName,
userName". 3.

3. XML Schema 1.0


<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/>
<xs:element ref="tns:userName"/>
<xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/>
</xs:sequence>

XML Schema 1.0,


userName , <xs:any>
XML Schema 1.1: 1.

4 16

ibm.com/developerWorks/ru/

developerWorks

<xs:element>.
- .
, , XML
. , :
userName, ,
" " .
3 XML Schema 1.1
, . ,
, ,
. , UPA. "
userName, " ,
4.

4. XML Schema 1.1


<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded"
processContents="skip" notQName="tns:userName"/>
<xs:element ref="tns:userName"/>
<xs:any minOccurs="0" maxOccurs="unbounded"
processContents="skip" notQName="tns:userName"/>
</xs:sequence>

XML Schema
XML Schema :
(Structures) (Datatypes, . "").
, .
.

XQuery 1.0 XPath


, XQuery 1.0, XPath 2.0, XSLT 2.0,
XQuery 1.0 XPath 2.0 (. ""),
XML Schema 1.0.
XML Schema 1.0,
, : anyAtomicType, untyped, untypedAtomic,
dayTimeDuration yearMonthDuration. XML Schema 1.1
(anyAtomicType, dayTimeDuration yearMonthDuration)
XSD .
anyAtomicType
XML Schema 1.1,
anySimpleType. anyAtomicType
,
.
: XML- 5,
anyAtomicType

XML Schema 1.1: 1.

5 16

developerWorks

ibm.com/developerWorks/ru/

XML 6. anyAtomicType
. ,
anyAtomicType, xsi:type. , anyAtomicType
(constraining facet),
, .

5. anyAtomicType
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="test" xmlns:pfx="test">
<element name="root">
<complexType>
<sequence>
<element name="elanyAtomicType" type="anyAtomicType"
maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
</schema>

6. ,
anyAtomicType
<pfx:root xmlns:pfx="test" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<elanyAtomicType>Test</elanyAtomicType>
<elanyAtomicType>12345</elanyAtomicType>
<elanyAtomicType xsi:type="xs:string">Test</elanyAtomicType>
<elanyAtomicType xsi:type="xs:integer">12345</elanyAtomicType>
</pfx:root>

yearMonthDuration
duration, XML Schema 1.0 (.
"") ,
. , P30D P1M ,
28 31 .
XMl Schema 1.1 : yearMonthDuration dayTimeDuration,
duration.
XML Schema 1.1 yearMonthDuration
duration.
. '-?P[0-9]+(Y([0-9]+M)?|M)'.

,
. duration
.
yearMonthDuration duration,
.

yearMonthDuration P1Y6M P18M,
XML Schema 1.1: 1.

6 16

ibm.com/developerWorks/ru/

developerWorks

18 . yearMonthDuration
P1Y2M, P12Y, -P20M, - P-1Y, P1Y-1M P1YM. yearMonthDuration
, ..
(D1, D2) yearMonthDurations. , D1 > D2, D1 < D2.
yearMonthDuration.
,
duration. yearMonthDuration duration,
ordered () partial (),
.
dayTimeDuration
yearMonthDuration, dayTimeDuration , duration.
duration,
, , .
[^YM]*[DT].*. ,
( xs:integer), xs:decimal.
, "",
dayTimeDuration. dayTimeDuration
duration, ,
, .
, , 4.5
dayTimeDuration: P1DT2H3M4.5S.
93784.5 (1*24*60*60+2*60*60+3*60+4.5) . ,
, ,
, .
dayTimeDuration c , T.
dayTimeDuration P1D, PT25H, P22DT2H, PT1H99M5,5S, -PT20M, PT60.60S, - P-5D, P1D1M1H1S, PDT1M, P5H P1DT. yearMonthDuration
dayTimeDuration .
, dayTimeDuration, ,
, duration , whitespace
yearMonthDuration dayTimeDuration collapse .
7 , XML Schema 1.1,
yearMonthDuration dayTimeDuration.

7. yearMonthDuration
dayTimeDuration XML Schema
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="test" xmlns:pfx="test">
<simpleType name="ymdBase">
<restriction base="yearMonthDuration">
<minInclusive value="P1Y6M"/>

XML Schema 1.1: 1.

7 16

developerWorks

ibm.com/developerWorks/ru/

</restriction>
</simpleType>
<simpleType name="ymdDerived">
<restriction base="ymdBase">
<minInclusive value="P19M"/>
</restriction>
</simpleType>
<simpleType name="dtdBase">
<restriction base="dayTimeDuration">
<maxInclusive value="-P2DT2H"/>
</restriction>
</simpleType>
<simpleType name="dtdDerived">
<restriction base="dtdBase">
<maxInclusive value="-P51H"/>
</restriction>
</simpleType>
<element name="root">
<complexType>
<sequence>
<element name="elYearMonthDuration" type="ymdDerived"/>
<element name="elDayTimeDuration" type="dtdDerived"/>
</sequence>
</complexType>
</element>
</schema>

7
yearMonthDuration dayTimeDuration XML Schema 1.1. ymdDerived
ymdBase,
yearMonthDuration minInclusive.
yearMonthDuration , P19M
ymdDerived , P1Y6M ymdBase, ,
. dtdDerived
dtdBase, dayTimeDuration,
maxInclusive. -P51H
dtdDerived -P2DT2H .
root elYearMonthDuration elDayTimeDuration
ymdDerived dtdDerived .

precisionDecimal
XML Schema 1.1 precisionDecimal
IEEE-754.
decimal , ,
. precisiontDecimal
" " (+INF), " " (-INF), NaN (not
a number), , . ,
(+0 -0).
precisionDecimal (
), () ,
'INF', '+INF', '-INF', 'NaN'.
XML Schema 1.1: 1.

8 16

ibm.com/developerWorks/ru/

developerWorks

, precisionDecimal,
decimal. ,
maxScale minScale,
precisionDecimal. maxScale ,
minScale - precisionDecimal.
8 price,
-999,999.99 999,999.99.

8. precisionDecimal XML Schema


<xs:simpleType name='price'>
<xs:restriction base='xs:precisionDecimal'>
<xs:totalDigits value='8'/>
<xs:minScale value='2'/>
<xs:maxScale value='2'/>
</xs:restriction>
</xs:simpleType>

NaN , ,
. , NaN
(minInclusive, maxInclusive, minExclusive maxExclusive)
.
NaN .
NaN ,
, NaN
( pattern "NaN").


XML Schema 1.0 , date, time dateTime,
(('+' | '-') hh ':'
mm) | 'Z'. (UTC)
.
, XML Schema 1.0 (timezone
offset), " " (timezone),
, .
(, ),

UTC (, 11:00-05:00). XML Schema 1.1
, timezone timezone offset , .


(leap seconds) ,
, , . ,
60 . ,
UTC 0.9 .
XML Schema 1.1: 1.

9 16

developerWorks

ibm.com/developerWorks/ru/

, XML Schema 1.1,


,
, .
1972-06-30. ,
, .

, XML-
XML Schema , string,
boolean double, XML-.
. ,
,
.
,
XML Schema 1.1
. ,
.
:
anyAtomicType ;
, (
whiteSpace );

, http://www.w3.org/2001/XMLSchema ( ,
W3C);
, ,
;
;
.
, , XML-,
date --,
, (-).
, anyAtomicType ,
, "http://www.example.com/XMLSchemaprimitiveTypes". , ,
, , , . ,
date XML
Schema 1.1. , , :
(.), (-) (/).
, ,
.
:
XML Schema 1.1: 1.

10 16

ibm.com/developerWorks/ru/

developerWorks

ordered: partial ( : )
bounded: false ( : )
cardinality: countably infinite ( : -)
numeric: false ( : )

, whiteSpace.
"collapsed", date .
XML Schema 1.1
, :

pattern
enumeration
maxInclusive
maxExclusive
minInclusive
minExclusive
assertions
dateSeparator ( )

, "2008-11-01", "2008.11.01" "2008/11/01"


.
2008 .
,
XML Schema ,
minInclusive maxLength, .
,
.
.
, ,
XML Schema 1.1
. ,
.
,
:
;
;
,
http://www.w3.org/2001/XMLSchema ( , W3C);
, .

XML Schema 1.1: 1.

11 16

developerWorks

ibm.com/developerWorks/ru/

9 , XML-
dateSeparator, -,
date .

9. ,
<dateSeparator
fixed = boolean : false
id = ID
value = '-' | '.' | '/'
...
>
( )
...
</dateSeparator>

(
fixed, id, value) , .
date,
dateSeparator.
,
XML-. 10 specialDate,
.
dateSeparator.

10. ,

<xs:simpleType name="specialDate">
<xs:restriction base="xyz:date">
<xyz:dateSeparator value="/" />
<xs:restriction>
</xs:simpleType>

"2008/11/01" , "2008-11-01" "2008.11.01" .

XML Schema 1.1,


c XML Schema 1.0.
, ,
.
, ,
,
.
, , ,
.

XML Schema 1.1: 1.

12 16

ibm.com/developerWorks/ru/

developerWorks

: XML Schema 1.1, 1: . (EN)


XML: XML, ,
, SGML Web. (EN)
XML Schema, 1: ( ): XML
Schema, W3C, ,
XML 1.0, ,
XML .
"XML Schema,
2: ". (EN)
XML Schema, 2: ( ):
, XML Schema. (EN)
XML Schema W3C (XSD) 1.1, 1: :
XML Schema, W3C. (EN)
XML Schema W3C (XSD) 1.1, 1: :
, XML
Schema. (EN)
XQuery 1.0: XML Query,
, XML. (EN)
XML Path 2.0: XPath. (EN)
XSL (XSLT) 2.0: ,
XSLT 2.0. (EN)
XQuery 1.0 XPath 2.0 (XDM): W3C,
XPath 2.0, XSLT 2.0 XQuery. (EN)
Schematron,
() XML.
(EN)
RELAX NG XML-. (EN)
XML IBM: ,
IBM XML . (EN)
XML, , ,
, IBM Redbooks. (EN)
Web- developerWorks:
. (EN)
,
. (EN)
developerWorks: ,
. (EN)

Xerces2-J - XML- Java, Apache. (EN)
XML Schema 1.1: 1.

13 16

developerWorks

ibm.com/developerWorks/ru/

IBM
DB2,
Lotus, Rational, Tivoli WebSphere. (EN)

.
.
developerWorks . (EN)

XML Schema 1.1: 1.

14 16

ibm.com/developerWorks/ru/

developerWorks



(Neil Delima) IBM
.
XML- XML-.
Apache Xerces ( XML- Java).
, W3C DOM XML 1.1.


() (Sandy (Shudi) Gao)
IBM . Apache
Xerces c 2001 , XML Schema Xerces
. XML Schema
W3C IBM 2003 . XML Schema
1.1 , 2006 .
, IBM W3C SML.


(Michael Glavassevich)
XML- IBM .
Apache Xerces 2,
XML Schema, XInclude, JAXP 1.3/1.4
DOM Level 3. IBM JAXP,
JAXP 1.4.


(Khaled Noaman) XML IBM .
++- Apache Xerces ,
XML Schema.
Copyright IBM Corporation 2010
(www.ibm.com/legal/copytrade.shtml)

(www.ibm.com/developerworks/ru/ibm/trademarks/)
XML Schema 1.1: 1.

15 16

developerWorks

XML Schema 1.1: 1.

ibm.com/developerWorks/ru/

16 16