Mdulo II Introduo a XMLSchema Prof Ismael H

  • Slides: 133
Download presentation
Módulo II Introdução a XMLSchema Prof. Ismael H F Santos April 05 Prof. Ismael

Módulo II Introdução a XMLSchema Prof. Ismael H F Santos April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 1

Ementa n Modulo II – XML Schema n n n April 05 Revisão de

Ementa n Modulo II – XML Schema n n n April 05 Revisão de XML - Extensible Markup Language XML Validação n DTD n XMLSchema n DTD x XMLSchema XML Processing - XSLT Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 2

Bibliografia n Linguagem de Programação JAVA n April 05 Ismael H. F. Santos, Apostila

Bibliografia n Linguagem de Programação JAVA n April 05 Ismael H. F. Santos, Apostila Univer. Cidade, 2002 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 3

Livros n Core Java 2, Cay S. Horstmann, Gary Cornell Volume 1 (Fundamentos) n

Livros n Core Java 2, Cay S. Horstmann, Gary Cornell Volume 1 (Fundamentos) n Volume 2 (Características Avançadas) n Java: Como Programar, Deitel & Deitel n Thinking in Patterns with JAVA, Bruce Eckel n Gratuito. http: //www. mindview. net/Books/TIJ/ n April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 4

SOA April 05 Revisão XML Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

SOA April 05 Revisão XML Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 5

What is XML n XML stands for extensible markup language n It is a

What is XML n XML stands for extensible markup language n It is a hierarchical data description language n It is a sub set of SGML a general document markup language designed for the American millitary. n It is defined by w 3 c. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 6

XML – Extensible Markup Language n XML é um documento de Texto n Dois

XML – Extensible Markup Language n XML é um documento de Texto n Dois tipos de elementos Marcação – Guarda a estrutura do documento n Dados – Informação propriamente dita n Uma maneira de representar informação n não é uma linguagem específica n não define vocabulário de comandos n não define uma gramática, apenas regras mínimas n Exemplo: n April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 7

Anatomia de um documento XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf.

Anatomia de um documento XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 8

How does XML differ from HTML? n HTML is a presentation markup language –

How does XML differ from HTML? n HTML is a presentation markup language – provides no information about content. n There is only one standard definition of all of the tags used in HTML. n XML can define both presentation style and give information about content. n XML relies on custom documents defining the meaning of tags. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 9

XML x HTML n HTML mostra como apresentar n XML mostra o que significa

XML x HTML n HTML mostra como apresentar n XML mostra o que significa April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 10

Por que usar XML para compartilhar dados? n Porque é um padrão aberto n

Por que usar XML para compartilhar dados? n Porque é um padrão aberto n Facilidade para converter para formatos proprietários n Porque é texto n Fácil de ler, fácil de processar, menos incompatibilidades n Porque promove a separação entre estrutura, conteúdo e apresentação n n Facilita geração de dados para visualização dinâmica Evita repetição de informação / simplifica manutenção n Porque permitirá semântica na Web n Elementos HTML não carregam significado, apenas dicas de formatação: mecanismos de busca ficam prejudicados n Solução com XML dependerá de suporte dos clientes April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 11

Componentes de um documento XML n Árvore XML n nós, n raiz, n galhos

Componentes de um documento XML n Árvore XML n nós, n raiz, n galhos e n folhas n Prólogo n Comentários n Instruções de processamento n Elementos n Atributos n Nós de texto n Entidades April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 12

Partes de um documento XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf.

Partes de um documento XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 13

Árvore XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 14

Árvore XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 14

Estrutura XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 15

Estrutura XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 15

Prólogo XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 16

Prólogo XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 16

Nó raiz e elementos April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio.

Nó raiz e elementos April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 17

Atributos April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 18

Atributos April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 18

Nós de Texto April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

Nós de Texto April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 19

A minimal XML document value <? xml version=“ 1. 0” ? > <document name=“first”>Jim</document>

A minimal XML document value <? xml version=“ 1. 0” ? > <document name=“first”>Jim</document> A tag An attribute April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br Closing tag 20

Entidades April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 21

Entidades April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 21

Entidades de caracteres April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

Entidades de caracteres April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 22

Elementos e Atributos April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

Elementos e Atributos April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 23

Elementos e Atributos (2) April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio.

Elementos e Atributos (2) April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 24

Quando usar elementos/atributos n Questão de design n Elementos geralmente referem-se a coisas que

Quando usar elementos/atributos n Questão de design n Elementos geralmente referem-se a coisas que têm atributos n Atributos geralmente são características dessas coisas que podem ser descritas com poucas palavras n Questão de suporte tecnológico n Atributos não podem conter subelementos n Atributos são mais fáceis de serem validados num DTD April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 25

Identificadores n Nomes de atributos e elementos n Podem conter n qualquer caractere alfanumérico

Identificadores n Nomes de atributos e elementos n Podem conter n qualquer caractere alfanumérico ou ideograma n. (ponto) n - (hífen) n _ (sublinhado) n Não podem começar com n ponto, n hífen ou n número April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 26

Identificadores (2) April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 27

Identificadores (2) April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 27

Conteúdo misto April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 28

Conteúdo misto April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 28

Seção CDATA (Character DATA) April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio.

Seção CDATA (Character DATA) April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 29

Instruções de processamento April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

Instruções de processamento April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 30

Declaração XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 31

Declaração XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 31

Using namespaces in XML n To fully qualify a namespace in XML write the

Using namespaces in XML n To fully qualify a namespace in XML write the namespace: tag name. eg. <my_namespace: tag> </my_namespace: tag> n In a globally declared single namespace the qualifier may be omitted. n More than one namespace: <my_namespace: tag> </my_namespace: tag> <your_namespace: tag> </your_namespace: tag> can co-exist if correctly qualified. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 32

Using namespaces in XML n To fully qualify a namespace in XML write the

Using namespaces in XML n To fully qualify a namespace in XML write the namespace: tag name. eg. <my_namespace: tag> </my_namespace: tag> n In a globally declared single namespace the qualifier may be omitted. n More than one namespace: <my_namespace: tag> </my_namespace: tag> <your_namespace: tag> </your_namespace: tag> can co-exist if correctly qualified. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 33

XML Namespaces April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 34

XML Namespaces April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 34

XML Namespaces n Limita o escopo de elementos Evita conflitos quando duas linguagens se

XML Namespaces n Limita o escopo de elementos Evita conflitos quando duas linguagens se cruzam no mesmo documento n Consiste da associação de um identificador a cada elemento/atributo da linguagem, que pode ser n herdado através do escopo de uma sub-árvore n atribuído explicitamente através de um prefixo n April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 35

Outro Exemplo April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 36

Outro Exemplo April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 36

Exemplo com 3 Namespaces April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio.

Exemplo com 3 Namespaces April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 37

Namespace Ilustration April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 38

Namespace Ilustration April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 38

SOA April 05 XML Validação Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

SOA April 05 XML Validação Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 39

Problemas do XML n An XML element name may not mean the same thing

Problemas do XML n An XML element name may not mean the same thing in different XML files n XML on its own doesn’t specify allowable elements n New elements may be added without breaking applications – but applications won’t recognize them n XML on its own doesn’t mandate a structure n XML on its own doesn’t enforce data types April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 40

Documento XML bem-formado n Documento bem-formado n ter um único elemento raiz n etiquetas

Documento XML bem-formado n Documento bem-formado n ter um único elemento raiz n etiquetas iniciais e finais combinam (levando em conta que caracteres maiúsculos e minúsculos são diferentes) n elementos bem aninhados n valores de atributos entre aspas ou apóstrofes n atributos não repetidos n identificadores válidos para elementos e atributos n comentários não devem aparecer dentro das etiquetas n sinais < ou & nunca devem ocorrer dentro dos valores dos atributos ou nos nós de texto do documento. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 41

XML Solution – Schemas n An XML Schema defines the legal building blocks of

XML Solution – Schemas n An XML Schema defines the legal building blocks of an XML document. It mandates: elements that can appear in a document n attributes that can be used for a given element n which elements are parent elements and which elements are child elements n the order of child elements n data types for elements and attributes n allowable values for elements and attributes n April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 42

Por que validar ? April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio.

Por que validar ? April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 43

Valid and well formed n A correct XML document must be both valid and

Valid and well formed n A correct XML document must be both valid and well formed. n Well formed means that the syntax must be correct and all tags must close correctly (eg <…> </…>). n Valid means that the document must conform to some XML definition ( a DTD or Schema). (Otherwise there can be no definition of what the tags mean) April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 44

Definindo um Esquema XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio.

Definindo um Esquema XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 45

Classes x Instâncias April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

Classes x Instâncias April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 46

Documentos Válidos April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 47

Documentos Válidos April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 47

O que define um Esquema XML DTD Documento Válido April 05 Prof. Ismael H.

O que define um Esquema XML DTD Documento Válido April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 48

Documentos não-válidos n Diga porque os documentos são não-válidos ? Falta elemento sobrenome Elemento

Documentos não-válidos n Diga porque os documentos são não-válidos ? Falta elemento sobrenome Elemento profissão não pode vir antes do elemento nome April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 49

What is a Schema? n A schema is the definition of the meaning of

What is a Schema? n A schema is the definition of the meaning of each of the tags within a XML document. n Analogy: A HTML style sheet can be seen as a limited schema which only specifies the presentational style of HTML which refers to it. n Example: in HTML the tag <strong> pre-defined. In XML you would need to define this in the context of your document. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 50

Namespaces e XML Schema April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio.

Namespaces e XML Schema April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 51

XML válido n Um XML bem construído pode não ser válido em determinada aplicação

XML válido n Um XML bem construído pode não ser válido em determinada aplicação n Aplicação típica pode esperar que n n n elementos façam parte de um vocabulário limitado, certos atributos tenham valores e tipos definidos, elementos sejam organizados de acordo com uma determinada estrutura hierárquica, etc. n É preciso especificar a linguagem! n Esquema: modelo que descreve todos os elementos, atributos, entidades, suas relações e tipos de dados n Um documento XML é considerado válido em relação a um esquema se obedecer todas as suas regras April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 52

Esquemas XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 53

Esquemas XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 53

DTD vs. XML Schema April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio.

DTD vs. XML Schema April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 54

Schema <? xml version="1. 0"? > <xs: schema xmlns: xs=http: //www. w 3. org/2001/XMLSchema

Schema <? xml version="1. 0"? > <xs: schema xmlns: xs=http: //www. w 3. org/2001/XMLSchema xmlns=“document" > <xs: element name = “DOCUMENT”> <xs: element name=“CUSTOMER"> </xs: element> </xs: schema> <? xml version=“ 1. 0”? > <DOCUMENT xmlns=“document” xmlns: xsi="http: //www. w 3. org/2001/XMLSchema-instance" Xsi: schema. Location=“order. xsd”> <DOCUMENT> <CUSTOMER>sam smith</CUSTOMER> </DOCUMENT> April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br Simple schema saved as order. xsd XML document derived from schema. 55

SOA XMLSchema April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 56

SOA XMLSchema April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 56

Namespaces e XML Schema April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio.

Namespaces e XML Schema April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 57

Documentos XML bem formados n Para que possa ser manipulado como uma árvore, um

Documentos XML bem formados n Para que possa ser manipulado como uma árvore, um documento XML precisa ser bem formado n Documentos que não são bem formados não são documentos XML n Documentos bem-formados obedecem as regras de construção de documentos XML genéricos n Regras incluem n n n Ter um, e apenas um, elemento raiz Valores dos atributos estarem entre aspas ou apóstrofes Atributos não se repetirem Todos os elementos terem etiqueta de fechamento Elementos estarem corretamente aninhados April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 58

XML válido n Um XML bem construído pode não ser válido em determinada aplicação

XML válido n Um XML bem construído pode não ser válido em determinada aplicação n Aplicação típica pode esperar que n n n elementos façam parte de um vocabulário limitado, certos atributos tenham valores e tipos definidos, elementos sejam organizados de acordo com uma determinada estrutura hierárquica, etc. n É preciso especificar a linguagem! n Esquema: modelo que descreve todos os elementos, atributos, entidades, suas relações e tipos de dados n Um documento XML é considerado válido em relação a um esquema se obedecer todas as suas regras April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 59

Esquemas XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 60

Esquemas XML April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 60

Basic XML Schema concepts n n n Syntax is not the Schema Namespaces are

Basic XML Schema concepts n n n Syntax is not the Schema Namespaces are fundamental But a schema is not a namespace Separation of tag from type Simple and Complex types Modular Schema construction Powerful type construction Local tag-type association Powerful wildcards Element equivalence classes Extension mechanism Documentation mechanism April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 61

XML Schemas n What is an XML Schema? n The purpose of an XML

XML Schemas n What is an XML Schema? n The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD. n An XML Schema: n n n n April 05 defines elements that can appear in a document defines attributes that can appear in a document defines which elements are child elements defines the order of child elements defines the number of child elements defines whether an element is empty or can include text defines data types for elements and attributes defines default and fixed values for elements and attributes Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 62 62

XML Schemas n XML Schemas are the Successors of DTDs n XML Schemas will

XML Schemas n XML Schemas are the Successors of DTDs n XML Schemas will be used in most Web applications as a replacement for DTDs. Here are some reasons: n n n April 05 XML Schemas are extensible to future additions XML Schemas are richer and more powerful than DTDs XML Schemas are written in XML Schemas support data types XML Schemas support namespaces Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 63 63

XML Schemas n XML Schemas Support Data Types n One of their greatest strengths

XML Schemas n XML Schemas Support Data Types n One of their greatest strengths n With support for data types: n It is easier to describe allowable document content n It is easier to validate the correctness of data n It is easier to work with data from a database n It is easier to define data facets (restrictions on data) n It is easier to define data patterns (data formats) n It is easier to convert data between different data types April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 64 64

XML Schemas n XML Schemas use XML Syntax n Schemas are XML documents n

XML Schemas n XML Schemas use XML Syntax n Schemas are XML documents n Benefits of Schemas as XML docs n You don't have to learn a new language You can use your XML editor to edit your Schema files You can use your XML parser to parse your Schema files You can manipulate your Schema with the XML DOM n You can transform your Schema with XSLT n n n April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 65 65

XML Schemas n XML Schemas are Extensible n XML Schemas are extensible, because XML

XML Schemas n XML Schemas are Extensible n XML Schemas are extensible, because XML is extensible n April 05 With an extensible Schema definition you can: n Reuse your Schema in other Schemas n Create your own data types derived from the standard types n Reference multiple schemas in the same document Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 66 66

XML Schemas n Well-Formed is not Enough n A well-formed XML document is a

XML Schemas n Well-Formed is not Enough n A well-formed XML document is a document that conforms to the XML syntax rules, like: n it must begin with the XML declaration n it must have one unique root element n start-tags must have matching end-tags n elements are case sensitive n all elements must be closed n all elements must be properly nested n all attribute values must be quoted n entities must be used for special characters April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 67 67

XML Schemas n Even if documents are well-formed they can still contain errors, and

XML Schemas n Even if documents are well-formed they can still contain errors, and those errors can have serious consequences. n Think of the following situation: you order 5 gross of laser printers, instead of 5 laser printers. With XML Schemas, most of these errors can be caught by your validating software. April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 68 68

XML Schemas n Simple XML Document "note. xml": <? xml version="1. 0"? > <note>

XML Schemas n Simple XML Document "note. xml": <? xml version="1. 0"? > <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 69 69

XML Schemas n An XML Schema n The following example is an XML Schema

XML Schemas n An XML Schema n The following example is an XML Schema file called "note. xsd" that defines the elements of the XML document above ("note. xml"): n April 05 The note element is a complex type because it contains other elements. The other elements (to, from, heading, body) are simple types because they do not contain other elements. Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 70 70

XML Schemas <? xml version="1. 0"? > <xs: schema xmlns: xs= target. Namespace= xmlns=

XML Schemas <? xml version="1. 0"? > <xs: schema xmlns: xs= target. Namespace= xmlns= element. Form. Default= “http: //www. w 3. org/2001/XMLSchema” “http: //www. w 3 schools. com” "qualified"> <xs: element name="note"> <xs: complex. Type> <xs: sequence> <xs: element name="to" <xs: element name="from" <xs: element name="heading" <xs: element name="body" </xs: sequence> </xs: complex. Type> </xs: element> </xs: schema> April 05 type="xs: string"/> 71 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 71

XML Schemas n This XML document has a reference to a Schema: <? xml

XML Schemas n This XML document has a reference to a Schema: <? xml version="1. 0"? > <note xmlns= “http: //www. w 3 schools. com” xmlns: xsi="http: //www. w 3. org/2001/XMLSchema instance“ xsi: schema. Location="http: //www. w 3 schools. com note. xsd"> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don'tforget me this weekend!</body> </note> April 05 72 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 72

XML Schemas n The <schema> Element n The <schema> element is the root element

XML Schemas n The <schema> Element n The <schema> element is the root element of every XML Schema: <? xml version="1. 0"? > <xs: schema>. . . </xs: schema> April 05 73 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 73

XML Schemas n The <schema> element may contain some attributes. A schema declaration often

XML Schemas n The <schema> element may contain some attributes. A schema declaration often looks something like this: <? xml version="1. 0"? > <xs: schema xmlns: xs= target. Namespace= xmlns= element. Form. Default=. . . </xs: schema> April 05 “http: //www. w 3. org/2001/XMLSchema” “http: //www. w 3 schools. com” "qualified"> 74 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 74

XML Schemas n The following fragment: xmlns: xs= “http: //www. w 3. org/2001/XMLSchema” n

XML Schemas n The following fragment: xmlns: xs= “http: //www. w 3. org/2001/XMLSchema” n Indicates that the elements and data types used in the schema come from the “http: //www. w 3. org/2001/XMLSchema" namespace. n It also specifies that the elements and data types that come from the “http: //www. w 3. org/2001/XMLSchema" namespace should be prefixed with xs: target. Namespace="http: //www. w 3 schools. com" n April 05 Indicates that the elements defined by this schema (note, to, from, heading, body. ) come from the target namespace. 75 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 75

XML Schemas xmlns=“http: //www. w 3 schools. com” n Indicates the default namespace element.

XML Schemas xmlns=“http: //www. w 3 schools. com” n Indicates the default namespace element. Form. Default="qualified" n April 05 Indicates that any elements used by the XML instance document which were declared in this schema must be namespace qualified. Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 76 76

XML Schemas n This XML document has a reference to a Schema: <? xml

XML Schemas n This XML document has a reference to a Schema: <? xml version="1. 0"? > <note xmlns= “http: //www. w 3 schools. com” xmlns: xsi="http: //www. w 3. org/2001/XMLSchema instance“ xsi: schema. Location="http: //www. w 3 schools. com note. xsd"> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don'tforget me this weekend!</body> </note> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 77 77

XML Schemas xmlns="http: //www. w 3 schools. com" n n Specifies the default namespace

XML Schemas xmlns="http: //www. w 3 schools. com" n n Specifies the default namespace declaration. Tells the schema-validator that all the elements used in this XML document are declared in this namespace. n Once the XML Schema Instance namespace is available: xmlns: xsi="http: //www. w 3. org/2001/XMLSchema-instance" n Can use the schema. Location attribute. The first value is the namespace to use. The second value is the location of the XML schema to use for that namespace: xsi: schema. Location="http: //www. w 3 schools. com note. xsd" April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 78 78

XML Schemas n Schemas define the elements of your XML files. n Simple element

XML Schemas n Schemas define the elements of your XML files. n Simple element is an XML element that contains only text. It cannot contain any other elements or attributes. n The text can be of many different types. It can be one of the types included in the XML Schema definition (boolean, string, date, etc. ), or it can be a custom type that you can define yourself. n You can also add restrictions (facets) to a data type in order to limit its content, or you can require the data to match a specific pattern. April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 79 79

XML Schemas n The syntax for defining a simple element is: <xs: element name="xxx"

XML Schemas n The syntax for defining a simple element is: <xs: element name="xxx" type="yyy"/> n Where xxx is the name of the element and yyy is the data type of the element. n XML Schema has a lot of built-in data types. The most common types are: n n n April 05 xs: string xs: decimal xs: integer xs: boolean xs: date xs: time Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 80 80

XML Schemas n Here are some simple XML elements: <lastname>Refsnes</lastname> <age>36</age> <dateborn>1970 -03 -27</dateborn>

XML Schemas n Here are some simple XML elements: <lastname>Refsnes</lastname> <age>36</age> <dateborn>1970 -03 -27</dateborn> n Here are the corresponding simple element definitions: <xs: element name="lastname" type="xs: string"/> <xs: element name="age" type="xs: integer"/> <xs: element name="dateborn" type="xs: date"/> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 81 81

XML Schemas n Simple elements may have a default value OR a fixed value

XML Schemas n Simple elements may have a default value OR a fixed value specified. n Default value is automatically assigned to the element when no other value is specified. In the following example the default value is "red": <xs: element name="color" type="xs: string" default="red"/> n Fixed value is also automatically assigned to the element, and you cannot specify another value. In the following example the fixed value is "red": <xs: element name="color" type="xs: string" fixed="red"/> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 82 82

XML Schemas n The syntax for defining an attribute is: <xs: attribute name="xxx" type="yyy"/>

XML Schemas n The syntax for defining an attribute is: <xs: attribute name="xxx" type="yyy"/> n n Where xxx is the name of the attribute and yyy specifies the data type of the attribute. Simple elements can’t have attributes! n Here is an XML element with an attribute: <lastname lang="EN">Smith</lastname> n Here is the corresponding attribute definition: <xs: attribute name="lang" type="xs: string"/> n Attributes can have default or fixed values. If the attribute is required, add use=“required” April 05 83 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 83

XML Schemas n When an XML element or attribute has a data type defined,

XML Schemas n When an XML element or attribute has a data type defined, it puts restrictions on the element's or attribute's content. n If an XML element is of type "xs: date" and contains a string like "Hello World", the element will not validate. n With XML Schemas, you can also add your own restrictions to your XML elements and attributes. April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 84 84

XML Schemas n The following example defines an element called "age" with a restriction.

XML Schemas n The following example defines an element called "age" with a restriction. The value of age cannot be lower than 0 or greater than 120: <xs: element name="age"> <xs: simple. Type> <xs: restriction base="xs: integer"> <xs: min. Inclusive value="0"/> <xs: max. Inclusive value="120"/> </xs: restriction> </xs: simple. Type> </xs: element> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 85 85

XML Schemas n The example below defines an element called "car" with a restriction.

XML Schemas n The example below defines an element called "car" with a restriction. The only acceptable values are: Audi, Golf, BMW: <xs: element name="car" type="car. Type"/> <xs: simple. Type name="car. Type"> <xs: restriction base="xs: string"> <xs: enumeration value="Audi"/> <xs: enumeration value="Golf"/> <xs: enumeration value="BMW"/> </xs: restriction> </xs: simple. Type> n Note: In this case the type "car. Type" can be used by other elements because it is not a part of the "car" element. April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 86 86

Schema example April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 87

Schema example April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 87

Schema example (cont´d) April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

Schema example (cont´d) April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 88

Using the schema April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

Using the schema April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 89

Combining Schemas April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 90

Combining Schemas April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 90

Combining Schemas April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 91

Combining Schemas April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 91

Types and Type Derivation n For purposes of discussion, consider only the content type

Types and Type Derivation n For purposes of discussion, consider only the content type aspects of types (attributes are analogous) n A content type definition (simple or complex) consists of a set of constraints on what's allowed as content. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 92

Built-In Data Types April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

Built-In Data Types April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 93

Permissions and obligations n You can think of the type itself as the set

Permissions and obligations n You can think of the type itself as the set of strings/EIIs its constraints allow. It's helpful to think of constraints as composed of obligations and permissions: (d )? (d{3}-)? d{3}-d{4} n regexp definition facet for [US] 'phone number type n the ? and the d can be seen as permissions, the - and the {3} as obligations n April 05 1 337 -6818 and 207 -422 -6240 belong to this type Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 94

Simple Data. Type example April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio.

Simple Data. Type example April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 95

Datatype Extensions April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 96

Datatype Extensions April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 96

Restricting values in na Element April 05 Prof. Ismael H. F. Santos - ismael@tecgraf.

Restricting values in na Element April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 97

An integer extension April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

An integer extension April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 98

Specifying Attributes April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 99

Specifying Attributes April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 99

XML Schemas n What is a Complex Element? n A complex element is an

XML Schemas n What is a Complex Element? n A complex element is an XML element that contains other elements and/or attributes. n There are four kinds of complex elements: n n empty elements that contain only other elements that contain only text elements that contain both other elements and text n Note: Each of these elements may contain attributes as well! April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 100

XML Schemas n A complex XML element, "food", which contains only text: <food tye="dessert">Ice

XML Schemas n A complex XML element, "food", which contains only text: <food tye="dessert">Ice cream</food> n A complex XML element, "description", which contains both elements and text: <description> It happened on <date lang="norwegian">03. 99</date>. . </description> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 101

XML Schemas n A complex XML element, "product", which is empty: <product pid="1345"/> n

XML Schemas n A complex XML element, "product", which is empty: <product pid="1345"/> n A complex XML element, "employee", which contains only other elements: <employee> <firstname>John</firstname> <lastname>Smith</lastname> </employee> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 102

XML Schemas n A complex XML element, "food", which contains only text: <food tye="dessert">Ice

XML Schemas n A complex XML element, "food", which contains only text: <food tye="dessert">Ice cream</food> n A complex XML element, "description", which contains both elements and text: <description> It happened on <date lang="norwegian">03. 99</date>. . </description> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 103

XML Schemas n A complex XML element, "description", which contains both elements and text:

XML Schemas n A complex XML element, "description", which contains both elements and text: <description> It happened on <date lang="norwegian">03. 99</date>. . </description> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 104

Complex types (title? , forename*, surname) n (shorthand for) content model for name n

Complex types (title? , forename*, surname) n (shorthand for) content model for name n the ? can be seen as permission, the , and the 'surname' as obligations (at the end of the day, each component involves both permission AND obligation, but the balance of impact is as suggested) April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 105

XML Schemas n A complex XML element, "food", which contains only text: <food tye="dessert">Ice

XML Schemas n A complex XML element, "food", which contains only text: <food tye="dessert">Ice cream</food> n A complex XML element, "description", which contains both elements and text: <description> It happened on <date lang="norwegian">03. 99</date>. . </description> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 106

XML Schemas n A complex XML element, "description", which contains both elements and text:

XML Schemas n A complex XML element, "description", which contains both elements and text: <description> It happened on <date lang="norwegian">03. 99</date>. . </description> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 107

XML Schemas n How to Define a Complex Element n Look at this complex

XML Schemas n How to Define a Complex Element n Look at this complex XML element, "employee", which contains only other elements: <employee> <firstname>John</firstname> <lastname>Smith</lastname> </employee> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 108

XML Schemas 2. The "employee" element can have a type attribute that refers to

XML Schemas 2. The "employee" element can have a type attribute that refers to the name of the complex type to use: <xs: element name="employee" type="personinfo"/> <xs: complex. Type name="personinfo"> <xs: sequence> <xs: element name="firstname" type="xs: string"/> <xs: element name="lastname" type="xs: string"/> </xs: sequence> </xs: complex. Type> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 109

XML Schemas n If you use the 2 nd method, several elements can refer

XML Schemas n If you use the 2 nd method, several elements can refer to the same complex type, like this: <xs: element name="employee" type="personinfo"/> <xs: element name="student" type="personinfo"/> <xs: element name="member" type="personinfo"/> <xs: complex. Type name="personinfo"> <xs: sequence> <xs: element name="firstname" type="xs: string"/> <xs: element name="lastname" type="xs: string"/> </xs: sequence> </xs: complex. Type> April 05 Dr. Ray LIS 2600 Fall 07 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 110

Enforcing Structure April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 111

Enforcing Structure April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 111

Parent/child example April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 112

Parent/child example April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 112

Specifying repeating elements April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br

Specifying repeating elements April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 113

Complex types, cont'd (title? , forename*, surname) <name> <forename>. . . </forename> <surname>. .

Complex types, cont'd (title? , forename*, surname) <name> <forename>. . . </forename> <surname>. . . </surname> </name> n and <name> <title>. . . </title> <surname>. . . </surname> </name> n are both members of this type April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 114

Restriction n A type definition may be a restriction of another type's definition if

Restriction n A type definition may be a restriction of another type's definition if it reduces permissions, sometimes to the point of inducing obligations: d[01]d-d{3}-d{4} (a restriction (d )? (d{3}-)? d{3}-d{4} of US p#) n The membership of this type, which includes n 207 -422 -6240 but not 1 337 -6818 n is a (proper) subset of the membership of the original type, n because by construction every member of the new type is a member of the original. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 115

Restriction, cont'd n Similarly, (forename+, surname) n is a restriction of the original type

Restriction, cont'd n Similarly, (forename+, surname) n is a restriction of the original type definition for name (title? , forename*, surname) n and the same relation holds. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 116

Restriction, cont'd n Note first that (forename+, surname) <name> <forename>. . . </forename> <surname>.

Restriction, cont'd n Note first that (forename+, surname) <name> <forename>. . . </forename> <surname>. . . </surname> </name> n is a member of the new type, but <name> <title>. . . </title> <surname>. . . </surname> </name> n is not. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 117

Extension n Now consider (title? , forename*, surname, gen. Mark? ) n This type

Extension n Now consider (title? , forename*, surname, gen. Mark? ) n This type extends the original type definition for name. <name> <forename>Al</forename> <surname>Gore</surname> <gen. Mark>Jr</gen. Mark> </name> n is an instance of this new type, but not of the original. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 118

Any n Finally note that the <any/> content model particle, in all of its

Any n Finally note that the <any/> content model particle, in all of its forms, introduces particularly broad permissions into complex content types. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 119

Where are we headed? n A number of design decisions can now be stated:

Where are we headed? n A number of design decisions can now be stated: n Should we make it easy to construct type definitions which restrict or extend other type definitions, by specifying only the method of derivation and the differences between the source and derived type definitions? n The new proposal says 'yes', you do this by using the "source" and "derived. By" attributes on your <type> or <datatype> element. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 120

Datatype example n Consider the simple type case first: <datatype name='bodytemp' source='decimal'> <precision value='4'/>

Datatype example n Consider the simple type case first: <datatype name='bodytemp' source='decimal'> <precision value='4'/> <scale value='1'/> <min. Inclusive value='97. 0'/> <max. Inclusive value='105. 0'/> </datatype> <datatype name='healthy. Bodytemp' source='bodytemp'> <max. Inclusive value='99. 5'/> </datatype> April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 121

Derived type n The healthy. Bodytemp type definition is defined by closing down the

Derived type n The healthy. Bodytemp type definition is defined by closing down the permitted range of bodytemp. We say it 'inherits' the other facets of bodytemp, so the 'effective type definition' of healthy. Bodytemp is April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 122

Effective type <datatype name='healthy. Bodytemp' source='decimal'> <precision value='4'/> <scale value='1'/> <min. Inclusive value='97. 0'/>

Effective type <datatype name='healthy. Bodytemp' source='decimal'> <precision value='4'/> <scale value='1'/> <min. Inclusive value='97. 0'/> <max. Inclusive value='99. 5'/> </datatype> n Since it doesn't in general make sense to extend one simple type by another, the "derived. By" attribute is actually redundant for <datatype>. April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 123

Extension for complex types n The next simplest case is extension for complex types:

Extension for complex types n The next simplest case is extension for complex types: <type name='name'> <element name='title‘ min. Occurs='0'/> <element name='forename' min. Occurs='0‘ max. Occurs='*'/> <element name='surname'/> </type> n Derived type <type name='full. Name' source='name' derived. By='extension'> <element name='gen. Mark' min. Occurs='0'/> </type> April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 124

The effective type <type name='full. Name'> <element name='title' min. Occurs='0'/> <element name='forename' min. Occurs='0'

The effective type <type name='full. Name'> <element name='title' min. Occurs='0'/> <element name='forename' min. Occurs='0' max. Occurs='*'/> <element name='surname'/> <element name='gen. Mark' min. Occurs='0'/> </type> April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 125

Restriction for complex types n Restriction for complex types is harder to handle syntactically,

Restriction for complex types n Restriction for complex types is harder to handle syntactically, because of the significance of linear order in content models, but the semantics are completely parallel to the simple type case: April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 126

Restriction example n Restriction for complex types is harder to handle syntactically, because of

Restriction example n Restriction for complex types is harder to handle syntactically, because of the significance of linear order in content models, but the semantics are completely parallel to the simple type case: <type name='simple. Name' source='name' derived. By='restrictio n'> <restrictions> <element name='title' max. Occurs='0'/> <element name='forename' min. Occurs='1'/> </restrictions> </type> April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 127

Restriction and Inheritance n Just as in the <datatype> case, the content model aspects

Restriction and Inheritance n Just as in the <datatype> case, the content model aspects not mentioned are left alone, including the "max. Occurs='*'" on <forename> and the whole particle for <surname>, so the 'effective content model' of 'simple. Name' is April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 128

Effective type <type name='simple. Name'> <element name='title' max. Occurs='0' min. Occurs='0'/> <!-- i. e.

Effective type <type name='simple. Name'> <element name='title' max. Occurs='0' min. Occurs='0'/> <!-- i. e. forbidden --> <element name='forename' min. Occurs='1' max. Occurs='*'/> <element name='surname'/> </type> April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 129

Instances n Given all the example definitions above, all of <name> <title>Ms</title> <surname>Steinem</surname> </name>

Instances n Given all the example definitions above, all of <name> <title>Ms</title> <surname>Steinem</surname> </name> <name xsi: type='simple. Name'> <fore. Name>Harry</fore. Name> <fore. Name>S</fore. Name> <surname>Truman</surname> </name> April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 130

Another instance <name xsi: type='full. Name'> <forename>Al</forename> <surname>Gore</surname> <gen. Mark>Jr</gen. Mark> </name> n all

Another instance <name xsi: type='full. Name'> <forename>Al</forename> <surname>Gore</surname> <gen. Mark>Jr</gen. Mark> </name> n all would be schema-valid per <element name='name' type='name'/> April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 131

Connecting Instances and Schemas n A schema is not a namespace n The connection

Connecting Instances and Schemas n A schema is not a namespace n The connection cannot be made rigid n The draft identifies three layers, first is n schema-valid(EII, Type. Name, Component. Set) n The Type. Name is a (namespace. URI, NCName) pair n The component set is made up of (namespace. URI, NCName, component) triples April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 132

fim April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 133

fim April 05 Prof. Ismael H. F. Santos - ismael@tecgraf. puc-rio. br 133