Skip to main content

Home/ Groups/ PSI_ESEI
David Gelpi Fleta

XML Schema Part 0: Primer Second Edition - 0 views

  • <xsd:element name="comment" type="xsd:string"/>
  • Global elements, and global attributes, are created by declarations that appear as the children of the schema element. Once declared, a global element or a global attribute can be referenced in one or more declarations using the ref attribute as described above.
  • ref="comment"
    • David Gelpi Fleta
       
      Uso de elementos globales. Ver sección 2.2.2
  • ...151 more annotations...
  • The declaration of a global element also enables the element to appear at the top-level of an instance document
  • , global declarations cannot contain the ref attribute, they must use the type attribute
  • global declarations cannot contain the attributes minOccurs, maxOccurs, or use.
  • If the two things are a type and an element or attribute,
  • What happens if we give two things the same name?
  • Naming Conflicts
  • there is a conflict
  • If the two things are both types
  • the more similar are the two things, the more likely there will be a conflict.
  • there is no conflic
  • If the two things are elements within different types (i.e. not global elements),
  • there is no conflict
  • if the two things are both types and you define one and XML Schema has defined the other, say you define a simple type called decimal, there is no conflict. The reason for the apparent contradiction in the last example is that the two types belong to different namespaces
  • local element
  • <xsd:attributeGroup ref="ItemDelivery"/>
  • we can create a named attribute group containing all the desired attributes of an item element, and reference this group by name in the item element declaration:
  • Attribute Groups
  • <xsd:attributeGroup id="ItemDelivery">
  • A schema can be viewed as a collection (vocabulary) of type definitions and element declarations whose names belong to a particular namespace called a target namespace. Target namespaces enable us to distinguish between definitions and declarations from different vocabularies.
  • When we want to check that an instance document conforms to one or more schemas (through a process called schema validation), we need to identify which element and attribute declarations and type definitions in the schemas should be used to check which elements and attributes in the instance document. The target namespace plays an important role in the identification process
  • <element name="purchaseOrder" type="po:PurchaseOrderType"/> <element name="comment" type="string"/>
  • <apo:purchaseOrder xmlns:apo="http://www.example.com/PO1"
  • <apo:comment>
  • The instance document declares one namespace, http://www.example.com/PO1, and associates it with the prefix apo:. This prefix is used to qualify two elements in the document, namely purchaseOrder and comment. The namespace is the same as the target namespace of the schema in po1.xsd, and so a processor of the instance document will know to look in that schema for the declarations of purchaseOrder and comment. In fact, target namespaces are so named because of the sense in which there exists a target namespace for the elements purchaseOrder and comment. Target namespaces in the schema therefore control the validation of corresponding namespaces in the instance.
  • Elements and attributes can be independently required to be qualified,
  • elementFormDefault="qualified" attributeFormDefault="unqualified"
  • <apo:name>Alice Smith</apo:name> <apo:street>123 Maple Street</apo:street>
  • To specify that all locally declared elements in a schema must be qualified, we set the value of elementFormDefault to qualified:
  • we can replace the explicit qualification of every element with implicit qualification provided by a default namespace
  • xmlns="http://www.example.com/PO1"
  • xml, all the elements in the instance belong to the same namespace, and the namespace statement declares a default namespace that applies to all the elements in the instance. Hence, it is unnecessary to explicitly prefix any of the elements.
  • Attributes that must be qualified, either because they are declared globally or because the attributeFormDefault attribute is set to qualified, appear prefixed in instance documents.
  • he Namespaces in XML specification does not provide a mechanism for defaulting the namespaces of attributes
  • attributeFormDefault="unqualified">
  • form="qualified"
  • the form attribute can be applied to an element declaration in the same manner
  • create schemas in which all elements are global
  • we have omitted the elementFormDefault and attributeFormDefault attributes in this example to emphasize that their values are irrelevant when there are only global element and attribute declarations.
  • <element name="purchaseOrder" type="po:PurchaseOrderType"/> <element name="shipTo" type="po:USAddress"/> <element name="billTo" type="po:USAddress"/> <element name="comment" type="string"/> <element name="name" type="string"/> <element name="street" type="string"/>
  • both schema approaches can validate the same, namespace defaulted, document.
  • n cases where a schema is designed without a target namespace, it is strongly recommended that all XML Schema elements and types are explicitly qualified with a prefix such as xsd: that is associated with the XML Schema namespace
  • without prefixes, then references to XML Schema types may not be distinguishable from references to user-defined types.
  • Element declarations from a schema with no target namespace validate unqualified elements in the instance document. That is, they validate elements for which no namespace qualification is provided by either an explicit prefix or by default (xmlns:).
  • As schemas become larger, it is often desirable to divide their content among several schema documents for purposes such as ease of maintenance, access control, and readability
  • <include schemaLocation="http://www.example.com/schemas/address.xsd"/>
  • <include schemaLocation="http://www.example.com/schemas/address.xsd"/> The effect of this include element is to bring in the definitions and declarations contained in address.xsd,
  • The one important caveat to using include is that the target namespace of the included components must be the same as the target namespace of the including schema
  • Bringing in definitions and declarations using the include mechanism effectively adds these components to the existing target namespace
  • it is possible to include more than one document using multiple include elements, and documents can include documents that themselves include other documents. However, nesting documents in this manner is legal only if all the included parts of the schema are declared with the same target namespace.
  • Instance documents that conform to schema whose definitions span multiple schema documents need only reference the 'topmost' document and the common namespace, and it is the responsibility of the processor to gather together all the definitions specified in the various included documents
  • XML Schema uses the schemaLocation and xsi:schemaLocation attributes in three circumstances.
  • 1. In an instance document, the attribute xsi:schemaLocation provides hints from the author to a processor regarding the location of schema documents. The author warrants that these schema documents are relevant to checking the validity of the document content, on a namespace
  • 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.
  • A schema is not required to have a namespace
  • and so there is a noNamespaceSchemaLocation attribute which is used to provide hints for the locations of schema documents that do not have target namespaces.
  • 2. In a schema, the include element has a required schemaLocation attribute, and it contains a URI reference which must identify a schema document. The effect is to compose a final effective schema by merging the declarations and definitions of the including and the included schemas.
  • targetNamespace="http://www.example.com/IPO
  • targetNamespace="http://www.example.com/IPO"
  • <element name="shipTo" type="ipo:Address"/> <element name="billTo" type="ipo:Address"/>
    • David Gelpi Fleta
       
      El prefijo "ipo", correspondiente al espacio de nombres que valida este Schema, se aplica al tipo de dato "Address" aunque su definición se encuentre en el fichero Schema incluido.
  • <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType>
  • <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType>
    • David Gelpi Fleta
       
      Elemento con tipo anónimo: no contiene el atributo "type=valor". La definición de tipo no especifica indentificador.
  • <xsd:element name="quantity"> <xsd:simpleType>
    • David Gelpi Fleta
       
      Elemento con tipo anónimo: no contiene el atributo "type=valor". La definición de tipo no especifica indentificador.
  • 2. In a schema, the include element has a required schemaLocation attribute, and it contains a URI reference which must identify a schema document. The effect is to compose a final effective schema by merging the declarations and definitions of the including and the included schemas.
  • The technique we use here to derive new (complex) address types by extending an existing type is the same technique we used in Complex Types from Simple Types (§2.5.1), except that our base type here is a complex type whereas our base type in the previous section was a simple type.
  • 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.
  • When a complex type is derived by extension, its effective content model is the content model of the base type plus the content model specified in the type derivation. Furthermore, the two content models are treated as two children of a sequential group
  • xsi:type="ipo:UKAddress"
  • to identify exactly which derived type is intended, the derived type must be identified in the instance document. The type is identified using the xsi:type attribute which is part of the XML Schema instance namespace.
  • The import mechanism that we describe in this section is an important 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.
    • David Gelpi Fleta
       
      Ver ejemplo "The Report Schema, report.xsd" en la sección 5.
  • only global schema components can be imported:
  • Only named complex types can be imported; local, anonymously defined types cannot
  • When schema components are imported from multiple namespaces, each namespace must be identified with a separate import element. The import elements themselves must appear as the first children of the schema element. Furthermore, each namespace must be associated with a prefix, using a standard namespace declaration, and that prefix is used to qualify references to any schema components belonging to that namespace. Finally, import elements optionally contain a schemaLocation attribute to help locate resources associated with the namespaces
  • 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 in (1).
  • To import components that are not in any target namespace, the import element is used without a namespace attribute (and with or without a schemaLocation attribute)
  • <import namespace="http://www.example.com/IPO"/>
    • David Gelpi Fleta
       
      En el ejemplo, el autor/a importa el tipo SKU definido en otro documento schema.
      1. Para importar tipos de datos, identificamos el espacio de nombres en el cual están definidos y asociamos dicho espacio de nombres con un prefijo. En el ejemplo:
      xmlns:xipo="http://www.example.com/IPO"

      2. Usamos el elemento "import" para identificar el espacio de nombres objetivo:
      <import namespace="http://www.example.com/IPO"/&gt;

      Es conveniente incluir el atributo Schemalocation en la etiqueta "import" para indicar la ruta de accedo al fichero Schema que contiene el tipo importado.


      3. En la instancia XML sólo es preciso indicar la localización del Schema que referencia a los demás empleados.
  • xmlns:xipo="http://www.example.com/IPO
  • type="xipo:SKU"
  • List Types
  • XML Schema has the concept of a list type, in addition to the so-called atomic types that constitute most of the types listed in Table 2.
  • The value of an atomic type is indivisible from XML Schema's perspective. For example, the NMTOKEN value US is indivisible in the sense that no part of US, such as the character "S", has any meaning by itself.
  • NMTOKENS is a list type, and an element of this type would be a white-space delimited list of NMTOKEN's, such as "US UK FR"
  • you can create new list types by derivation from existing atomic types
  • &lt;xsd:simpleType name="listOfMyIntType"&gt; &lt;xsd:list itemType="myInteger"/&gt; &lt;/xsd:simpleType&gt;
  • Several facets can be applied to list types: length, minLength, maxLength, pattern, and enumeration
  • &lt;xsd:simpleType name="USStateList"&gt; &lt;xsd:list itemType="USState"/&gt; &lt;/xsd:simpleType&gt; &lt;xsd:simpleType name="SixUSStates"&gt; &lt;xsd:restriction base="USStateList"&gt; &lt;xsd:length value="6"/&gt; &lt;/xsd:restriction&gt; &lt;/xsd:simpleType&gt;
    • 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.
  • &lt;redefine schemaLocation="http://www.example.com/schemas/address.xsd"&gt;
  • &lt;/redefine&gt;
  • &lt;complexType name="Address"&gt;
  • 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.
  • 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
  • &lt;element name="shipComment" type="string" substitutionGroup="ipo:comment"/&gt;
  • &lt;ipo:shipComment&gt;
    • 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.
  • substitutionGroup="ipo:comment"/&gt;
  • &lt;ipo:customerComment&gt;
  • The existence of a substitution group does not require any of the elements in that class to be used
  • 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,
  • xsi:type="Car"
  • abstract="true"
  • extension base
  • abstract="true"
  • extension
  • extension
  • Controlling the Creation &amp; 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.
  • 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"
  • 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"
  • final="restriction"
  • block="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.
  • a mechanism that controls which derivations and substitution groups may be used in instance documents
  • substitutionGroup=
  • global declarations cannot contain the attributes > minOccurs > , > maxOccurs > , or > use > . >
  • 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.
  • 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
  • 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"&gt;
  • xsi:type="ipo:USAddress"&gt;
  • 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).
  • &lt;complexContent&gt; &lt;restriction base=
  • Table 3 shows several examples of how element and attribute declarations within type definitions may be restricted
David Gelpi Fleta

XSL Languages - 0 views

  • XSL stands for EXtensible Stylesheet Language.
  • XSL describes how the XML document should be displayed!
  • XSL consists of three parts: XSLT - a language for transforming XML documents XPath - a language for navigating in XML documents XSL-FO - a language for formatting XML documents
David Gelpi Fleta

XPath Syntax - 0 views

  • Selecting Nodes XPath uses path expressions to select nodes in an XML document.
  • Expression Description nodename Selects all child nodes of the named node / Selects from the root node // Selects nodes in the document from the current node that match the selection no matter where they are . Selects the current node .. Selects the parent of the current node @ Selects attributes
  • Selecting Several Paths By using the | operator in an XPath expression you can select several paths.
  • ...10 more annotations...
  • Wildcard Description * Matches any element node @* Matches any attribute node node() Matches any node of any kind
  • Predicates Predicates are used to find a specific node or a node that contains a specific value.
  • Predicates are always embedded in square brackets.
  • [last()]
  • [position()&lt;3]
  • title[@lang]
  • [@lang]
  • [@lang='eng']
  • [price&gt;35.00]
  • [1]
David Gelpi Fleta

XML Introduction - What is XML? - 0 views

  • What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to describe data XML tags are not predefined. You must define your own tags XML uses a Document Type Definition (DTD) or an XML Schema to describe the data XML with a DTD or XML Schema is designed to be self-descriptive XML is a W3C Recommendation
  • The Extensible Markup Language (XML) became a W3C Recommendation 10. February 1998.
  • XML is not a replacement for HTML.
  • ...8 more annotations...
  • XML was designed to describe data and to focus on what data is. HTML was designed to display data and to focus on how data looks.
  • XML was created to structure, store and to send information.
  • It is just pure information wrapped in XML tags
  • XML tags are not predefined. You must "invent" your own tags. The tags used to mark up HTML documents and the structure of HTML documents are predefined.
  • XML allows the author to define his own tags and his own document structure.
  • XML will be used to describe the data, while HTML will be used to format and display the same data
  • XML is a cross-platform, software and hardware independent tool for transmitting information.
    • davidg
       
      Forma parte de la plataforma básica de tecnologías con las que se construyen los Servicios Web.
    • David Gelpi Fleta
       
      Cita un caso de uso de XML.
    • mfestevez
       
      Sirve para guardar datos estructurados, por ejemplo para guardar las conversacion del messenger
    • lplamazares
       
      XML podemos utilizarlo para realizar migraciones de datos entre distintas bases de datos.
    • pbpascual
       
      Es la base del lenguaje utilizado por la herramienta Flex 2 de Adobe, utilizada para crear RIA.
    • patriab
       
      Se puede utilizar para guardar historiales de búsqueda o navegación.
    • leepard
       
      Se puede utilizar para intercambio de informacion contable.
    • magonzalez2
       
      XML se puede utilizar para crear podcast, ya que es un archivo XML que se distribuye a través de un feeder.
    • lorena84
       
      Se utilizan también para el tratamiento de imágenes,para que sea más fácil implementar figuras guardando sus componentes con XML y para que su posterior tratamiento sea más cómodo.
    • samacia
       
      XML es un lenguaje de marcado muy utilizado en ficheros de configuración (por ejemplo, en WEBORB, tecnología para usar los FLEX DATA SERVICES)
    • rcarjolekas
       
      Con XML puedes comunicar aplicaciones de distintas plataformas sin importar el origen de los datos. Por ejemplo, puedo tener una aplicación bajo Linux y Base de datos Oracle, y otra aplicación bajo windows y base de datos en SQL Server.
    • vrdominguez
       
      Obtener datos desde una base de datos MySQL, mediante un script PHP que formatee los datos en XML, para asi poder trabajar con ellos mediante un objeto XML en Flash con ActionScript
    • anonymous
       
      Para sindicación web o de noticias, mediante lenguajes como RSS, el cual forma parte de la familia de lenguajes XML.
    • irconde
       
      Actualmente XML está siendo usado para muchos fines diferentes. Uno de los que me parece más interesante es que se hatomado como base para el XLL: el eXtensible Link Language que permite definir distintos tipos de enlaces (links) entre documentos, ya sean externos o internos.
    • Silvia Rivas Borrajo
       
      XML permite la creación de archivos de configuración de aplicaciones (web en flash, programas open-source,...)
    • evcervino
       
      También puede ser usado para embeber otros lenguajes. Puede ser usada también en imágenes de tipo vectorial, así como en vídeos o música para dar mayor información.
    • MaryGR
       
      XML puede ser usado también para el almacenamiento de gráficos vectoriales ,mediante una utlidad llamada VML (Vector Markup Lenguaje) la cual nos facilita esta tarea.
    • mfalvarez
       
      SMIL Synchronized Multimedia Integration Language, es un lenguaje para sincronizar presentaciones multimedia en la web. Se basa en XML y permite definir la posición y el tiempo de activación de diversos objetos.
    • jagdominguez
       
      Se puede utilizar en Google Maps. Se puede usar un archivo Xml para guardar la informacion de varios marcadores
    • jlvazquez2
       
      Se usa para guardar la configuracion de las aplicaciones. Y recientemente es usado para los documentos de open office. Para mas informacion http://es.wikipedia.org/wiki/OpenDocument.
    • lnanta
       
      XML tiene un lenguaje de consulta XQL, el cual facilita la extracción de datos. Se pueden realizar consultas flexibles para extraer datos de documentos XML en la web.
David Gelpi Fleta

XML Namespaces - 0 views

  • XML Namespaces provide a method to avoid element name conflicts. Name Conflicts Since element names in XML are not predefined, a name conflict will occur when two different documents use the same element names.
  • &lt;h:table&gt;
  • &lt;f:table&gt;
  • ...8 more annotations...
  • &lt;h:table xmlns:h="http://www.w3.org/TR/html4/"&gt;
  • &lt;f:table xmlns:f="http://www.w3schools.com/furniture"&gt;
  • xmlns:namespace-prefix="namespaceURI"
  • Note that the address used to identify the namespace is not used by the parser to look up information. The only purpose is to give the namespace a unique name.
  • Uniform Resource Identifier (URI) A Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource. The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address.
  • not so common type of URI is the Universal Resource Name (URN)
  • Default Namespaces Defining a default namespace for an element saves us from using prefixes in all the child elements.
  • &lt;table xmlns="http://www.w3.org/TR/html4/"&gt;
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

XML Elements - 0 views

  • XML documents can be extended to carry more information.
  • Elements are related as parents and children.
  • child elements
  • ...10 more annotations...
  • root element
  • parent element
  • siblings
  • Elements can have different content types.
  • An element can have element content, mixed content, simple content, or empty content. An element can also have attributes.
  • simple content (or text content)
  • XML elements must follow these naming rules: Names can contain letters, numbers, and other characters Names must not start with a number or punctuation character Names must not start with the letters xml (or XML, or Xml, etc) Names cannot contain spaces
  • make names descriptive.
  • Avoid "-" and "." in names
  • ":" should not be used
David Gelpi Fleta

XSLT <xsl:template> Element - 0 views

  • An XSL style sheet consists of one or more set of rules that are called templates. Each template contains rules to apply when a specified node is matched.
  • &lt;xsl:template&gt; element is used to build templates. The match attribute is used to associate a template with an XML element. The match attribute can also be used to define a template for the entire XML document. The value of the match attribute is an XPath expression (i.e. match="/" defines the whole document).
  • &lt;xsl:template match="/"&gt; &lt;html&gt;
  • ...3 more annotations...
  • Since an XSL style sheet is an XML document itself, it always begins with the XML declaration: &lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  • &lt;xsl:stylesheet&gt;, defines that this document is an XSLT style sheet document
  • The content inside the &lt;xsl:template&gt; element defines some HTML to write to the output.
David Gelpi Fleta

XML Schema Indicators - 0 views

  • Order indicators: All Choice Sequence Occurrence indicators: maxOccurs minOccurs Group indicators: Group name attributeGroup name
  • &lt;all&gt; indicator specifies that the child elements can appear in any order, and that each child element must occur only once
  • When using the &lt;all&gt; indicator you can set the &lt;minOccurs&gt; indicator to 0 or 1 and the &lt;maxOccurs&gt; 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...
  • &lt;choice&gt; indicator specifies that either one child element or another can occur
  • Occurrence indicators are used to define how often an element can occur.
  • The &lt;sequence&gt; indicator specifies that the child elements must appear in a specific order:
  • The &lt;maxOccurs&gt; indicator specifies the maximum number of times 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 &lt;minOccurs&gt; 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.
  • &lt;xs:group name="groupname"&gt;
  • After you have defined a group, you can reference it in another definition
  • &lt;xs:group name="persongroup"&gt;
  • &lt;xs:group ref="persongroup"/&gt;
  • &lt;xs:attributeGroup name="groupname"&gt;
  • &lt;xs:attributeGroup ref="personattrgroup"/&gt;
davidg

XML Syntax - 0 views

  • The syntax rules of XML are very simple and very strict. The rules are very easy to learn, and very easy to use.
  • XML documents use a self-describing
  • the XML declaration
  • ...10 more annotations...
  • All XML Elements Must Have a Closing Tag
  • XML Tags are Case Sensitive
  • XML Elements Must be Properly Nested
  • XML Documents Must Have a Root Element
  • (child elements
  • XML Attribute Values Must be Quoted
  • &lt;note date="12/11/2002"&gt;
  • With XML, White Space is Preserved
  • Comments in XML
  • &lt;!-- This is a comment --&gt;
David Gelpi Fleta

XML Schema Part 2: Datatypes Second Edition - 0 views

  • The ·value space· of NMTOKEN is the set of tokens that ·match· the Nmtoken production
  • token represents tokenized strings. The ·value space· of token is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters, that have no leading or trailing spaces (#x20) and that have no internal sequences of two or more spaces.
  • NMTOKEN has the following ·constraining facets·: lengthminLengthmaxLengthpatternenumerationwhiteSpace
David Gelpi Fleta

XSLT <xsl:for-each> Element - 0 views

  • The &lt;xsl:for-each&gt; Element The XSL &lt;xsl:for-each&gt; element can be used to select every XML element of a specified node-set:
  • &lt;xsl:for-each select="catalog/cd"&gt;
  • We can also filter the output from the XML file by adding a criterion to the select attribute in the &lt;xsl:for-each&gt; element.
  • ...1 more annotation...
  • Legal filter operators are: =&nbsp; (equal) != (not equal) &amp;lt; less than &amp;gt; greater than
David Gelpi Fleta

XML Attributes - 0 views

  • Attributes often provide information that is not a part of the data
  • &lt;gangster name='George "Shotgun" Ziegler'&gt;
  • &lt;gangster name="George 'Shotgun' Ziegler"&gt;
  • ...3 more annotations...
  • Use of Elements vs. Attributes Data can be stored in child elements or in attributes.
  • Should you avoid using attributes? Some of the problems with using attributes are: attributes cannot contain multiple values (child elements can) attributes are not easily expandable (for future changes) attributes cannot describe structures (child elements can) attributes are more difficult to manipulate by program code attribute values are not easy to test against a Document Type Definition (DTD) - which is used to define the legal elements of an XML document
  • Try to use elements to describe data. Use attributes only to provide information that is not relevant to the data.
David Gelpi Fleta

XSLT <xsl:apply-templates> Element - 0 views

  • The &lt;xsl:apply-templates&gt; element applies a template to the current element or to the current element's child nodes.
  • If we add a select attribute to the &lt;xsl:apply-templates&gt; element it will process only the child element that matches the value of the attribute
‹ Previous 21 - 34
Showing 20 items per page