Download - 3 Displaying and Navigating through XML
-
8/14/2019 3 Displaying and Navigating through XML
1/26
XSL
Style sheets
-
8/14/2019 3 Displaying and Navigating through XML
2/26
CSS
Cascading Style Sheet Style sheets are used to specify how
the tags will be rendered in the targetapplication.
CSS were initially designed to be used
with html. It is now used with XML too. 2 levels CSS Level 1 and Level 2
-
8/14/2019 3 Displaying and Navigating through XML
3/26
Contemplation
If today was a perfect there would be no need for tomorrow. God
-
8/14/2019 3 Displaying and Navigating through XML
4/26
topic {display: block;font-size: large;
}by {
display:block;
font-size:small;text-align: right;color: navy;
}body{
font: 20 pt Arial;color: red;
margin-left: 2.0 in }
-
8/14/2019 3 Displaying and Navigating through XML
5/26
Limitation of CSS
Syntax is not XML. CSS does not filter and rearrange data.
That is you cannot reorder things, andyou cannot conditionally perform stylingwithout resorting to scripting.
-
8/14/2019 3 Displaying and Navigating through XML
6/26
XSL
Extensible Stylesheet Language for TransformationsXSL is used to render XML document. Itovercomes the disadvantages of CSS.
Parts of XSL: XSLT (XSL transformation): vocabulary
describing the formatting of XML XSL-FO : the part that covers formatting
objects, also known as flow objects. XPath (XML Path Language): language
used to address XML document fragments
-
8/14/2019 3 Displaying and Navigating through XML
7/26
XSLT
The XSLT transformation standard isessentially a translation mechanism that letsyou specify what to convert an XML tag into sothat it can be displayedfor example, in
HTML. Different XSL formats can then be usedto display the same data in different ways, for different uses.
XSLT works with XSLT processor. The
processor can be invoked using command linewhere xml file, xsl file and html file (where theoutput will be written) needs to be supplied .
-
8/14/2019 3 Displaying and Navigating through XML
8/26
XPATH XML Path Language The XPATH standard is an addressing
mechanism that you use whenconstructing transformation instructions, inorder to specify the parts of the XMLstructure you want to transform.
Important in exchange of informationbetween computers because it allowsfiltering and selecting information from thesource XML document.
Used with XSLT, XPointer, XLink and otherXML-related technologies.
-
8/14/2019 3 Displaying and Navigating through XML
9/26
Working XPath has a starting point, the context node, and then
we move on in a particular direction, called an axis. Finally we arrive at our destination moving one or more
steps called location steps.
A location step has three parts An axis A node test, which specifies the node type and
expanded name of the nodes selected by the
location step Zero or more predicates, which use arbitrary XPath
expression to further refine the set of nodes selectedby the location step.
-
8/14/2019 3 Displaying and Navigating through XML
10/26
Example: XSTL with XPath Divinity National
Nilakandan Narayanan
Mohan Madan
XML Document withXSL linked
-
8/14/2019 3 Displaying and Navigating through XML
11/26
Employee Data,
First NameLast
NameDate of birth
stxsl.xsl XSL document
-
8/14/2019 3 Displaying and Navigating through XML
12/26
-
8/14/2019 3 Displaying and Navigating through XML
13/26
A template is a structured container that manages
the way a source tree or a portion of the source treeis transformed. xsl:template defines a set of rules for transforming
nodes in source document into the result tree. Thisis handled by the match attribute.
Example: Matches the
root node
-
8/14/2019 3 Displaying and Navigating through XML
14/26
Fragrance
Rose
Fragrance Rose
XSL
XML
Result
Children of thenamed templateare processed
-
8/14/2019 3 Displaying and Navigating through XML
15/26
Evaluates the node and returns thestring between the node.
Example:
-
8/14/2019 3 Displaying and Navigating through XML
16/26
Selection Patterns
element name:
child elements
Selects the company node assuming that the contextnode is employee-info
descendents
Selects fname node if it is descendent of the contextnode
attributes :
Axes
Node Test Expression
Predicate / XPath Expression
-
8/14/2019 3 Displaying and Navigating through XML
17/26
More Predicates child::employee[position()=2]
Node representing the 2nd employee element. child::employee[position()=last()]
Node representing the last employee element.
child::employee[position()=last()-1]Node representing the last but one employee element.
select="/employee-info/employee[@join=1999]"Nodes representing employee whose join attribute is1999.()
-
8/14/2019 3 Displaying and Navigating through XML
18/26
This tag makes it possible to repeat the sameset of processing for each instance of
element specified in the pattern.
-
8/14/2019 3 Displaying and Navigating through XML
19/26
First NameLast NameDateof birth
XSLT with style
-
8/14/2019 3 Displaying and Navigating through XML
20/26
To transform XML into HTML
-
8/14/2019 3 Displaying and Navigating through XML
21/26
Conditions ..
Single condition
Multiple Condition
-
8/14/2019 3 Displaying and Navigating through XML
22/26
-
8/14/2019 3 Displaying and Navigating through XML
23/26
Creating elements
Is used to create an element in XSL
document. Example:
Creates an tag element
-
8/14/2019 3 Displaying and Navigating through XML
24/26
XLink and XPointer
Linking in XML is divided into two parts: XLinkand XPointer.
XLink defines a standard way of creatinghyperlinks in XML documents.
XPointer allows the hyperlinks to point tomore specific parts (fragments) in the XMLdocument.
-
8/14/2019 3 Displaying and Navigating through XML
25/26
-
8/14/2019 3 Displaying and Navigating through XML
26/26
XPointer Syntax
If the hyperlink points to an XML document, we canadd an XPointer part after the URL in the
xlink:href attribute, to navigate (with an XPathexpression) to a specific place in the document.