CIS 451: XSL Dr. Ralph Westfall February, 2009
Problems With XML no formatting capabilities contra formatting tags like, etc. in HTML CSS can be used but not an ideal solution very limited logic and selection capabilities to get parts of content can use JavaScript (see slsrcpt.html and slsrcpt2.html) but it's slow because it's not specialized for XMLslsrcpt.html slsrcpt2.html
What Is XSL? eXtensible Stylesheet Language a language for formatting XML output works somewhat like CSS formats HTML XSL = "CSS for XML" works with Internet Explorer, FireFox, etc.
XSL Has Three Components XSLT for transforming XML documents XPath for navigating XML documents XS-FO for formatting XML documents
What Is XSLT? XSL Transformations most important component of XSL W3C has made 1.0 version a formal standard (2.0 pending) transforms XML documents into HTML documents, other XML documents, etc. uses XPath to navigate XML documents can be used without other XSL components
With XSLT You Can … can add or remove XML elements from an output file element = [some data] rearrange and/or sort elements can use code logic to decide which to add, remove, rearrange, etc.
Original File: books.xml Beginning UML Dr. Stumpf
Formatting With books.xsl <xsl:stylesheet version="1.0" xmlns:xsl="
XSL Syntax first 3 lines of.xsl file are required overhead use exactly the same spacing and capitalizations <xsl:stylesheet version="1.0" xmlns:xsl="
XSL Syntax - 2 match attribute of xsl template element tells how much of.xml file to include match="/" means start with root element (gets whole.xml file) there is a syntax for other match values to get specific (combinations of) data
XSL Syntax - 3 XSLT file can contain HTML code bulleted list tags below get their contents from data for title and author in xml file
XSL Syntax - 4 xsl value-of element can use its select operator to pull contents of an XML tag into the HTML page gets contents of following title element Beginning UML
XSL Syntax - 5 xsl for-each operator is like a for… each loop in VB.NET pulls contents of a set of tags into output retrieves all titles and authors in textbooks sub-elements of books element
Exercise work through some of the items in the W3Schools XSLT TutorialXSLT Tutorial XSLT Templates XSLT Element XSLT Element XSLT Element XSLT Element XSLT Element XSLT Element XSLT Templates XSLT Element
Exercise try W3Schools XML ExamplesXML Examples XML and XSL are toward bottom of screen note use of HTML div and span tags to implement CSS formats note that some examples have an Edit the text and click me button often the last item under a heading e.g., XML Parser: Loading same file into HTML
References much of the content of this PowerPoint was derived from W3Schools XML TutorialXML Tutorial also see XSLT Elements Reference by W3SchoolsXSLT Elements Reference