Skip to main content

Home/ PSI_ESEI_08/ Group items tagged namespaces

Rss Feed Group items tagged

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.
  • Name Conflicts In XML, element names are defined by the developer. This often results in a conflict when trying to mix XML documents from different XML applications.
  • <h:table>
  • ...13 more annotations...
  • <f:table>
  • XML Namespaces - The xmlns Attribute When using prefixes in XML, a so-called namespace for the prefix must be defined. The namespace is defined by the xmlns attribute in the start tag of an element.
  • <h:table xmlns:h="http://www.w3.org/TR/html4/">
  • xmlns:prefix="URI".
  • <f:table xmlns:f="http://www.w3schools.com/furniture">
  • xmlns:namespace-prefix="namespaceURI"
  • Namespaces can be declared in the elements where they are used or in the XML root element:
  • 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.
  • The namespace URI is not used by the parser to look up information. The 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.
  • <table xmlns="http://www.w3.org/TR/html4/">
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

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

XSLT Transformation - 0 views

  • xmlns:xsl="http://www.w3.org/1999/XSL/Transform" points to the official W3C XSLT namespace.
  • Link the XSL Style Sheet to the XML Document Add the XSL style sheet reference to your XML document
  • <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  • ...3 more annotations...
  • <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  • orrect Style Sheet Declaration The root element that declares the document to be an XSL style sheet is <xsl:stylesheet> or <xsl:transform>.
  • Example study: How to transform XML into XHTML using XSLT.
David Gelpi Fleta

XPath Nodes - 0 views

  • In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document (root) nodes.
  • XML documents are treated as trees of nodes. The root of the tree is called the document node (or root node).
  • Atomic values Atomic values are nodes with no children or parent.
  • ...5 more annotations...
  • Children Element nodes may have zero, one or more children.
  • Relationship of Nodes Parent Each element and attribute has one parent.
  • Siblings Nodes that have the same parent.
  • Ancestors A node's parent, parent's parent, etc.
  • Descendants A node's children, children's children, etc.
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 CDATA - 0 views

  • PCDATA - Parsed Character Data XML parsers normally parse all the text in an XML document.
  • CDATA - (Unparsed) Character Data
  • Escape Characters Illegal XML characters have to be replaced by entity references. If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element.
  • ...5 more annotations...
  • < < less than > > greater than & & ampersand  ' ' apostrophe " " quotation mark
  • Apostrophes, quotation marks and greater than signs are legal, but it is a good habit to replace them.
  • CDATA Everything inside a CDATA section is ignored by the parser.
  • Nested CDATA sections are not allowed.
  • A CDATA section starts with "<![CDATA[" and ends with "]]>":
1 - 7 of 7
Showing 20 items per page