Skip to main content

Diigo Home
Home/ Groups/ PSI_ESEI
David Gelpi Fleta

XML Schema Part 0: Primer Second Edition - 0 views

  • <xsd:element name="comment" type="xsd:string"/>
  • ref="comment"
    • David Gelpi Fleta
       
      Uso de elementos globales. Ver sección 2.2.2
  • 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.
  • ...47 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.
  • Naming Conflicts
  • What
    happens if we give two things the same name?
  • the more similar are the two things, the more
    likely there will be a conflict.
  • If the two things are both types
  • there is a conflict
  • If the two things are a type
    and an element or attribute,
  • If the two things are elements within
    different types (i.e. not global elements),

  • there is no conflic
  • there
    is no conflict
  • local
    element
  • 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
  • Attribute Groups
  • 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:
  • <xsd:attributeGroup ref="ItemDelivery"/>
  • <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>
  • 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
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
  • Predicates


    Predicates are used to find a specific node or a node that contains a
    specific value.

  • ...10 more annotations...
  • Predicates are always embedded in square brackets.

  • [1]
  • [last()]
  • [position()<3]
  • title[@lang]
  • [@lang]
  • [@lang='eng']
  • [price>35.00]
  • Wildcard
    Description


    *
    Matches any element node


    @*
    Matches any attribute node


    node()
    Matches any node of any kind
  • Selecting Several Paths


    By using the | operator in an XPath expression you can select several paths.



David Gelpi Fleta

XSLT Transformation - 0 views

  • <?xml-stylesheet type="text/xsl" href="http://www.w3schools.com/cdcatalog.xsl"?>
  • <?xml-stylesheet type="text/xsl" href="http://www.w3schools.com/cdcatalog.xsl"?>
  • <?xml-stylesheet type="text/xsl" href="http://www.w3schools.com/cdcatalog.xsl"?>
  • ...6 more annotations...
  • Example study: How to transform XML into XHTML using XSLT.
  • orrect Style Sheet Declaration



    The root element that declares the document to be an XSL style sheet is <xsl:stylesheet>
    or <xsl:transform>.

  • <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  • <xsl:transform version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  • 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

David Gelpi Fleta

Enunciado práctica - 41 views

English version of the practice available in section "Apuntes de prácticas" in Creaweb: http://creaweb.ei.uvigo.es/creaweb/jsp/crearAsignatura.jsp?codigo=110421 dgelpi wrote: > Estimad@s tod@s, > ...

practica

David Gelpi Fleta

XSL - 24 views

Hemos marcado a través de la herramienta Diigo lo estrictamente necesario para añadir una capa de presentación a los datos etiquetados mediante XML. Encontraréis los apuntes en los "bookmarks" del grup...

practica

started by David Gelpi Fleta on 27 Nov 07 no follow-up yet
David Gelpi Fleta

Introduction to XSLT - 0 views

  • What is XSLT?


    • XSLT stands for XSL Transformations
    • XSLT is the most important part of XSL
    • XSLT transforms an XML document into another XML document
    • XSLT uses XPath to navigate in XML documents
    • XSLT is a W3C Recommendation
  • XSLT is used to transform an XML document into another XML document, or another
    type of document that is recognized by a browser, like HTML and
    XHTML. Normally XSLT does this by transforming each XML element into an (X)HTML
    element.
  • A common way to describe the transformation process is to say that
    XSLT transforms an XML source-tree into an XML result-tree.
  • ...2 more annotations...
  • XSLT Uses XPath


    XSLT uses XPath to find information in an XML document. XPath is used to
    navigate through elements and attributes in XML documents.

  • How Does it Work?


    In the transformation process, XSLT uses XPath to define parts of the source
    document that should match one or more predefined templates. When a match is found,
    XSLT will transform the matching part of the source document into the result
    document.

David Gelpi Fleta

XSLT <xsl:if> Element - 0 views

  • <xsl:if test="expression">
    ...
    ...some output if the expression is true...
    ...
    </xsl:if>
  • add the <xsl:if> element inside the <xsl:for-each> element
  • <xsl:for-each select="catalog/cd">
    <xsl:if test="price &gt; 10">
David Gelpi Fleta

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

  • The <xsl:apply-templates> element applies a template to the current
    element or to the current element's child nodes.
  • If we add a select attribute to the <xsl:apply-templates>
    element it will process only the child element that matches the value of the
    attribute
David Gelpi Fleta

XSLT <xsl:sort> Element - 0 views

  • To sort the output, simply add an <xsl:sort> element inside the <xsl:for-each> element in
    the XSL file:
  • <xsl:for-each select="catalog/cd">
    <xsl:sort select="artist"/>
David Gelpi Fleta

XSLT <xsl:choose> Element - 0 views

  • The <xsl:choose> element is used in conjunction with <xsl:when>
    and <xsl:otherwise> to express multiple
    conditional tests.
  • <xsl:choose>
    <xsl:when test="expression">
    ... some output ...
    </xsl:when>
    <xsl:otherwise>
    ... some output ....
    </xsl:otherwise>
    </xsl:choose>
David Gelpi Fleta

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

  • The <xsl:for-each> Element


    The XSL <xsl:for-each> element can be used to select every XML
    element of a specified node-set:

  • <xsl:for-each select="catalog/cd">
  • We can also filter the output from the XML file by adding a criterion to the
    select attribute in
    the <xsl:for-each> element.


  • ...1 more annotation...
  • Legal filter operators are:


    • =  (equal)
    • != (not equal)
    • &lt; less than
    • &gt; greater than
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

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.

  • <xsl:template> 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).

  • <xsl:template match="/">
    <html>
  • ...3 more annotations...
  • Since an XSL style sheet is an XML document itself, it always begins with the
    XML
    declaration: <?xml version="1.0" encoding="ISO-8859-1"?>
  • <xsl:stylesheet>, defines that this
    document is an XSLT style sheet document
  • The content inside the <xsl:template> element defines some HTML to write to
    the output.
David Gelpi Fleta

XSLT <xsl:value-of> Element - 0 views

  • The <xsl:value-of> element is used to extract the value of a selected node.
  • <xsl:value-of select="catalog/cd/title"/>
  • he value of the select attribute is an XPath
    expression.

    An XPath expression works like navigating a file system; where a forward slash (/) selects subdirectories.
    • David Gelpi Fleta
David Gelpi Fleta

Código ejemplos laboratorio. - 22 views

Están disponibles (por el momento) - ejercicio base sobre trabajo con espacio de nombres - ejercicio con recurso Include - ejercicio con recurso Import - ejercicio con Tipos Derivados - ejercicio con ...

ejercicios

David Gelpi Fleta

Extensible Markup Language (XML) 1.0 (Second Edition) - 0 views

  • A Name is a
    token beginning with a letter or one of a few punctuation characters, and
    continuing with letters, digits, hyphens, underscores, colons, or full stops,
    together known as name characters.] Names beginning with the string "
    xml
    ", or any string which would match (('X'|'x') ('M'|'m') ('L'|'l'))
    , are reserved for standardization in this or future versions of this
    specification.
  • An
    Nmtoken
    (name token) is any mixture of name characters.
  • NameChar   ::=   
    Letter | Digit
    | '.' | '-' | '_' | ':' | CombiningChar
    | Extender
  • ...1 more annotation...
  • Nmtoken   ::=   
    (NameChar)+
David Gelpi Fleta

XML Schema Part 2: Datatypes Second Edition - 0 views

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"/>
    • hocevik hocevik
       
      Simple Element tanımı aşağıdaki gibi :

    • hocevik hocevik
       
      Simple element tanımı :
      <xs:element name="lastname" type="xs:string"/>
  • 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"/>
hocevik hocevik

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
etcidou

ejercicio 0: presentación - 79 views

Ei k pasa gente!!!! Soy Esteban y suelo ir -si surge- los jueves de 4 a 6. nos vemos los jueves !!!!

ejercicios

1 - 20 of 44 Next › Last »
Showing 20 items per page