Download presentation
Presentation is loading. Please wait.
Published byJonah Horton Modified over 8 years ago
1
XML, XPATH, XSL Part IV
2
XSLT Extensible Stylesheet Language Transformations XSLT is used for converting XML to some other output or restructuring XML XSLT utilizes XPath XSLT is a declarative language, written in XML
3
Original XML document In memory Source tree + In memory Result tree XSL Template XSLT Transformation Process Serialization Target Document
4
Foundational XSLT Elements XSLT is writing in XML, the root element of XSLT is or contains template for the output tell the XSLT processor to apply specific template to specific node of the source tree
5
Source tree info. extraction : provides the value of a part of the source tree that represents the source XML document. : copies a node to the result tree, but it doesn’t copy any descendant nodes or attributes : a deep copy (a node, together with all its attribute nodes and descendant nodes, is copied to the result tree)
6
Adding child element/attribute : add new attribute to the context node in the result tree : add child node to the context node in the result tree
7
Winston Churchill Winston Churchill was a mid 20th century British politician who became famous as Prime Minister during the Second World War. Indira Gandhi Indira Gandhi was India’s first female prime minister and was assassinated in 1984. John F. Kennedy JFK, as he was affectionately known, was a United States president who was assassinated in Dallas, Texas. Example 1: people.xml
8
Example 1: people.xml on Firefox
9
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > Information about people. Information about people. Example 1: people.xsl
10
Winston Churchill Winston Churchill was a mid 20th century British politician who became famous as Prime Minister during the Second World War. Indira Gandhi Indira Gandhi was India’s first female prime minister and was assassinated in 1984. John F. Kennedy JFK, as he was affectionately known, was a United States president who was assassinated in Dallas, Texas. Example 1: people.xml links to people.xsl
11
Example 1: people.xml+people.xsl on Firefox
12
Example 2: people2.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
13
Example 2: Another version of people2.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
14
Example 2: restructuring people.xml with people2.xsl pout.xml
15
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > Example 3: people3.xsl
16
Example 3: restructuring pout.xml(Ex2) with people3.xsl pout1.xml
17
Example4: people4.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
18
Example 4: pout1.xml+people4.xsl on Firefox
19
Example 5: p_order.xml Example.org XMML.com 234 Any Street Any Town MO 98765 Wheel Basket
20
Example 5: invoice.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
21
Example 5: transform p_order.xml using invoice.xsl
22
Conditional Processing : tests whether a Boolean condition is true or false.,, : Loop Processing : allows all nodes in a node-set to be processed
23
Julius Caesar Anne Boleyn George Washington Martin Luther Methuselah Moses Asterix the Gaul Example 6: characters.xml
24
Age check on Characters. The recorded age is unusually high. Please check original data. is older than expected. Please check if this character's age,, is correct. Example 6: characters.xsl
25
Example 6: character.xml + characters.xsl
26
Example 7: characters1.xsl Age check on all Characters. The following is the assessment of the age data. - too high. Please check if this character's age,, is correct. - ok
27
Example 7: character.xml + characters1.xsl
28
Example 7: modify character1.xsl->characters2.xsl - too high. Please check if this character's age,, is correct. - too low. Please check if this character's age,, is correct. - ok
29
Example 7: character.xml + characters2.xsl
30
Example 8: object.xml Hard Shiny Has 4 wheels Internal Combustion Engine
31
Example 8: object.xsl Object Characteristics Characteristics of
32
Example 8: object.xml+object.xsl
33
: is used to specify sort order for node-sets. mode Attribute: allows certain node to be precessed more than once. This attribute is used together with –
34
Object Characteristics Characteristics of Example 9: object1.xsl
35
Example 9: object.xml + object1.xsl
36
David Hunter Danny Ayers Jeff Rafter John Duckett Eric van der Vlist Andrew Watt Joe Fawcett 2007 XML is a markup language, derived from SGML. To be well-formed an XML document must satisfy several rules about its structure. To help unambiguously identify the names of elements and attributes the notion of an XML namespace is used. A document type definition, DTD, is a way to specify the permitted structure of an XML document. W3C XML Schema and Relax NG are two schema languages to specify the structure of XML documents. Example 10: book.xml
37
Example 10: book.xsl by Table of Contents, and. :.
38
Example 10: book.xml + book.xsl
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.