1 / 34

High-Tech Entrepreneurship Networking Event

Join CTI students and alumni to explore the possibilities of using IT skills to start your own company. Learn about DePaul's New Venture Competition and find teammates. Refreshments served.

simoni
Download Presentation

High-Tech Entrepreneurship Networking Event

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 I Robin Burke ECT 360

  2. Outline • XSLT processing • XSLT syntax • XPath • XSLT basics • Lab

  3. Admin • Announcement • Milestone #4

  4. Friday, October 21 5-7pm, CTI Collaboration Lab, Free Surf to www.depaulcti.com for more information high-techentrepreneurshipnetworking event Have you ever thought of using your IT skills to start your own company? Join other CTI students and alumni in exploring the possibilities. e, CTI’s new high-tech entrepreneurship club invites you to an open house to mingle, network, and learn. We will present info on DePaul’s New Venture (business plan) Competition, with $5,000 in prizes – and help you find teammates. Refreshments served.

  5. XML • XSL • "family" of standards • XSL-FO • formatting objects • typesetting • document = a set of geometric areas organized on pages • XSLT • transformations • XPath • supports both • a language for addressing individual XML nodes

  6. XSL-FO Example

  7. XSLT HTML example

  8. XSLT syntax • XML document • stylesheet • root element • templates • "rule-based" processing

  9. XSLT Processing • Let L be a list of nodes • Let T be a list of templates • style (L, T) = • Find a template t matching L • Instantiate t using L • May call style (L', T) • Return instantiated template • To process a document • style ( { root }, T )

  10. Special purpose • XSLT is not a general-purpose programming language • lacks many conventional facilities • technically a "tree-rewriting" language • XSLT 2.0 • is more general purpose

  11. Example <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <html> <head> <title>Jeep suppliers</title> </head> <body>The first one is <xsl:value-of select="/child::entries/child::entry[position() = 1]/child::address/child::name/child::text()" /></body> </html> </xsl:template> </xsl:stylesheet>

  12. Note • stylesheet element • output type element

  13. Running example • value-of1

  14. XPath • XPath expression "/child::entries/child::entry[position() = 1]/child::address/child::name/child::text()" • How to read • "/" = root and delimiter for steps • axis::step = a move in the XML document • :: = "that is" or "that are" • [] = apply some predicate • position () = compute the position of this element in its list of siblings • text() = the element content • Result is a set of nodes

  15. Axes • self • this node • child • immediate descendant • descendant • any descendant • attribute • attribute list • following • siblings to the right • preceding • siblings to the left

  16. Steps • Depends on axis • element name • attribute name • can be associated with a predicate • foo[attribute::bar='5'] • entry[position() = 2]

  17. XPath shortcuts • Axes can be abbreviated • default = child • @ = attribute • // = descendant • . = self • .. = parent • Steps • text() can be omitted • [position() = n] can be [n] • Abbreviated version "/child::entries/child::entry[1]/child::address/child::name/child::text()" "/entries/entry[1]/address/name"

  18. Example • with simplified syntax

  19. XML Document

  20. Paths • All "name" elements? • All advertisers? • All non-advertisers? • The rating of the second entry? • All advertisers with a rating above 3? • The second line of every address?

  21. For-each • May want to operate on all nodes in a set • for-each element • instantiates contents once for every node in set

  22. Example • listing just names

  23. Multiple templates • Typically a stylesheet will have multiple templates • Easier to read / debug • Templates often correspond to elements • More modular

  24. Templates • template element • match attribute • describes nodes that use the template • content • template to instantiate • apply-templates element • select attribute • what nodes to use • position shows where in the parent element the result is inserted

  25. Example

  26. Whitespace • XSLT automatically removes whitespace • this is often correct • when it isn't • use text element

  27. Path mismatch • Biggest source of errors • end path has no content • Check path • local path • template match • apply-template select • Match/select should overlap by one step

  28. Example • template choice

  29. Building an element <xsl:element name="a"> <xsl:attribute name="href">http:// <xsl:value-of select="." /> </xsl:attribute> <xsl:value-of select="." /> </xsl:element> Becomes <a href="http://foo.org/">foo.org</a>

  30. Alternate syntax <a href="http://{.}"> <xsl:value-of select="." /></a> Becomes <a href="http://foo.org/">foo.org</a>

  31. Sorting • We can sort node lists • after they are selected • before they are operated on • for-each • apply-templates • Embed sort element

  32. Sorting, cont'd <xsl:apply-templates select="some/path"> <xsl:sort select="whatever/@foo" /> </xsl:apply-templates> What does this do?

  33. Example • complex selection and sorting

  34. Break / Lab

More Related