2. XPath
• expressions that can be used to find specific pieces of information
within an XML document.
• Used by XPointer and XSLT.
• It locate nodes based on the nodes’ type, name, or value or by the
relationship of the nodes to other nodes within the XML document.
• It returns:
• A node set
• A Boolean value
• A string value
• A numeric value
7. Node test
• indicates the type of node desired for the results.
• list of these node tests:
• comment()
• node()
• processing-instruction()
• text()
8. Predicate
• filters a node set on the specified axis to create a new node set.
• Forward / reverse axis predicate.
13. XPointers
• describes a location within an external document.
• can target a point within that XML document or a range within the
target XML document.
• XPointer provides two more important node tests:
• point()
• range()
14. • Functions that return location set: id(), root(), here(), origin().
• Points: node point & character points.
• Range functions: end-point(), range-inside(), range-to(), start-point().
16. XLink
• allowing a link to another document to be specified on any element
within an XML document.
• creates a link to another resource through the use of attributes
specified on elements, not through the actual elements themselves.
19. Types of link
• Simple links:
• consists of an xlink:type attribute with a value of simple and, optionally, an
xlink:href attribute with a specified value.
• acts as a resourceXLink type for the local document.
• They link exactly two resources together: one local and one remote.
• Extended links:
• to specify relationships between an unlimited number of resources, both local
and remote.
21. XSLT for document Publishing
• Use XSL to convert XML into HTML,PDF,…
• For WAP, convert XML to WML
22. Book.xml
<?xml version=”1.0”?>
<?xml-stylesheet type=”text/xsl” href=”book_view.xsl”?>
<book>
<author>Michael Daconta et al</author>
<title>XML Development with Java 2</title>
<category>Java</category>
<price currency=”USD”>44.99</price>
<summary>
XML Development with Java 2 provides the information
and techniques a Java developer will need to integrate
XML into Java-based applications.
</summary>
</book>
27. ASP: Server-Side XSLT Processing
• The required components:
• Microsoft IIS Web Server 5.0
• Microsoft XML Parser 3.0.
• Two options for publishing the source code on the IIS server:
• Copy the files in <install_dir>ch9_xslpublic_html to c:Inetpubwwwroot.
• Set up a virtual directory that points to <install_dir>ch9_xslpublic_html
29. JSP: Server-Side XSLT Processing
• The required components:
• Sun Microsystems’ Software Development Kit (SDK) 1.3 (or higher)
• Apache Tomcat Server 4.
• <install_dir>ch9_xslpublic_htmlbook_test.jsp:
<%@ taglib uri=”http://jakarta.apache.org/taglibs/xsl-1.0”
prefix=”jakarta” %>
<jakarta:apply xml=”book.xml” xsl=”book_view.xsl” />
30. Advanced Features of XSLT
• Looping
• Sorting
• Sorting: ascending/descending
• Sorting by case
• Sorting with multiple keys
• Conditionals
• Filters
34. Ascending/descending
<!-- Sort by the book title, descending -->
<xsl:for-each select=”booklist/book”>
<xsl:sort select=”title” order=”descending”/>
<!-- insert table rows and table data -->
</xsl:for-each>
46. Generating a PDF Document
Steps to generate a PDF document from simple.fo:
1. Open an MS-DOS window.
2. Move to the directory <install_dir>ch9_xslxsl_fo.
3. Set up the Java classpath by typing setpaths.
4. Execute Apache-FOP by typing fop simple.fo simple.pdf. The Apache-
FOP formatter now reads the input file simple.foand generates the
output file simple.pdf.
5. View the simple.pdffile in Adobe Acrobat Reader.