1 / 12

XSLT, XML Schema, and XPath

XSLT, XML Schema, and XPath. Matt McClelland. Introduction. XML Schema Defines the content and structure of XML data. XSLT Used to transform XML documents into other XML documents or text-based formats such as HTML and PDF. XPath

coy
Download Presentation

XSLT, XML Schema, and XPath

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XSLT, XML Schema, and XPath Matt McClelland

  2. Introduction • XML Schema • Defines the content and structure of XML data. • XSLT • Used to transform XML documents into other XML documents or text-based formats such as HTML and PDF. • XPath • Used as a way to locate and tag “items” or nodes in an XML document.

  3. XML Schema • What is an XML Schema? • XML Schema documents are used to define and validate the content and structure of XML Data. • Primarily used to separate content from formatting

  4. XML Schema (cont.) • Follows Strict Hierarchical Structure • Every well-formed XML Schema document (.xsd) follows a tree-like structure • Contains root, child, and leaf nodes/tags • Restricts documents to a fixed vocabulary and validates documents to ensure they follow the rules of the dialect • Contains only Structural/Semantic Data • XML Documents contain NO formatting information..

  5. XSLT • What is XSLT? • XSLT stands for eXtensible Stylesheet Language Transformations. • Used in conjunction with XSL Stylesheets and XPath to render and style XML and other text-based documents.

  6. XSLT (cont.) Advantages Disadvantages • Clean, concise templates • Relatively fast • Provides an easy, platform neutral way to render XML into HTML, PDF, and other XML docs • Stylesheets may become difficult to maintain, especially if left unkempt • Not easily readable or understandable at a glance • Not supported by all web crawlers or older internet browsers

  7. XPath • What is XPath? • XPath is a query language often used in conjunction with XSLT for selecting nodes from an XML document. • Addresses ‘parts’ of an XML document and provides basic facilities for computing and manipulating strings, numbers, and booleans from the content of an XML document.

  8. XPath (cont.) • How does it work? • XPath uses a compact, string-based, rather than XML element-based syntax. • Operates on the abstract, logical structure of an XML document (tree of nodes) rather than its surface syntax. • Uses a path notation (much like URLs) to navigate through the XML’s hierarchical tree structure.

  9. SpecifyXSL Stylesheet Sample XML

  10. XSL version XPath XSLT Example classical.xsl <xsl:stylesheetxmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <HTML> <HEAD><TITLE>Authors</TITLE></HEAD> <BODY> <H1>Composers from Austria</H1> <TABLE BORDER="1"><TR><TH>Name</TH></TR> <xsl:for-each select="/authors/author[nationality='Austrian']"> <TR><TD><xsl:value-ofselect="name" /></TD></TR> </xsl:for-each> </TABLE> </BODY> </HTML> </xsl:template> </xsl:stylesheet>

  11. Output Original XML Transformed XML

  12. Questions?

More Related