Você está na página 1de 7

Welcome to:

Additional Information for XML Schema

Copyright IBM Corporation 2004


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

3.1

"Table 2. Simple Types


Built In to XML Schema"*
Simple Type
string
normalizedString
token
byte
unsignedByte
base64Binary
hexBinary
integer
...

Examples (delimited by commas)


Confirm this is electric
Confirm this is electric
Confirm this is electric
-1, 126
0, 126
GpM7
0FB7
-126789, -1, 0, 1, 126789

Notes
see (3)
see (4)
see (2)
see (2)

see (2)

Notes: (1) To retain compatibility between XML Schema and XML 1.0 DTDs, the simple types ID, IDREF, IDREFS, ENTITY,
ENTITIES, NOTATION, NMTOKEN, NMTOKENS should only be used in attributes. (2) A value of this type can be represented by
more than one lexical format, e.g. 100 and 1.0E2 are both valid float formats representing "one hundred". However, rules have
been established for this type that define a canonical lexical format, see XML Schema Part 2. (3) Newline, tab and carriage-return
characters in a normalizedString type are converted to space characters before schema processing. (4) As normalizedString, and
adjacent space characters are collapsed to a single space character, and leading and trailing spaces are removed. (5) The "g"
prefix signals time periods in the Gregorian calender. otes: (1) To retain compatibility between XML Schema and XML 1.0 DTDs,
the simple types ID, IDREF, IDREFS, ENTITY, ENTITIES, NOTATION, NMTOKEN, NMTOKENS should only be used in
attributes. (2) A value of this type can be represented by more than one lexical format, e.g. 100 and 1.0E2 are both valid float
formats representing "one hundred". However, rules have been established for this type that define a canonical lexical format,
see XML Schema Part 2. (3) Newline, tab and carriage-return characters in a normalizedString type are converted to space
characters before schema processing. (4) As normalizedString, and adjacent space characters are collapsed to a single space
character, and leading and trailing spaces are removed. (5) The "g" prefix signals time periods in the Gregorian calender.

*Excerpt from table of the same name in the 20010502 Primer.


Copyright IBM Corporation 2004

Pattern Facet
<schema xmlns='http://www.w3.org/2001/XMLSchema'>
<simpleType name='DNAType'>
<restriction base='string'>
<pattern value='(A|G|T|C)+'/>
</restriction>
</simpleType>
<element name='DNA' type='DNAType/>
</schema>
Valid XML:
<DNA>AGCTATATACGGTAACGTA</DNA>
Invalid XML:
<DNA>AGTBCTGAEC</DNA>
<DNA>10100011011</DNA>"

Copyright IBM Corporation 2004

List Simple Type


Allows definition of a simple type as a sequence of values from a
single simple type. This type must allow whitespace in its lexical
space. The list is an aggregate of simple type values.
The elements of a list are separated by whitespace.
Built in list types (needed for XML 1.0)

NMTOKENS
IDREFS
ENTITIES

Copyright IBM Corporation 2004

List Simple Type Example


We will use the DNAType from a previous example to declare a new
element called 'DNASamples', which is a list of type 'DNAType'.
Declaration
<schema xmlns='http://www.w3.org/2001/XMLSchema'>
<element name='DNASamples'>
<simpleType>
<list itemType='DNAType'/>
</simpleType>
</element>
</schema>
Valid XML:
<DNASamples>AGCTA TATAC GGTAA CGTA</DNASamples>
Invalid XML:
</DNASamples>AGCTA:TATC:GATTA</DNASamples>
</DNASamples>AGCTA,TATC,GATTA</DNASamples>

Copyright IBM Corporation 2004

Union Simple Type (1 of 2)


Allows you to create a new simple type whose instances must match the rules
for one of the member simple types which is specified in the union.
Example: Union type creates an interval with a "hole"
Schema
<schema xmlns='http://www.w3.org/2001/XMLSchema'>
<simpleType name='biggerThanFive'>
<restriction base='integer'>
<minExclusive value='5'/>
</restriction>
</simpleType>
<simpleType name='lessThanZero'>
<restriction base='integer'>
<maxExclusive value='0'/>
</restriction>
</simpleType>
<element name='interval'>
<simpleType>
<union memberTypes='biggerThanFive lessThanZero'/>
</simpleType>
</element>
</schema>
Copyright IBM Corporation 2004

Union Simple Type (2 of 2)


Valid XML:
<interval>-1</interval>
<interval>8</interval>
Invalid XML:
<interval>0</interval>
<interval>4</interval>

Copyright IBM Corporation 2004

Você também pode gostar