XML Schema XML schema é um vocabulário XML para expressar regras de negócios (sobre os dados).
Transcript of XML Schema XML schema é um vocabulário XML para expressar regras de negócios (sobre os dados).
XML Schema
http://www.w3.org/TR/xmlschema
XML schema é um vocabulário XML para expressar regras de negócios (sobre os dados).
Exemplo
<localização><latitude>32.904237</latitude><longitude>73.620290</longitude>
<incerteza unidades="metros">2</incerteza>
</localização>
° A localização precisa ser seguida de uma latitude e de uma longitude e do grau de incerteza que envolve as medidas;
° A latitude precisa ser um decimal com um valor entre -90 e 90
° A longitude precisa ser um decimal com um valor entre -180 e 180
Validando os dados:
XML Schema
XML Schemavalidatorchecar a latitude
checar a longitude
etc....
<localização>
<latitude>32.904237</latitude><longitude>73.620290</longitude>
<incerteza unidades="metros">2</incerteza>
</localização>
Proposta do schema XML
Especificar a estrutura das instâncias dos documentos!
Definir o tipo de dados (datatype) de cada elemento/atributo!
Exemplo de um esquema Schema XML
BookStore.xsd
<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Book"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Author" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Date" minOccurs="1" maxOccurs="1"/> <xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/></xsd:schema>
xsd = XML Schema Definition
<!ELEMENT BookStore (Book+)>
<!ELEMENT Book (Title, Author, Date, ISBN, Publisher)>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Author (#PCDATA)>
<!ELEMENT Date (#PCDATA)>
<!ELEMENT ISBN (#PCDATA)>
<!ELEMENT Publisher (#PCDATA)>
DTD de uma Livraria (BookStore)
DTD equivalente ao Schema XML exemplificado
<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element>
<xsd:element name="Book"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Author" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Date" minOccurs="1" maxOccurs="1"/> <xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element>
<xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/></xsd:schema>
<!ELEMENT BookStore (Book+)>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Date (#PCDATA)>
<!ELEMENT ISBN (#PCDATA)>
<!ELEMENT Publisher (#PCDATA)>
<!ELEMENT Author (#PCDATA)>
<!ELEMENT Book (Title, Author, Date,
ISBN, Publisher)>
<xsd:element name="name" type="type" minOccurs="int" maxOccurs="int"/>
Declaração de elementos:
Tipo simples (xsd:string) ou complexo.
Inteiro não negativo. Inteiro não negativo ou
‘unbounded’.
<xsd:element name="name" type="xsd:string" />
Alternativa
Default: minOccurs=1 e maxOccurs=1
<?xml version="1.0"?>
<xsd:schemaxmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.books.org"
xmlns="http://www.books.org“elementFormDefault="qualified"><xsd:element name="BookStore">
<xsd:complexType><xsd:sequence>
</xsd:sequence></xsd:complexType>
</xsd:element><xsd:element name="Book">
<xsd:complexType><xsd:sequence>
<xsd:element ref="Title" minOccurs="1" maxOccurs="1"/><xsd:element ref="Author" minOccurs="1" maxOccurs="1"/><xsd:element ref="Date" minOccurs="1" maxOccurs="1"/><xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/><xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/>
</xsd:sequence></xsd:complexType>
</xsd:element><xsd:element name="Title" type="xsd:string"/><xsd:element name="Author" type="xsd:string"/><xsd:element name="Date" type="xsd:string"/><xsd:element name="ISBN" type="xsd:string"/>
<xsd:element name="Publisher" type="xsd:string"/></xsd:schema>
<xsd:element ref="Book" minOccurs="1" maxOccurs= "unbounded"/>
<xsd:element name="name" type="type" minOccurs="int" maxOccurs="int"/>
Declaração de elementos:
Tipo simples (xsd:string) ou complexo.
Inteiro não negativo. Inteiro não negativo ou
‘unbounded’.
<xsd:element name="name" minOccurs="int" maxOccurs="int"><xsd:complexType>
...</xsd:complexType>
</xsd:element>
Alternativa
<?xml version="1.0"?>
<xsd:schemaxmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.books.org"
xmlns="http://www.books.org"elementFormDefault="qualified"><xsd:element name="BookStore">
<xsd:complexType><xsd:sequence>
</xsd:sequence></xsd:complexType>
</xsd:element><xsd:element name="Book">
<xsd:complexType><xsd:sequence>
<xsd:element ref="Title" minOccurs="1" maxOccurs ="1"/><xsd:element ref="Author" minOccurs="1" maxOccur s="1"/><xsd:element ref="Date" minOccurs="1" maxOccurs ="1"/><xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/></xsd:sequence>
</xsd:complexType></xsd:element>
<xsd:element name="Title" type="xsd:string"/><xsd:element name="Author" type="xsd:string"/><xsd:element name="Date" type="xsd:string"/><xsd:element name="ISBN" type="xsd:string"/>
<xsd:element name="Publisher" type="xsd:string"/></xsd:schema>
<xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/>
<xsd:element name="BookStore">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element>
<xsd:sequence>
<!ELEMENT BookStore (Book+)>
Book +
<?xml version="1.0"?>
<xsd:schemaxmlns:xsd="http://www+.w3.org/2001/XMLSchema"
targetNamespace="http://www.books.org"
xmlns="http://www.books.org" elementFormDefault="qualified"><xsd:element name="BookStore">
<xsd:complexType><xsd:sequence>
</xsd:sequence></xsd:complexType>
</xsd:element><xsd:element name="Book">
<xsd:complexType><xsd:sequence>
<xsd:element ref="Title" minOccurs="1" maxOccurs ="1"/><xsd:element ref="Author" minOccurs="1" maxOccurs="1"/><xsd:element ref="Date" minOccurs="1" maxOccurs="1"/><xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/><xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/>
</xsd:sequence></xsd:complexType>
</xsd:element>
<xsd:element name="Title" type="xsd:string"/><xsd:element name="Author" type="xsd:string"/><xsd:element name="Date" type="xsd:string"/><xsd:element name="ISBN" type="xsd:string"/>
<xsd:element name="Publisher" type="xsd:string"/></xsd:schema>
<xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/>
<xsd:element name="Book"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType></xsd:element>
<!ELEMENT Book (Title, Author, Date, ISBN, Publisher)>
<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element name="Book" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element></xsd:schema>
Nomes para tipos complexos
Sem nome
Declaração Inline
<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element name="Book" type="BookPublication" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:complexType name="BookPublication"> <xsd:sequence> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/> </xsd:sequence> </xsd:complexType></xsd:schema>
Nomes para tipos complexos
Vantagem: reutilização!
Tipo de dados do usuário
<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:simpleType name="ISBNType"> <xsd:restriction base="xsd:string"> <xsd:pattern value="\d{1}-\d{5}-\d{3}-\d{1}"/> <xsd:pattern value="\d{1}-\d{3}-\d{5}-\d{1}"/> <xsd:pattern value="\d{1}-\d{2}-\d{6}-\d{1}"/> </xsd:restriction> </xsd:simpleType> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element name="Book" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:gYear"/> <xsd:element name="ISBN" type="ISBNType"/> <xsd:element name="Publisher" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element></xsd:schema>
Declaração de ISBN como do tipo ISBNType
Definição de um novo tipo de dados
<xsd:simpleType name="TelephoneNumber"> <xsd:restriction base="xsd:string"> <xsd:length value="8"/> <xsd:pattern value="\d{3}-\d{4}"/> </xsd:restriction></xsd:simpleType>
Outros Exemplos
Restringe um tipo string a no máximo 8 caracteres, seguindo um padrão: 3 dígitos seguido por um traço (-) e mais 4 dígitos.
Outros Exemplos
<xsd:simpleType name="shape"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="circle"/> <xsd:enumeration value="triangle"/> <xsd:enumeration value="square"/> </xsd:restriction></xsd:simpleType>
Restringe um tipo string aos valores ‘circle’, ‘triangle’ e ‘square’.
Outros Exemplos
<xsd:simpleType name= "EarthSurfaceElevation"> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="-1290"/> <xsd:maxInclusive value="29035"/> </xsd:restriction></xsd:simpleType>
Restringe um tipo integer a um valor mínimo igual a -1290 e máximo igual a 29035.
<xsd:element name="name" type="
type" minOccurs="int" maxOccurs="int"/>
<xsd:element name="name" minOccurs="int" maxOccurs="int"> <xsd:complexType>
... </xsd:complexType></xsd:element>
1
2
<xsd:element name="name" minOccurs="int" maxOccurs="int "> <xsd:simpleType>
<xsd:restriction base="type"> ...
</xsd:restriction> </xsd:simpleType></xsd:element>
3
Resumo de declaração de Elementos
Tipos Derivados
Formam uma subclasse de tipos complexos
1. Derivados por extensão: estendem o tipo complexo pai com mais elementos
2. Derivados por restrição: criam um tipo que é um subconjunto do tipo base.
2.1. Redefinir um elemento tipo base para ter uma restrição sobre os valores possíveis;
2.2. OU redefinir um elemento tipo base para ter uma restrição sobre o número de ocorrências;
<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.books.org"xmlns="http://www.books.org"
elementFormDefault="qualified"><xsd:complexType name="Publication">
<xsd:sequence><xsd:element name="Title" type="xsd:string" maxOccurs="unbounded"/><xsd:element name="Author" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="Date" type="xsd:gYear"/></xsd:sequence>
</xsd:complexType><xsd:complexType name="BookPublication">
<xsd:complexContent><xsd:extensionbase="Publication"><xsd:sequence>
<xsd:element name="ISBN" type="xsd:string"/><xsd:element name="Publisher" type="xsd:string"/>
</xsd:sequence></xsd:extension>
</xsd:complexContent></xsd:complexType>
<xsd:element name="BookStore"><xsd:complexType>
<xsd:sequence><xsd:element name="Book" type="BookPublication"maxOccurs="unbounded"/></xsd:sequence>
</xsd:complexType></xsd:element>
</xsd:schema>
Derivando por extensão:
BookPublication estende a Publication
<xsd:complexType name="Publication"> <xsd:sequence> <xsd:element name="Title" type="xsd:string" maxOccurs="unbounded"/> <xsd:element name="Author" type="xsd:string" maxOccurs="unbounded"/> <xsd:element name="Date" type="xsd:gYear"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="BookPublication"> <xsd:complexContent> <xsd:extension base="Publication" > <xsd:sequence> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/> </xsd:sequence> </xsd:extension> </xsd:complexContent></xsd:complexType>
O tipo Publication passa a ter 05 elementos!
Title
AuthorDate
Publication
ISBN
Publisher
BookPublication
<xsd:complexType name="Publication"><xsd:sequence>
<xsd:element name="Title" type="xsd:string" maxOccurs="unbounded"/><xsd:element name="Author" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="Date" type="xsd:gYear"/></xsd:sequence>
</xsd:complexType><xsd:complexType name= "SingleAuthorPublication">
<xsd:complexContent><xsd:restrictionbase="Publication"><xsd:sequence>
<xsd:element name="Title" type="xsd:string" maxOccurs="unbounded"/><xsd:element name="Author" type="xsd:string"/><xsd:element name="Date" type="xsd:gYear"/></xsd:sequence>
</xsd:restriction></xsd:complexContent>
</xsd:complexType>
Derivando por restrição:
Note que SingleAuthorPublication tem apenas três elementos e o elemento Author aparecerá apenas 1 vez!
<!ELEMENT BookStore (Book)+><!ELEMENT Book (Title, Author+, Date, ISBN, Publisher)>
<!ATTLIST Book Category (autobiography | non fiction | fiction) #REQUIRED-
InStock (true | false) "false"Reviewer CDATA " ">
<!ELEMENT Title (#PCDATA)><!ELEMENT Author (#PCDATA)><!ELEMENT Date (#PCDATA)><!ELEMENT ISBN (#PCDATA)>
<!ELEMENT Publisher (#PCDATA)><!ELEMENT Month (#PCDATA)><!ELEMENT Year (#PCDATA)>
BookStore.dtd
Declaração de Atributos
xsd:string
xsd:integerxsd:boolean...
required
optional
prohibited
Obs.:se for usar valor default, não usar a opção "use"
<xsd:simpleType><xsd:restriction base=" tipo simples" >
<xsd:facetvalue="valor”/>...
</xsd:restriction></xsd:simpleType>
</xsd:attribute>
2. <xsd:attribute name="nome" type="tipo simples" default/fixed="valor"/>
1.<xsd:attribute name="nome" type="tipo simples" use="forma de uso" default/fixed="valor"/>
Declaração de Atributos
<xsd:element name="BookStore"><xsd:complexType>
<xsd:sequence><xsd:element name="Book" maxOccurs="unbounded">
<xsd:complexType><xsd:sequence>
<xsd:element name="Title" type="xsd:string"/><xsd:element name="Author" type="xsd:string" maxOccurs="unbounded"/><xsd:element name="Date" type="xsd:string"/><xsd:element name="ISBN" type="xsd:string"/><xsd:element name="Publisher" type=" xsd:string"/>
</xsd:sequence><xsd:attributeGroup ref="BookAttributes"/>
</xsd:complexType></xsd:element>
</xsd:sequence></xsd:complexType>
</xsd:element><xsd:attributeGroup name="BookAttributes"> <xsd:attribute name="Category" use="required">
<xsd:simpleType><xsd:restriction base="xsd:string"><xsd:enumeration value="autobiography"/>
<xsd:enumeration value="non fiction"/><xsd:enumeration value="fiction"/></xsd:restriction>
</xsd:simpleType></xsd:attribute>
<xsd:attribute name="InStock" type="xsd:boolean" default ="false"/><xsd:attribute name="Reviewer" type="xsd:string" default =" "/>
</xsd:attributeGroup>
Category (autobiography | non fiction | fiction) #REQUIRED-
InStock (true | false) "false"Reviewer CDATA " "
<xsd:attribute name="Category" use="required">
<xsd:simpleType><xsd:restriction base="xsd:string">
<xsd:enumeration value="autobiography"/>
<xsd:enumeration value="non
-
fiction"/>
<xsd:enumeration value="fiction"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
- Instâncias dos documentos têm que obrigatoriamente ter o atributo Categoria.
- Os atributos são sempre simples, ou seja, não podem ter elementos filhos.
<xsd:element name="Book" maxOccurs="unbounded"><xsd:complexType>
<xsd:sequence><xsd:element name="Title" type="xsd:string"/><xsd:element name="Author" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="Date" type="xsd:string"/><xsd:element name="ISBN" type="xsd:string"/><xsd:element name="Publisher" type="xsd:string"/>
</xsd:sequence><xsd:attribute name="Category" use="required">
<xsd:simpleType><xsd:restriction base="xsd:string">
<xsd:enumeration value="autobiography"/><xsd:enumeration value="non
-
fiction"/><xsd:enumeration value="fiction"/></xsd:restriction>
</xsd:simpleType></xsd:attribute>
<xsd:attribute name="InStock" type="xsd:boolean" default="false"/>
<xsd:attribute name="Reviewer" type="xsd:string" default=" "/>
</xsd:complexType></xsd:element>
Declarando o atributo no próprio elemento
elementcomplexType
schema
sequence
http://www.w3.org/2001/XMLSchema
XMLSchema Namespace
string
integer
boolean
<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Book"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Author" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Date" minOccurs="1" maxOccurs="1"/> <xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/></xsd:schema>
Indica que os elementos definidos por esse esquema: - BookStore - Book - Title - Author - Date - ISBN - Publisherestarão no namespacehttp://www.books.org
BookStore
BookTitle
Author
Date
ISBNPublisher
http://www.books.org (targetNamespace)
Book Namespace (targetNamespace)
<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Book"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Author" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Date" minOccurs="1" maxOccurs="1"/> <xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/></xsd:schema>
Referência ao elemento Book, declarado no namespace padrão
O namespace padrão é http://www.books.org, que também é o targetNamespace
Tipos de dados primitivos• Primitive Datatypes
– string
– boolean
– decimal
– float
– double
– duration
– dateTime
– time
– date
– gYearMonth
– gYear
– gMonthDay
– gDay
– gMonth
– hexBinary
– base64Binary
– anyURI
– QName
– NOTATION
• Atomic, built-in
– "Hello World"
– {true, false, 1, 0}
– 7.08
– 12.56E3, 12, 12560, 0, -0, INF, -INF, NAN
– 12.56E3, 12, 12560, 0, -0, INF, -INF, NAN
– P1Y2M3DT10H30M12.3S
– format: CCYY-MM-DDThh:mm:ss
– format: hh:mm:ss.sss
– format: CCYY-MM-DD
– format: CCYY-MM
– format: CCYY
– format: --MM-DD
– format: ---DD (note the 3 dashes)
– format: --MM--
– a hex string
– a base64 string
– http://www.xfront.com
– a namespace qualified name
– a NOTATION from the XML spec
Note: 'T' is the date/time separator INF = infinity NAN = not-a-number
• Derived types
– normalizedString
– token
– language
– IDREFS
– ENTITIES
– NMTOKEN
– NMTOKENS
– Name
– NCName
– ID
– IDREF
– ENTITY
– integer
– nonPositiveInteger
– negativeInteger
– long
– int
– short
– byte
– nonNegativeInteger
– unsignedLong
– unsignedInt
– unsignedShort
– unsignedByte
– positiveInteger
• Subtype of primitive datatype
– A string without tabs, line feeds, or carriage returns– String w/o tabs, l/f, leading/trailing spaces, consecutive spaces
– any valid xml:lang value, e.g., EN, FR, ...
– usado somente com atributos
– usado somente com atributos
– usado somente com atributos
– usado somente com atributos
– part (no namespace qualifier)
– usado somente com atributos
– usado somente com atributos
– usado somente com atributos
– 456
– infinito negativo a 0
– infinito negativo a -1
– -9223372036854775808 to 9223372036854775807
– -2147483648 to 2147483647
– -32768 to 32767
– -127 to 128
– 0 to infinity
– 0 to 18446744073709551615
– 0 to 4294967295
– 0 to 65535
– 0 to 255
– 1 to infinity
Tip
os d
e da
dos
prim
itivo
s (c
ont.
)
<xsd:simpleType name= "name"> <xsd:restriction base= "xsd:source"> <xsd:facet value= "value"/> <xsd:facet value= "value"/> … </xsd:restriction></xsd:simpleType>
Facets: - length - minlength - maxlength - pattern - enumeration - totalDigits - minInclusive - maxInclusive - minExclusive - maxExclusive ...
Sources: - string - boolean - number - float - double - duration - dateTime - time ...
Forma geral para a especificação de valores de novos tipos