Soa XSLT Xpath Xquery
Soa XSLT Xpath Xquery
Introduction
XSL: EXtensible Stylesheet Language.
Defined by the WWW Consortium (W3C)
CSS - Stylesheets for HTML
XSL - Stylesheets for XML
XSLT
A common way to describe the transformation process is to say that XSLT
transforms an XML source -tree into an XML result tree
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
With XSLT you can add/remove elements and attributes to or from the
output file.
You can also rearrange and sort elements, perform tests and make
decisions about which elements to hide and display
XSLT - Transformation
Write an XML
Write an XSLT
Declaring XSLT:
<xsl:stylesheet version="1.0 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Link the XSLT to XML Document:
<?xml - stylesheet type="text/xsl" href= XSLName"?>
XSLT - Basics
xsl:template Element
Is used to build templates
The match attribute is used to associate a template with an XML element
xsl:value - of element to select values from the XML elements.
xsl:for- each element can be used to select every XML element of a specified node - set
Filtering the output: Filter the output from the XML file by adding a criterion to the select
attribute
Eg: <xsl:for-each select="catalog/cd[artist= SDTech'] />
XSLT - Basics
XSLT - Basics
Templates
Are rules to apply to the data
Similar to Procedures / Functions
XPath
XPath
XPath is a W3C recommendation
XPath contains a library of standard functions
XPath uses path expressions to select nodes or node - sets in an XML document.
Helps you navigate through the XML document.
Simple language consisting of path expressions.
XPath uses expressions to select nodes or node - sets in an XML document
Each vendor has already defined a lot of XPath functions
XPath Expressions
Expression Description
XPath Wildcards
Expression Description
* Matches any element node
@* Matches any attribute node
| Selects two nodes with AND
Selects the current node
Selects the parent of current node @ Selects attributes
XPath Axes
ancestor Selects all ancestors (parent, grandparent, etc.) of the current node
ancestor- or- self Selects all ancestors (parent, grandparent, etc.) of the current node
and the current node itself
attribute Selects all attributes of the current node
child Selects all children of the current node
descendant Selects all descendants (children, grandchildren, etc.) of the current node
descendant- or- self Selects all descendants (children, grandchildren, etc.) of the
current node and the current node itself
following Selects everything in the document after the closing tag of the current node
following - sibling Selects all siblings after the current node
XPath Functions
XQuery
XQuery
XQuery - Basics
XQuery - Basics
The for clause selects all book elements under a node element into a variable.
The where clause selects only elements with a filter. The order by clause defines the
sort - order. Will be sort by the specified element.
XQuery - Syntax