1 / 13

Introduction BCi

XSLT. Introduction BCi. MC 365 – Software Engineering. Presented by: John Ristuccia Shawn Posts Ndi Sampson. Title: EE and DC. What can BCi Do?. Background. What is XSLT? XSLT stands for Extensible Stylesheet Language Transformations

erol
Download Presentation

Introduction BCi

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 Introduction BCi MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson

  2. Title: EE and DC What can BCi Do? Background • What is XSLT? • XSLT stands for Extensible Stylesheet Language Transformations • XSLT is designed for use as part of XSL, which is a stylesheet language for XML. • What is XML and why does it need XSL • Extensible Markup Language is a set of semantic rules designed to break up a document into hierarchical and easily identifiable parts. • XML Has three important features…

  3. Title: EE and DC What can BCi Do? Background Continued • XML is a meta-markup language • Instead of having a specified set of tags to draw from, you define your own as you need them; allowing for immense versatility and Domain-specific markup languages. • XML Follows a Strict hierarchical structure. • Every well-formed XML document is a tree; having a root, children, and leaves. Nodes can be elements, text, attributes, comments, processing instructions, or namespaces. • XML contains only structural and semantic info • XML documents contain no formatting information – hence XSL/XSLT.

  4. What can BCi Do? Title: EE and DC Background Continued • To Reiterate • XSL (Extensible Stylesheet Language)provides a language for adding formatting and structure to an XML document. The process of XSL Transformation basically takes in one XML document and transforms it into a different XML document (usually but not always a well-formed HTML document viewable by a web browser)

  5. What can BCi Do? Title: EE and DC Advantages and Disadvantages • Advantages • Easy to merge data into XML data into a presentation • More resilient to change in the details of the XML document than in the low-level DOM (Document Object Model) and SAX (Simple API for XML) • Database inquiries can be returned in XML • Insensitive to column order • Disadvantages • Memory intensive and suffers a performance penalty • Difficult to implement complicated business rules • Have to learn a new language • Can’t change the value of variables (requires recursion)

  6. Title: EE and DC What can BCi Do? XSL Transformations • Use • X-Path to identify (select) parts of an XML document • XSLT Templates to apply transformations • Requires • Well formed XML document • XSL document (stylesheet) that contains formatting and transformation templates • XSLT parser to perform the transformations

  7. Title: EE and DC What can BCi Do? Steps for Translating a Document • Tell a system which parser to use • Establish a factory in which to create transformations • Create a transformer for a particular style sheet • Invoke the transformer to process the document

  8. Who can use BCi? Title: EE and DC XSLT Example <- XML <- XSL XSLT -> Another example

  9. Title: EE and DC What can BCi Do? XSLT Stylesheet Elements • Matching and Selecting Templates • xsl:template • xsl:apply-template • xsl:value-of • Branching Elements • xsl:for-each • xsl:if • xsl:choose

  10. Title: EE and DC What can BCi Do? Example of xsl:if • xsl:if test = “expression” • Evaluate the expression to a boolean and if true, applies the template body • XSLT has not else if construct (use choose) • <xsl:template match = “ROW”> • <!-- select first node in the node set --> • <xsl:if test= “position() = first()”> • <xsl:value of select = “.” /> • </xsl:if> • </xsl:template> • <xsl:template match= “ROW”> • <!– Select if current node has children --> • <xsl:if test = “node()”> • <xsl:apply-templates/> • </xsl:if> • </xsl:template>

  11. Requirements? Title: EE and DC Some Simple XSLT • Copying: • xsl:copy, copies the current node • xsl:apply-templates, processes the children of the current node • ex. <xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> • <xsl:template match="title"> • <xsl:copy> • <xsl:apply-templates/> • </xsl:copy> • </xsl:template> • </xsl:stylesheet> • xsl:copy-of element, can copy the entire subtree of each node that the template selects • ex. <xsl:template match="title“> • <xsl:copy-of select="*"/> • </xsl:template>

  12. Potential Problems? Some More Simple XSLT • Deleting: • <xsl:template match="nickname"> • </xsl:template> • <xsl:template match="project[@status='canceled']"> </xsl:template> • While a match value of "project" would delete all the project elements from the output, the match value shown will only delete project elements whose status attributes have the string "canceled" as their value.

  13. Some More Simple XSLT • Changing Element Names: • ex. • <xsl:template match="article"> • <html> • <xsl:apply-templates/> • </html> • </xsl:template> • This template rule tells an XSLT processor to take any “article” element fed to it as input, and output its contents surrounded by html tags

More Related