Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
 A peek into the world  of XSLT<br />Author<br />Neenu George<br />
“Style is what gives value and currency to thoughts.”<br />Arthur Schopenhauer (1788-1860) German philosopher.<br />“Style...
AGENDA<br /><ul><li>What is XSLT ?
Programming with XSLT
Example
Use of XSLT in Polaris Application
Conclusion
Q&A</li></li></ul><li>About XSLT<br />
What is XSLT?<br />XSL stands for EXtensibleStylesheet Language<br />Language for transforming XML documents<br />A progra...
XSLT in Motion<br />
Why transform?<br /><ul><li>Convert one schema to another
I say potato, you say paragraph
Rearrange data for formatting</li></li></ul><li>Programming with XSLT<br />
Correct Style Sheet Declaration<br />The root element that declares the document to be an XSL style sheet is <xsl:styleshe...
<xsl:template name="myTemplateName"><br />     ...body of template...<br />     </xsl:template><br />set of rules that are...
used to extract the value of a selected node.<br /><xsl:value-of> element can be used to extract the value of an XML eleme...
element allows you to do looping in XSLT<br /><xsl:for-each> element can be used to select every XML element of a specifie...
XSLT <xsl:sort> Element<br /><xsl:sort> element is used to sort the output.<br />To sort the output, simply add an <xsl:so...
XSLT <xsl:if> Element<br /><xsl:if> element is used to put a conditional test against the content of the XML file<br />tes...
XSLT <xsl:choose> Element<br />The <xsl:choose> element is used in conjunction with <xsl:when> and <xsl:otherwise> to expr...
XPath and its use in XSLT<br /><ul><li>An expression language over XML trees
Used to identify sets of elements
Upcoming SlideShare
Loading in …5
×

Xslt tutorial

2,799 views

Published on

Published in: Technology
  • Be the first to comment

Xslt tutorial

  1. 1. A peek into the world of XSLT<br />Author<br />Neenu George<br />
  2. 2. “Style is what gives value and currency to thoughts.”<br />Arthur Schopenhauer (1788-1860) German philosopher.<br />“Style is a simple way of saying complicated things”<br /> Jean Cocteau (1889-1963) French author and filmmaker.<br />“The proper words in the proper places are the true definition of style.”<br />Jonathan Swift (1667-1745) Irish-born English satirist.<br />
  3. 3. AGENDA<br /><ul><li>What is XSLT ?
  4. 4. Programming with XSLT
  5. 5. Example
  6. 6. Use of XSLT in Polaris Application
  7. 7. Conclusion
  8. 8. Q&A</li></li></ul><li>About XSLT<br />
  9. 9. What is XSLT?<br />XSL stands for EXtensibleStylesheet Language<br />Language for transforming XML documents<br />A programming language for XML documents<br />A functional language, based on value substitution<br />Augmented with pattern matching<br />And also template substitution to construct output (based on namespaces<br />Uses XML syntax<br />
  10. 10. XSLT in Motion<br />
  11. 11. Why transform?<br /><ul><li>Convert one schema to another
  12. 12. I say potato, you say paragraph
  13. 13. Rearrange data for formatting</li></li></ul><li>Programming with XSLT<br />
  14. 14. Correct Style Sheet Declaration<br />The root element that declares the document to be an XSL style sheet is <xsl:stylesheet> or <xsl:transform><br />W3C XSLT Recommendation is:<br /> <xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><br />
  15. 15. <xsl:template name="myTemplateName"><br /> ...body of template...<br /> </xsl:template><br />set of rules that are called templates<br />A template contains rules to apply when a specified node is matched.<br />Acts as functions in java<br /><xsl:call-template name="myTemplateName"/><br />XSLT <xsl:template> Element<br />
  16. 16. used to extract the value of a selected node.<br /><xsl:value-of> element can be used to extract the value of an XML element and add it to the output stream of the transformation<br /><xsl:value-of select="XPath expression"/><br />selects the contents of an element and adds it to the output stream <br />XSLT <xsl:value-of> Element<br />
  17. 17. element allows you to do looping in XSLT<br /><xsl:for-each> element can be used to select every XML element of a specified node-set<br /><xsl:for-each select="XPath expression"> <br />XSLT <xsl:foreach> Elements<br />
  18. 18. XSLT <xsl:sort> Element<br /><xsl:sort> element is used to sort the output.<br />To sort the output, simply add an <xsl:sort> element inside the <xsl:for-each> element in the XSL file:<br />xsl:sort select="author"/><br />
  19. 19. XSLT <xsl:if> Element<br /><xsl:if> element is used to put a conditional test against the content of the XML file<br />test against the content of the XML file, add an <xsl:if> element to the XSL document.<br /><xsl:if test="expression">  <!-- Content: template --></xsl:if><br />
  20. 20. XSLT <xsl:choose> Element<br />The <xsl:choose> element is used in conjunction with <xsl:when> and <xsl:otherwise> to express multiple conditional tests.<br /><xsl:choose>  <xsl:when test="expression">    ... some output ...  </xsl:when>  <xsl:otherwise>    ... some output ....  </xsl:otherwise></xsl:choose><br />
  21. 21. XPath and its use in XSLT<br /><ul><li>An expression language over XML trees
  22. 22. Used to identify sets of elements
  23. 23. “all paragraphs”
  24. 24. “all paragraphs directly inside footnotes”
  25. 25. “the section with ID=“sec37”
  26. 26. “footnotes with author=‘Knuth’”
  27. 27. “first paragraph in each section”
  28. 28. “the parent of each caption”
  29. 29. Then you can say what to do with them…</li></li></ul><li>What’s inside an XSLT transform?<br /><ul><li>Any number of “templates”
  30. 30. A template uses Xpath to match nodes
  31. 31. Highest priority matching template selected
  32. 32. Then the remplate takes over and generates:
  33. 33. Literal output XML (based on namespace)
  34. 34. Computational results (of XSLT functions)
  35. 35. Results of further template applications
  36. 36. Results of queries on the document
  37. 37. Many options</li></li></ul><li>Code Examples<br />
  38. 38. Conclusion<br />
  39. 39. Strategies for XSLT<br />Try to pick a single style as much as possible<br />May vary by project<br />Mixing may be necessary but can get confusing<br />Be sure you understand (and probably override the default rules)<br />Shorter patterns are better<br /><xsl:value-of> and <xsl:if> may be easier to deal with than a complex path<br />
  40. 40. References<br />Key siteshttp://www.w3.org/Style/XSL http://www.mulberrytech.com/xsl/xsl-list http://www.oasis-open.org/cover/xsl.html <br />Interactive XSLT reference http://www.zvon.org/xxl/XSLTreference/Output/<br />XSLT: 2nd Edition Programmer’s Reference Michael Kay [Good reference; clear, but not really a tutorial] <br />XSLT & XPath On the EdgeTennison [And her other books]<br />

×