XML Tutorial HTML Tutorial "> XML Tutorial HTML Tutorial ">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML WITH CSS.

Similar presentations


Presentation on theme: "XML WITH CSS."— Presentation transcript:

1 XML WITH CSS

2 Example1. xml <. xml version="1
Example1.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml-stylesheet type="text/css" href="tutorials.css"?> <tutorials> <tutorial> <name>XML Tutorial</name> <url> </tutorial> <tutorial> <name>HTML Tutorial</name> <url> </tutorial> </tutorials>

3 tutorials .css tutorials { margin:10px; background-color:#ccff00; font-family:verdana,helvetica, sans-serif; } name { display:block; font-weight:bold; } url { display:block; color:#636363; font-size:small; font-style:italic; }

4

5 XPath

6

7 XML documents can be thought of as a Tree Structure, made up of parent, child, and sibling relationships. XPath expression describes the location of an element or attribute in our XML document select any element in the document by creating a chain of children elements. XPath Expression inventory/snack/chips/amount XPath is for Attribute!

8

9 Absolute Location – from root
Relative Location - to select every element amount XPath - Descendants "//“ drink//price XPath - Parent .. amount/.. XPath - Wildcard * inventory/snack/chips/* XPath – Combining Expressions with | inventory/snack/chips/* | inventory/drink/pop/* XPath – Predicates inventory/drink/lemonade[amount>15] inventory/drink/pop/amount[. < 20]

10 XPath Axes An axis defines a node-set relative to the current node axisname::nodetest[predicate] child::book Selects all book nodes that are children of the current node XPath Operators returns either a node-set, a string, a Boolean, or a number. Division 8 div 4 2 Equal price=9.80 TRUE/FALSE

11 XPath Standard Functions
100 built-in functions. Node-Set Functions position() String Functions string(e) Boolean Functions true() Number Functions round(e)

12 XSLT

13

14

15 Extensible Stylesheet Language Transformations
XSL actually comes in two parts transformation language (XSLT) formatting language XSLT documents need to be well-formed and valid XML documents <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl=" </xsl:stylesheet>

16 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="tutorials.xsl"?> <tutorials> <tutorial> <name>XML Tutorial</name> <url> </tutorial> <name>HTML Tutorial</name> <url> </tutorial> </tutorials>

17 XSLT <template> Element
select a node from your XML document and transform its contents Selecting the Root Node <xsl:template match="/"> <xsl:template match="tutorials"> XSLT <apply-templates> Element determine where the content of its children appear

18 <xsl:template match="tutorials"> <html> <head> <title>My XSLT Example</title> </head> <body> <p>New content...</p> </body> </html> </xsl:template>

19 XSLT <value-of> Element
retrieve the value from a node the select attribute to extract data from the child nodes <xsl:value-of select="name"/> the select attribute (“.”) specifies the current node <xsl:value-of select="."/> XSLT <for-each> Element loop through multiple nodes that match the selection criteria

20 XSLT <sort> Element
sort the output of the <xsl:for-each> element. <xsl:sort select="name"/> XSLT <if> Element perform conditional statements against the contents of your XML document <xsl:if =‘value’ to check)"> symbol - specify an attribute XSLT <choose> Element to compare a value against a range of possible values

21 used in conjunction with the <xsl:when> and <xsl:otherwise> elements
<xsl:choose> <xsl:when ---- </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose>

22


Download ppt "XML WITH CSS."

Similar presentations


Ads by Google