Skip to main content

Home/ PSI_ESEI_08/ Group items tagged schemas

Rss Feed Group items tagged

David Gelpi Fleta

XML Schema Part 0: Primer Second Edition - 1 views

  • The schemaLocation attribute value consists of one or more pairs of URI references, separated by white space. The first member of each pair is a namespace name, and the second member of the pair is a hint describing where to find an appropriate schema document for that namespace
  • there is a noNamespaceSchemaLocation attribute which is used to provide hints for the locations of schema documents that do not have target namespaces.
  • the include element has a required schemaLocation attribute, and it contains a URI reference which must identify a schema document.
  • ...63 more annotations...
  • the import element has optional namespace and schemaLocation attributes. If present, the schemaLocation attribute is understood in a way which parallels the interpretation of xsi:schemaLocation
  • The default value for both the minOccurs and the maxOccurs attributes is 1.
  • Be sure that if you specify a value for only the minOccurs attribute, it is less than or equal to the default value of maxOccurs,
  • Attributes may appear once or not at all, but no other number of times
  • The existence of a substitution group does not require any of the elements in that class to be used
  • Several facets can be applied to list types: length, minLength, maxLength, pattern, and enumeration
  • <xsd:simpleType name="USStateList"> <xsd:list itemType="USState"/> </xsd:simpleType> <xsd:simpleType name="SixUSStates"> <xsd:restriction base="USStateList"> <xsd:length value="6"/> </xsd:restriction> </xsd:simpleType>
    • David Gelpi Fleta
       
      USState es una enumeración, definida en este documento en la sección 2.3. ASí, precisamos siempre de un tipo de dato definido previamente para construir una lista.
  • Note that it is possible to derive a list type from the atomic type string. However, a string may contain white space, and white space delimits the items in a list type, so you should be careful using list types whose base type is string.
  • The include mechanism enables you to use externally created schema components "as-is", that is, without any modification.
  • <complexType name="Address">
  • base="ipo:Address"
    • David Gelpi Fleta
       
      El tipo base y el extendido tienen igual identificador.
      Fuera del elemento "redefine" cualquier intento de nombrar a dos tipos de datos usando el mismo identificador producirá un error.
      Notar cómo el elemento "redefine" debe ser el primer hijo del elemento "schema" y encerrar al tipo de dato que redefinimos.
  • </redefine>
  • The redefine element acts very much like the include element as it includes all the declarations and definitions from the address.xsd file
  • Outside of the redefine element, any such attempt to define a complex type with the same name (and in the same namespace) as the base from which it is being derived would cause an error.
  • Now that Address has been redefined, the extension applies to all schema components that make use of Address
    • David Gelpi Fleta
       
      Cuando un elemento es redefinido, la extensión se aplica a todos los tipos de datos que hacen uso de él como, p.e., sus tipos derivados (ver sección 4.2 y 4.3, así como los ejemplos en Creaweb).
  • Substitution GroupsXML Schema provides a mechanism, called substitution groups, that allows elements to be substituted for other elements. More specifically, elements can be assigned to a special group of elements that are said to be substitutable for a particular named element called the head element. (Note that the head element as well as the substitutable elementsmust be declared as global elements
  • Elements in a substitution group must have the same type as the head element, or they can have a type that has been derived from the head element's type
  • <element name="shipComment" type="string" substitutionGroup="ipo:comment"/>
  • substitutionGroup="ipo:comment"/>
  • <ipo:shipComment>
    • David Gelpi Fleta
       
      - no todos los elementos del grupo de sustitución han de aparecer en la instancia XML. - los indicadores minOccurs y maxOccurs del elemento cabecera deben ser adecuados al número de elementos de sustitución que permitamos aparecer (pueden aparecer tantos como el valor maxOccurs del elemento cabecera). - si maxOccurs así lo permite, puede aparecer el elemento cabecera y sus sustitutos.
  • <ipo:customerComment>
  • global declarations cannot contain the attributes > minOccurs > , > maxOccurs > , or > use > . >
  • Abstract Elements and TypesXML Schema provides a mechanism to force substitution for a particular element or type. When an element or type is declared to be "abstract", it cannot be used in an instance document. When an element is declared to be abstract, a member of that element's substitution group must appear in the instance document. When an element's corresponding type definition is declared as abstract, all instances of that element must use xsi:type to indicate a derived type that is not abstract.
  • Declaring an element as abstract requires the use of a substitution group. Declaring a type as abstract simply requires the use of a type derived from it (and identified by the xsi:type attribute) in the instance document
    • David Gelpi Fleta
       
      Ver los ejemplos "abstract_tipo" y "abstract_elemento" en Creaweb.
  • the redefine mechanism we describe here enables you to redefine simple and complex types, groups, and attribute groups that are obtained from external schema files. Like the include mechanism, redefine requires the external components to be in the same target namespace as the redefining schema,
  • abstract="true"
  • abstract="true"
  • extension base
  • extension
  • extension
  • xsi:type="Car"
  • Controlling the Creation & Use of Derived Types
  • schema authors will sometimes want to control derivations of particular types, and the use of derived types in instances.
  • to specify that for a particular complex type, new types may not be derived from it, either (a) by restriction, (b) by extension, or (c) at all.
  • substitutionGroup=
  • The restriction value of the final attribute prevents derivations by restriction. Preventing derivations at all, or by extension, are indicated by the values #all and extension respectively
  • an optional finalDefault attribute on the schema element whose value can be one of the values allowed for the final attribute. The effect of specifying the finalDefault attribute is equivalent to specifying a final attribute on every type definition and element declaration in the schema.
  • When a simple type is defined, the fixed attribute may be applied to any of its facets to prevent a derivation of that type from modifying the value of the fixed facets.
  • fixed="true"
  • a mechanism that controls which derivations and substitution groups may be used in instance documents
  • eplacement by derived types can be controlled using the block attribute in a type definition
    • David Gelpi Fleta
       
      Previene la sustitución de un elemento por su tipo derivado, bien sea por extensión o restricción. No confundir este mecanismo con "final", que sólo previene la definición de tipos derivados (por extensión o restricción) de un tipo determinado.
  • final="restriction"
  • final="restriction"
  • Preventing replacement by derivations at all, or by derivations-by-extension, are indicated by the values #all and extension respectively. As with final, there exists an optional blockDefault attribute on the schema element whose value can be one of the values allowed for the block attribute.
  • block="restriction"
  • final="restriction"
  • mechanism that enables schema components from different target namespaces to be used together, and hence enables the schema validation of instance content defined across multiple namespaces.
  • Importing Types
  • only global schema components can be imported:
  • Only named complex types can be imported; local, anonymously defined types cannot.
  • each namespace must be identified with a separate import element.
  • The import elements themselves must appear as the first children of the schema element
  • each namespace must be associated with a prefix, using a standard namespace declaration
  • import elements optionally contain a schemaLocation attribute to help locate resources associated with the namespaces.
  • ref="xipo:
  • Deriving Types by Extension
  • we indicate that the content models of the new types are complex, i.e. contain elements, by using the complexContent element, and we indicate that we are extending the base type Address by the value of the base attribute on the extension element.
  • xsi:type="ipo:UKAddress">
  • xsi:type="ipo:USAddress">
  • Deriving Complex Types by Restriction
  • the values represented by the new type are a subset of the values represented by the base type (as is the case with restriction of simple types).
  • <complexContent> <restriction base=
  • Table 3 shows several examples of how element and attribute declarations within type definitions may be restricted
David Gelpi Fleta

Introduction to XML Schemas - 0 views

  • XML Schema is an XML-based alternative to DTD. An XML schema describes the structure of an XML document. The XML Schema language is also referred to as XML Schema Definition (XSD).
  • An XML Schema: 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
  • XML Schemas are extensible to future additions XML Schemas are richer and more powerful than DTDs XML Schemas are written in XML XML Schemas support data types XML Schemas support namespaces
  • ...1 more annotation...
  • XML Schema became a W3C Recommendation 02. May 2001.
David Gelpi Fleta

Why Use XML Schemas? - 0 views

  • XML Schemas Support Data Types
  • It is easier to describe allowable document content It is easier to validate the correctness of data It is easier to work with data from a database It is easier to define data facets (restrictions on data) It is easier to define data patterns (data formats) It is easier to convert data between different data types
  • XML Schemas use XML Syntax
  • ...4 more annotations...
  • 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 You can transform your Schema with XSLT
  • XML Schemas are Extensible
  • Reuse your Schema in other Schemas Create your own data types derived from the standard types Reference multiple schemas in the same document
  • Well-Formed is not Enough
David Gelpi Fleta

XML schema Element - 0 views

  • The <schema> element is the root element of every XML Schema:
  • The <schema> element may contain some attributes. A schema declaration
  • <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified">
  • ...7 more annotations...
  • targetNamespace="http://www.w3schools.com" indicates that the elements defined by this schema (note, to, from, heading, body.) come from the "http://www.w3schools.com" namespace.
  • xmlns:xs="http://www.w3.org/2001/XMLSchema" indicates that the elements and data types used in the schema come from the "http://www.w3.org/2001/XMLSchema" namespace.
  • prefixed with xs:
  • xmlns="http://www.w3schools.com" indicates that the default namespace is "http://www.w3schools.com".
  • Referencing a Schema in an XML Document
  • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com note.xsd"
  • This attribute has two values. The first value is the namespace to use. The second value is the location of the XML schema to use for that namespace
David Gelpi Fleta

XML Schema How To - 0 views

  • This XML document has a reference to an XML Schema:
  • xsi:schemaLocation="http://www.w3schools.com note.xsd"
David Gelpi Fleta

XML Schema Simple Elements - 0 views

  • What is a Simple Element? A simple element is an XML element that can contain only text. It cannot contain any other elements or attributes. However, the "only text" restriction is quite misleading. 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.
  • You can also add restrictions (facets) to a data type
  • you can require the data to match a specific pattern.
  • ...7 more annotations...
  • The syntax for defining a simple element is: <xs:element name="xxx" type="yyy"/>
  • built-in data types
  • xs:string xs:decimal xs:integer xs:boolean xs:date xs:time
    • David Gelpi Fleta
       
      Más tipos de datos predefinidos en: http://www.w3.org/TR/xmlschema-0/#simpleTypesTable
  • A default value is automatically assigned to the element when no other value is specified.
  • default="red"/
  • A fixed value is also automatically assigned to the element, and you cannot specify another value.
  • fixed="red"/
David Gelpi Fleta

XML Schema Complex Types - Mixed Content - 0 views

  • A mixed complex type element can contain attributes, elements, and text.
  • mixed="true">
David Gelpi Fleta

XML Schema Complex Type - Text Elements - 0 views

  • This type contains only simple content (text and attributes),
  • <xs:element name="shoesize"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:integer"> <xs:attribute name="country" type="xs:string" />
David Gelpi Fleta

XML Schema Complex Type - Empty Elements - 0 views

  • <xs:element name="product"> <xs:complexType> <xs:attribute name="prodid" type="xs:positiveInteger"/>
David Gelpi Fleta

XML Schema Complex Elements - 0 views

  • A complex element is an XML element that contains other elements and/or attributes. There are four kinds of complex elements: empty elements elements that contain only other elements elements that contain only text elements that contain both other elements and text Note: Each of these elements may contain attributes as well!
  • <xs:element name="employee"> <xs:complexType> <xs:sequence>
  • type="personinfo"/> <xs:complexType name="personinfo">
  • ...1 more annotation...
  • <xs:complexType name="fullpersoninfo"> <xs:complexContent> <xs:extension base="personinfo">
David Gelpi Fleta

XML Schema Restrictions/Facets - 0 views

  • Restrictions are used to define acceptable values for XML elements or attributes. Restrictions on XML elements are called facets.
  • Restrictions on Values
  • <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="120"/> </xs:restriction>
  • ...15 more annotations...
  • Restrictions on a Set of Values To limit the content of an XML element to a set of acceptable values, we would use the enumeration constraint.
  • <xs:restriction base="xs:string"> <xs:enumeration value="Audi"/> <xs:enumeration value="Golf"/> <xs:enumeration value="BMW"/> </xs:restriction>
  • type="carType"/>
  • <xs:simpleType name="carType">
  • the type "carType" can be used by other elements
  • series of numbers or letters that can be used, we would use the pattern constraint.
  • <xs:restriction base="xs:string"> <xs:pattern value="[a-z]"/>
  • <xs:pattern value="male|female"/>
  • The whiteSpace constraint is set to "preserve", which means that the XML processor WILL NOT remove any white space characters:
  • <xs:whiteSpace value="preserve"/>
  • The whiteSpace constraint is set to "replace", which means that the XML processor WILL REPLACE all white space characters (line feeds, tabs, spaces, and carriage returns) with spaces:
  • <xs:whiteSpace value="replace"/>
  • <xs:length value="8"/>
  • <xs:minLength value="5"/> <xs:maxLength value="8"/>
  • Constraint Description enumeration Defines a list of acceptable values fractionDigits Specifies the maximum number of decimal places allowed. Must be equal to or greater than zero length Specifies the exact number of characters or list items allowed. Must be equal to or greater than zero maxExclusive Specifies the upper bounds for numeric values (the value must be less than this value) maxInclusive Specifies the upper bounds for numeric values (the value must be less than or equal to this value) maxLength Specifies the maximum number of characters or list items allowed. Must be equal to or greater than zero minExclusive Specifies the lower bounds for numeric values (the value must be greater than this value) minInclusive Specifies the lower bounds for numeric values (the value must be greater than or equal to this value) minLength Specifies the minimum number of characters or list items allowed. Must be equal to or greater than zero pattern Defines the exact sequence of characters that are acceptable totalDigits Specifies the exact number of digits allowed. Must be greater than zero whiteSpace Specifies how white space (line feeds, tabs, spaces, and carriage returns) is handled
David Gelpi Fleta

XML Schema Attributes - 0 views

  • Simple elements cannot have attributes. If an element has attributes, it is considered to be of a complex type. But the attribute itself is always declared as a simple type.
  • <xs:attribute name="xxx" type="yyy"/>
  • Attributes may have a default value OR a fixed value specified
  • ...1 more annotation...
  • Attributes are optional by default. To specify that the attribute is required, use the "use" attribute: <xs:attribute name="lang" type="xs:string" use="required"/>
David Gelpi Fleta

XML Schema Indicators - 0 views

  • Order indicators: All Choice Sequence Occurrence indicators: maxOccurs minOccurs Group indicators: Group name attributeGroup name
  • <all> indicator specifies that the child elements can appear in any order, and that each child element must occur only once
  • When using the <all> indicator you can set the <minOccurs> indicator to 0 or 1 and the <maxOccurs> indicator can only be set to 1
    • David Gelpi Fleta
       
      The all group is limited to the top-level of any content model. Es ilegal!! : ...... ....
  • ...14 more annotations...
  • <choice> indicator specifies that either one child element or another can occur
  • The <sequence> indicator specifies that the child elements must appear in a specific order:
  • Occurrence indicators are used to define how often an element can occur.
  • For all "Order" and "Group" indicators (any, all, choice, sequence, group name, and group reference) the default value for maxOccurs and minOccurs is 1.
  • The <maxOccurs> indicator specifies the maximum number of times an element can occur:
  • The <minOccurs> indicator specifies the minimum number of times an element can occur:
  • To allow an element to appear an unlimited number of times, use the maxOccurs="unbounded" statement:
    • David Gelpi Fleta
       
      Ver algunos ejemplos sobre indicadores de ocurrencia: http://www.w3.org/TR/xmlschema-0/#cardinalityTable
  • Group indicators are used to define related sets of elements.
  • <xs:group name="groupname">
  • After you have defined a group, you can reference it in another definition
  • <xs:group name="persongroup">
  • <xs:group ref="persongroup"/>
  • <xs:attributeGroup name="groupname">
  • <xs:attributeGroup ref="personattrgroup"/>
David Gelpi Fleta

XML DTD - 0 views

  • XML with correct syntax is "Well Formed" XML. XML validated against a DTD is "Valid" XML.
  • Well Formed XML Documents A "Well Formed" XML document has correct XML syntax.
  • A "Well Formed" XML document has correct XML syntax. A "Well Formed" XML document is a document that conforms to the XML syntax rules that were described in the previous chapters: XML documents must have a root element XML elements must have a closing tag XML tags are case sensitive XML elements must be properly nested XML attribute values must always be quoted
  • ...4 more annotations...
  • A "Valid" XML document also conforms to a DTD. A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD):
  • Valid XML Documents A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD):
  • XML Schema is an XML based alternative to DTD.
  • XML Schema  W3C supports an XML based alternative to DTD called XML Schema:
David Gelpi Fleta

Problemas validación Redefine por Restricción - 58 views

Tod@s aquell@s que realiceis la práctica con Eclipse version 3.4.X debéis modificar la configuración del validador Schema (Xerces) para evitar que la redefinición por restricción no valide. Para el...

practica

started by David Gelpi Fleta on 09 Dec 08 no follow-up yet
David Gelpi Fleta

Práctica: tarea 2 (18/11/08) - 96 views

Esta semana hemos tratado el uso de los espacios de nombres, así como la sintaxis, normas y elementos básicos de Schema. Durante estas dos semanas (hasta el martes 18/11/08) intenteremos construir...

practica

started by David Gelpi Fleta on 04 Nov 08 no follow-up yet
David Gelpi Fleta

Práctica: tarea 3 - 101 views

En la sección "apuntes de prácticas" en Creaweb se encuentra el fichero Schema "tipos_web_plantilla.xsd" que contiene los tipos de datos que es necesario importar en la práctica. Más indicaciones e...

practica

started by David Gelpi Fleta on 18 Nov 08 no follow-up yet
David Gelpi Fleta

Comienzo de la práctica. - 129 views

El martes día 28/10/08 dió comienzo la práctica de este año. Expusimos los objetivos a alcanzar de aquí al 15 de Diciembre. El primero de ellos consiste en proteger la inversión en sistemas de info...

practica

started by David Gelpi Fleta on 03 Nov 08 no follow-up yet
David Gelpi Fleta

Ampliación del plazo de entrega de la práctica. - 76 views

La entrega de la segunda parte de la práctica consta de los siguientes documentos (impresos y en CD): - Hoja de estilos XSLT. - Una o varias instancias XML ejemplo con el juego de documentos...

practica

1 - 19 of 19
Showing 20 items per page