Download presentation
Presentation is loading. Please wait.
1
XSLT Part 2
2
Catalog.xml <?xml version="1.0"?> <catalog> <book>
<title language="English">Fun With XML</title> <author>John Robot</author> <isbn>12367</isbn> <price>70</price> </book> language="English">Xml and Java</title> <author>Mary Jones</author> <isbn>7856</isbn> <price>34</price>
3
Applying Template Rules
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:template match="catalog"> <html> <xsl:apply-templates/> </html> </xsl:template> <xsl:template match="book"> <P> </P> </xsl:stylesheet> Two template rules
4
XSL Templates Template rules are defined by xsl:template elements.
These associate particular output with particular input. Each xsl:template element has a match attribute that specifies which nodes of the input document the template is instantiated for. The content of the xsl:template element is the actual template to be instantiated. A template may contain both text that will appear literally in the output document and XSLT instructions that copy data from the input XML document to the result.
5
Example A template rule applied to the root node
<xsl:template match="/"> <html> <head> </head> <body> </body> </html> </xsl:template> This text is output in the root node
6
Recursively processing the children of the root
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:template match="/"> <html> <xsl:apply-templates/> </html> </xsl:template> <xsl:template match="catalog"> <body> </body> <xsl:template match="book"> A Book </xsl:stylesheet> Matches the root node The child nodes of the root node are processed
7
To choose a specific set of children
<xsl:template match="/"> <html> <xsl:apply-templates/> </html> </xsl:template> <xsl:template match="catalog"> <body> </body> <xsl:template match="book"> A Book <xsl:apply-templates select="title" /><br/> </xsl:stylesheet> To choose a specific set of children
8
Computing the value of a node with xsl:value-of
The xsl:value-of element computes the value of something (most of the time, though not always, something in the input document) and copies it into the output document. The select attribute of the xsl:value-of element specifies exactly which something's value is being computed. The value of a node is always a string, possibly an empty string. The value of an element node is concatenation of all the character data between the element's start tag and end tag.
9
Example <html> <xsl:apply-templates/> </html>
<xsl:template match="/"> <html> <xsl:apply-templates/> </html> </xsl:template> <xsl:template match="catalog"> <body> </body> <xsl:template match="book"> <br/>Title: <xsl:value-of select="title"/> <br/>Author: <xsl:value-of select="author"/> </xsl:stylesheet>
10
Output Title: Fun With XML Author: John Robot Title: Xml and Java Author: Mary Jones Title: Speaking in Spanish Author: Michael Herrara Title: Adventures Of Freddie Frog Author: Susan Kidder
11
Xsl:for-each < Xsl:for-each> instruction selects a set of nodes using an XPath expression and performs the same processing for each node in the set.
12
Processing multiple elements with xsl:for-each - Example
<xsl:template match="/"> <html> <xsl:apply-templates/> </html> </xsl:template> <xsl:template match="catalog"> <body> <table width="100%" border="2"> <tr> <th>Title</th> <th>Author</th> <th>ISBN</th> <th>Price</th> </tr> <xsl:for-each select="book"> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="author"/></td> <td><xsl:value-of select="isbn"/></td> <td><xsl:value-of select="price"/></td> </xsl:for-each> </table> </body> </xsl:stylesheet>
13
Apply-templates vs for-each
< Xsl:apply-templates> is a rule-based pattern and is most useful when processing an element that may contain children of different types in an unpredictable sequence. This approach works well when the document itself evolves over time. This style of processing is sometimes called push processing. <xsl:for-each>: When the structure is more regular and predictable, it is simpler to navigate around the document using xsl:for-each. The required data is accessed directly using xsl:value-of. This is sometimes called pull processing.
14
Making choices <!-- Selection --> <xsl:template match="/">
<html> <xsl:apply-templates/> </html> </xsl:template> <xsl:template match="catalog"> <body> </body> <xsl:template match="book"> <xsl:choose> <xsl:when = 'English'"> <p><xsl:value-of select="title"/> -Paperback available </p> </xsl:when> </xsl:choose> </xsl:stylesheet>
15
Patterns for matching nodes
Using a single template to apply to more than one element: Use the asterisk wildcard (*) in place of an element name in the match attribute. For example, the template below says that all elements should be wrapped in a P element: <xsl:template match="*"> <P> <xsl:value-of select="."/> </P> </xsl:template> In the event that two rules both match a single node, then by default the more specific one takes precedence.
16
Patterns for matching nodes
Matching children with / You can use the / symbol to match specified hierarchies of elements. Used alone, the / symbol refers to the root node. However, you can use it between two names to indicate that the second is the child of the first. For example, book/title refers to title element that are children of book elements. Example: <xsl:template match="book/price"> <u><xsl:value-of select="."/></u> </xsl:template>
17
Patterns for matching nodes
Sometimes, especially with an uneven hierarchy, you may find it easier to bypass intermediate nodes and simply select all the elements of a given type, whether they're immediate children, grandchildren, and so on. The double slash, //, refers to a descendant element at an arbitrary level. For example, this template rule applies to all NAME descendants of catalog, no matter how deep: <xsl:template match="catalog//title"> <i><xsl:value-of select="."/></i> </xsl:template> The // operator at the beginning of a pattern selects any descendant of the root node. For example, this template rule processes all price elements while completely ignoring their location: <xsl:template match="//price"> <i><xsl:value-of select="."/></i> </xsl:template>
18
Example <?xml version="1.0"?> <xsl:stylesheet version="1.0"
xmlns:xsl=" <xsl:template match="/"> <html><head><title>Book Catalog</title> </head> <xsl:apply-templates/> <body></body></html> </xsl:template> <xsl:template match="catalog//title"> <i><xsl:value-of select="."/></i> </xsl:stylesheet>
19
Matching with [] You can test for more details about the nodes that match a pattern using []. You can perform many different tests including: Whether an element contains a given child, attribute, or other node Whether the value of an attribute is a certain string Whether the value of an element matches a string What position a given node occupies in the hierarchy
20
Example The select attribute is used in xsl:apply-templates, xsl:value-of, xsl:for-each, xsl:copy-of, xsl:variable, xsl:param, and xsl:sort to specify exactly which nodes are operated on. The value of select attribute is an expression written in the XPath language. The XPath language provides a means of identifying a particular element, group of elements, text fragment, or other part of an XML document. Expressions are a superset of the match patterns that enable you to match nodes by element name, child elements, descendants, and attributes, as well as by making simple tests on these items. XPath expressions allow you to select nodes through all these criteria but also by referring to ancestor nodes, parent nodes, sibling nodes, preceding nodes, and following nodes. Furthermore, expressions aren't limited to producing merely a list of nodes, but can also produce booleans, numbers, and strings.
21
Node axes Expressions are not limited to specifying the children and descendants of the current node. XPath provides a number of axes that you can use to select from different parts of the tree relative to some particular node in the tree called the context node. In XSLT, the context node is normally initialized to the current node that the template matches, though there are ways to change this.
22
Some XPath Expressions
Axis: Selects From: ancestor The parent of the context node, the parent of the parent of the context node, the parent of the parent of the parent of the context node, and so forth back to the root node ancestor-or-self The ancestors of the context node and the context node itself Attribute The attributes of the context node Child The immediate children of the context node descendant The children of the context node, the children of the children of the context node, and so forth descendant-or-self The context node itself and its descendants following All nodes that start after the end of the context node, excluding attribute and namespace nodes nodes that start after the end of the context node and have the same parent as the context node namespace The namespace of the context nodeparent. The unique parent node of the context node preceding All nodes that finish before the beginning of the context node, excluding attribute and namespace nodes preceding-sibling All nodes that start before the beginning of the context node and have the same parent as the context nodeself
23
Example <?xml version="1.0"?> <xsl:stylesheet version="1.0"
xmlns:xsl=" <xsl:template match="/catalog"> <HTML> <HEAD><TITLE>Catalog</TITLE></HEAD> <BODY> <xsl:apply-templates select="book"/> </BODY> </HTML> </xsl:template> <xsl:template match="book"> <P> <xsl:value-of select="position()"/>. <xsl:value-of select="title"/> </P> </xsl:stylesheet>
24
Output: 1. Fun With XML 2. Xml and Java 3. Speaking in Spanish 4. Adventures Of Freddie Frog
25
Examples This template rule applies to all book elements that are not the first child element of the catalog by testing whether the position is greater than 1: <xsl:template match=“catalog/book[position()>1]"> <xsl:value-of select="."/> </xsl:template> This template matches both the first and last book elements in their parent by matching when the position is 1 or when the position is equal to the number of elements in the set: <xsl:template match=“book[position()=1 or position()=last()]"> <xsl:value-of select="."/> </xsl:template>
26
Default Template Rules
XSLT defines several default template rules that are implicitly included in all style sheets. The first default rule matches root and element nodes, and applies templates to all child nodes. The second default rule matches text nodes and attributes, copying their values onto the output stream. Together these two rules mean that even a blank XSLT style sheet with just one empty xsl:stylesheet element will still produce the raw character data of the input XML document as output. The default rule for elements The first default rule applies to element nodes and the root node: <xsl:template match="*|/"> <xsl:apply-templates/> </xsl:template> *|/ is XPath shorthand for "any element node or the root node." The purpose of this rule is to ensure that all elements are recursively processed even if they aren't reached by following the explicit rules. That is, unless another rule overrides this one (especially for the root element), all element nodes will be processed. However, once an explicit rule for any parent of an element is present, this rule will not be activated for the child elements unless the template rule for the parent has an xsl:apply-templates child. For instance, you can stop all processing by matching the root element and neither applying templates nor using xsl:for-each to process the children like this: <xsl:template match="/"> </xsl:template>
27
Default Template Rules
Text and attribute nodes: <xsl:template <xsl:value-of select="."/> </xsl:template> This rule matches all text and attribute nodes and outputs the value of the node (<xsl:value-of select="."/>). In other words, it copies the text from the input to the output. This rule ensures that at the very least an element's text is output, even if no rule specifically matches it. Another rule can override this one for specific elements where you want either more or less than the text content of an element. This rule also copies attribute values (but not names). However, they turn from attributes in the input to simple text in the output. Because there's no default rule that ever applies templates to attributes, this rule won't be activated for attributes unless you specifically add a nondefault rule somewhere in the style sheet that does apply templates to attributes of one or more elements.
28
Generating an XML document from another XML document
29
Cont. --> <?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=" version="1.0"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="FitnessCenter"> <xsl:element name="FitnessCenter"> </xsl:element> <xsl:template match="Member"> <xsl:element name="Member"> Cont. -->
30
<xsl:template match="Name">
<xsl:element name="Name"> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="Phone"> <xsl:element name="Phone"> <xsl:template match="FavoriteColor"> <xsl:element name="FavoriteColor"> <xsl:template match="text()"> <xsl:value-of select="."/> </xsl:stylesheet>
31
<?xml-stylesheet type="text/xsl" href="FitnessCenter.xsl"?>
FitnessCenter.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="FitnessCenter.xsl"?> <FitnessCenter> <Member level="platinum"> <Name>Jeff</Name> <Phone type="home"> </Phone> <Phone type="work"> </Phone> <FavoriteColor>lightgrey</FavoriteColor> </Member> <Member level="gold"> <Name>David</Name> <Phone type="home"> </Phone> <Phone type="work"> </Phone> <FavoriteColor>lightblue</FavoriteColor> <Name>Roger</Name> <Phone type="home"> </Phone> <Phone type="work"> </Phone> <FavoriteColor>lightyellow</FavoriteColor> </FitnessCenter> FitnessCenter_new.xml <?xml version="1.0" encoding="UTF-8"?> <FitnessCenter> <Member> <Name>Jeff</Name> <Phone> </Phone> <Phone> </Phone> <FavoriteColor>lightgrey</FavoriteColor> </Member> <Name>David</Name> <Phone> </Phone> <Phone> </Phone> <FavoriteColor>lightblue</FavoriteColor> <Name>Roger</Name> <Phone> </Phone> <Phone> </Phone> <FavoriteColor>lightyellow</FavoriteColor> </FitnessCenter>
32
Note that we've lost the attribute on the Member element
<?xml version="1.0" encoding="UTF-8"?> <FitnessCenter> <Member> <Name>Jeff</Name> <Phone> </Phone> <Phone> </Phone> <FavoriteColor>lightgrey</FavoriteColor> </Member> <Name>David</Name> <Phone> </Phone> <Phone> </Phone> <FavoriteColor>lightblue</FavoriteColor> <Name>Roger</Name> <Phone> </Phone> <Phone> </Phone> <FavoriteColor>lightyellow</FavoriteColor> </FitnessCenter> Note that we've lost the attribute on the Member element
33
Getting Member’s Attribute:
<xsl:template match="Member"> <xsl:element name="Member"> <xsl:for-each <xsl:attribute name="{name(.)}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:apply-templates/> </xsl:element> </xsl:template> For each attribute Add an attribute to the element being output. The name of the attribute is the name of the current attribute being processed. The value of the attribute is the value of the current attribute being processed.
34
<?xml version="1.0" encoding="UTF-8"?>
<FitnessCenter> <Member level=“platinum”> <Name>Jeff</Name> <Phone type="home"> </Phone> <Phone type="work"> </Phone> <FavoriteColor>lightgrey</FavoriteColor> </Member> <Member level=“gold”> <Name>David</Name> <Phone type="home"> </Phone> <Phone type="work"> </Phone> <FavoriteColor>lightblue</FavoriteColor> <Name>Roger</Name> <Phone type="home"> </Phone> <Phone type="work"> </Phone> <FavoriteColor>lightyellow</FavoriteColor> </FitnessCenter>
35
Generalize Our identity stylesheet will only work for FitnessCenter XML documents. We can make a stylesheet which does an identity transformation on any XML document.
36
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl=" version="1.0"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="*"> <xsl:element name="{name(.)}"> <xsl:for-each <xsl:attribute name="{name(.)}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> </xsl:element> <xsl:template match="text()"> </xsl:stylesheet>
37
Default Template Rules
Every xsl document has two default template rules These rules are applied when the XSL Processor cannot find a template rule to use in your stylesheet Here are the two default template rules: <xsl:template match=“/ | *”> <xsl:apply-templates/> </xsl:template> <xsl:template match=“text()”> <xsl:value-of select=“.”/> “Match on the document or any element. The action is to go to the children and execute their template rules.” “Match on a text node. The action is to output the value of the text node.”
38
Multiple Applicable Rules
Suppose that the XSL Processor is processing FitnessCenter and it gets to the <Member> element. Why does it use: <xsl:template match=“Member”>... and not the default template rule: <xsl:template match=“/ | *”>... ??? After all, both apply. Answer: given two rules that apply, the more specific rule wins. --> Clearly, “*” is much more general than “Member”. “*” matches on any element. “Member” just matches on the Member element.
39
Smallest Identity Transformation Stylesheet
Now that we know about the default template rules, we can further reduce the size of the stylesheet.
40
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl=" version="1.0"> <xsl:output method="xml"/> <xsl:template match="*"> <xsl:element name="{name(.)}"> <xsl:for-each <xsl:attribute name="{name(.)}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:apply-templates/> </xsl:element> </xsl:template> </xsl:stylesheet>
41
<xsl:apply-templates select=“pattern”>
The xsl:apply-templates element (without the select attribute) tells the XSL Processor to apply the template rules to all children (in document order) The xsl: apply-templates element can have a select attribute that tells the XSL Processor to process only the child element that matches “pattern”. Thus, the select attribute rule enables us to specify the order in which the children are processed
42
<xsl:apply-templates select=“pattern”>
<xsl:template match="Member"> <xsl:apply-templates select="Name"/> <xsl:apply-templates </xsl:template> "Go to the template rule for my Name child element. Then go to the template rule for the work Phone child element." <xsl:template match="Member"> <xsl:apply-templates select="*"/> </xsl:template> "Go to all the child element nodes (not to any child text nodes)."
43
Copying Elements The xsl:copy element copies the source node into the output tree. Child elements, attributes, and other content are not automatically copied. However, the contents of the xsl:copy element are an xsl:template element that can select these things to be copied as well. This is often useful when transforming a document from one markup vocabulary to the same or a closely related markup vocabulary.
44
Shallow-copy vs Deep Copy
Copy and copy-of constructs are used for nodes copying. Copy element copies the current node in the source document to the current output destination. This is a shallow copy – copies only the current node without children and attributes. The main use of <xsl-copy> is when doing an XML-to-XML transformation in which parts of the document are to remain unchanged. <xsl-copy-of> copies a node-set to the current output destination. This is a deep copy, when a node is copied, its descendents are also copied.
45
Copying Elements Example 1
<!-- Find Book elements and copy them--> <xsl:template match="catalog"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="book"> <xsl:copy/> </xsl:stylesheet> Catalog.xml <?xml version="1.0"?> <catalog> <product code="1234" category="tools"> <description>Hammer</description> <weight units="lbs">0.5</weight> <price>12.00</price> </product> <product code="0000" category="tools"> <description>Nut</description> <weight units="lbs">0.1</weight> <price>2.00</price> <product code="7777" category="tools"> <description>Bolt</description> <price>1.00</price> <book> <title>Cosmos</title> <author >Sagan</author> </book> <title>XML Made Easy</title> <author >Joe Bloggs</author> </catalog>
46
Output <?xml version="1.0" encoding="utf-8" ?> - <catalog>
<book /> </catalog>
47
Copying Elements – Example 2
<!-- Find Book elements and copy them--> <xsl:template match="catalog"> <xsl:copy> <xsl:apply-templates/ </xsl:copy> </xsl:template> <xsl:template match="book"> <xsl:apply-templates/> <xsl:template match="title"> <xsl:value-of select="."/> <xsl:template match="text()"> </xsl:stylesheet>
48
Output <?xml version="1.0" encoding="utf-8" ?> - <catalog>
- <book> <title>Cosmos</title> </book> <title>XML Made Easy</title> </catalog>
49
Copying Elements Example 3
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl=" <!-- Find Book elements and copy them--> <xsl:template match="catalog"> <catalog> <xsl:for-each select="book"> <xsl:copy-of select="." /> </xsl:for-each> </catalog> </xsl:template> </xsl:stylesheet> <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl=" <!-- Deep copy --> <xsl:template match="catalog"> <xsl:for-each <xsl:copy-of select="." /> </xsl:for-each> </xsl:template> </xsl:stylesheet>
50
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl=" <!-- Generate another catalog with products that are less than 10 dollars--> <xsl:template match="*"> <xsl:copy> <xsl:copy-of /> <xsl:apply-templates /> </xsl:copy> </xsl:template> <xsl:template match="product [price > 10.00]" /> <xsl:template match="product/weight" /> </xsl:stylesheet>
51
What does this do? <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:template <xsl:copy> <xsl:apply-templates </xsl:copy> </xsl:template> </xsl:stylesheet>
52
Sum() The sum function calculates totals for a node-set. You need to be aware of nodes that do not contain values, as this function will return 'NaN' if one of the items is not numeric (i.e. empty). You will need to do formatting of your code to overcome this, i.e. replacing empty values with a 0. Example: calculate the total of all the book prices: <xsl:stylesheet xmlns:xsl=" version="1.0"> <xsl:template match="/"> <p>Total Price = <xsl:value-of select="sum(//price)"/></p> </xsl:template> </xsl:stylesheet>
53
Sum() <xsl:output method="html"/> <sales>
<xsl:template match="/"> <HTML> <BODY> <xsl:variable name="Space" select="' '"/> <xsl:for-each select="//data/month"> <br/><xsl:value-of select="name"/> <xsl:value-of select="$Space"/> <xsl:value-of '###,###')"/> </xsl:for-each> </BODY> </HTML> </xsl:template> </xsl:stylesheet> <sales> <summary> <heading>Book Store</heading> <subhead>Sales Report</subhead> <description>Sales Report for two months</description> </summary> <data> <month> <name>January 2002</name> <week number="1" books_sold="1000" /> <week number="2" books_sold="2000" /> <week number="3" books_sold="3000" /> <week number="4" books_sold="4000" /> </month> <name> April 2002</name> <week number="1" books_sold="700" /> <week number="3" books_sold="1000" /> <week number="4" books_sold="5000" /> </data> </sales>
54
Using modes Sometimes you want to include the same content from the source document in the output document multiple times. That's easy to do simply by applying templates multiple times, once in each place where you want the data to appear. However, suppose you want the data to be formatted differently in different locations? For example, you need two different rules that both apply to the same element at different places in the document. The solution is to give each of the different rules a mode attribute. Then you can choose which template to apply by setting the mode attribute of the xsl:apply-templates element.
55
Example <?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=" version="1.0"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="title" mode="normal"> <xsl:element name="title"> </xsl:element> <xsl:template match="catalog"> <xsl:element name="catalog"> <xsl:element name="SpanishBooks"> <xsl:for-each <xsl:apply-templates select="author" mode="footnote"/> </xsl:for-each>
56
Example <xsl:element name="book">
<xsl:template match="book"> <xsl:element name="book"> <xsl:for-each <xsl:attribute name="{name(.)}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:apply-templates mode="normal"/> </xsl:element> </xsl:template> <xsl:template match="author" mode="normal"> <xsl:element name="author"> <xsl:apply-templates/> <xsl:template match="author" mode="footnote"> <xsl:text>=====</xsl:text> <xsl:template match="isbn" mode="normal"> <xsl:element name="isbn"> <xsl:template match="price" mode="normal"> <xsl:element name="price"> <xsl:template match="text()"> </xsl:stylesheet>
57
mode Attribute Allows you to create multiple template rules for the same element. Each template rule can process the element differently. So, you can have multiple template rules for the same element. Just give each template rule a different mode <xsl:template match="Name" mode=“normal"> <xsl:template match="Name" mode="footnote">
58
Using Variables <xsl:template match="/">
<xsl:apply-templates/> </xsl:template> <xsl:template match="/catalog/book"> <xsl:variable name="booktitle" select="title"/> <xsl:variable name="firstWord" select="substring($booktitle,1,3)"/> <xsl:choose> <xsl:when test="$firstWord = 'XML'"> XML Book: <xsl:value-of select="$booktitle"/> </xsl:when> </xsl:choose> …. </xsl:stylesheet>
59
Named Templates <?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" <!-- Named templates--> <xsl:variable name="someVar select="catalog/product"/> <xsl:template match="catalog/book"> <xsl:call-template name="show"> <xsl:with-param name = "someVar" select="'book/title'"/> </xsl:call-template> </xsl:template> <xsl:template name="show"> <xsl:param name="someVar"/> <xsl:value-of select="concat('Hi',$someVar)"/> </xsl:stylesheet>
60
Catalog.xml <?xml version="1.0"?> <catalog> <book>
<title language="English">Fun With XML</title> <author>John Robot</author> <isbn>12367</isbn> <price>70</price> </book> language="English">Xml and Java</title> <author>Mary Jones</author> <isbn>7856</isbn> <price>34</price>
61
Controlling which nodes to process push model
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:template match = “catalog"> <html><body> <xsl:apply-templates/> </body></html> </xsl:template> <xsl:template match=“book”> <xsl:template match=“author|title|price”> <xsl:value-of select=“.”/> </xsl:stylesheet>
62
Controlling which nodes to process pull model
<xsl:template match=“book”> <xsl:apply-templates select=“author”> <xsl:apply-templates select=“title”> <xsl:apply-templates select=“price”> </xsl:template> </xsl:stylesheet>
63
Pull model <xsl:template match=“book”>
<xsl:value-of select=“author”> <xsl:value-of select=“title”> <xsl:value-of select=“price”> </xsl:template> </xsl:stylesheet>
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.