Skip to main content

Home/ PSI_ESEI/ Group items tagged XSLT

Rss Feed Group items tagged

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 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"?>
  • Example study: How to transform XML into XHTML using XSLT.
  • ...6 more annotations...
  • orrect Style Sheet Declaration The root element that declares the document to be an XSL style sheet is <xsl:stylesheet> or <xsl:transform>.
  • 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">
  • <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  • <?xml-stylesheet type="text/xsl" href="http://www.w3schools.com/cdcatalog.xsl"?>
  • xmlns:xsl="http://www.w3.org/1999/XSL/Transform" points to the official W3C XSLT namespace.
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

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

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

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: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
David Gelpi Fleta

XSLT <xsl:choose> Element - 0 views

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

XSLT <xsl:sort> Element - 0 views

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

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

  • The &lt;xsl:value-of&gt; element is used to extract the value of a selected node.
  • &lt;xsl:value-of select="catalog/cd/title"/&gt;
  • 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

XSLT <xsl:if> Element - 0 views

  • &lt;xsl:if test="expression"&gt; ... ...some output if the expression is true... ... &lt;/xsl:if&gt;
  • add the &lt;xsl:if&gt; element inside the &lt;xsl:for-each&gt; element
  • &lt;xsl:for-each select="catalog/cd"&gt; &lt;xsl:if test="price &amp;gt; 10"&gt;
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
1 - 12 of 12
Showing 20 items per page