1 / 26

XSL-2

XSL-2. COSC643 Internet Supply-Chain Management Sungchul Hong. Last Class. DTD XSL Template <xsl:value-of <xsl:apply-templates>. Today. More XSL List elements. Passing the Node for Further Processing. <?xml version="1.0"?>

dima
Download Presentation

XSL-2

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. XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong

  2. Last Class • DTD • XSL • Template • <xsl:value-of • <xsl:apply-templates>

  3. Today • More XSL • List elements

  4. Passing the Node for Further Processing • <?xml version="1.0"?> • <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> • <xsl:template match="*"> • <xsl:apply-templates /> • </xsl:template> • <xsl:template match="text()"> • <DIV style="border: solid 1px"> • <xsl:value-of select="." /> • </DIV> • </xsl:template> • <xsl:template match="/"> • <div style="border: solid 3px; padding: 10px;"> • <xsl:apply-templates /> • </div> • </xsl:template> • </xsl:stylesheet>

  5. Getting Specific • <?xml version="1.0"?> • <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> • <xsl:template match="/"> • <xsl:apply-templates /> • </xsl:template> • <xsl:template match="*"> • <xsl:apply-templates /> • </xsl:template> • <xsl:template match="text()"> • <xsl:apply-templates /> • </xsl:template> • <xsl:template match="vendor_name"> • <p><xsl:value-of select="." /></p> • </xsl:template> • </xsl:stylesheet>

  6. <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="*"> <xsl:apply-templates /> </xsl:template> <xsl:template match="text()"> <xsl:apply-templates /> </xsl:template> <xsl:template match="product"> <ul><li> <xsl:value-of select="product_id" />: <xsl:value-of select="short_desc" /> </li></ul> </xsl:template> <xsl:template match="vendor_name"> <p><xsl:value-of select="." /></p> </xsl:template> </xsl:stylesheet>

  7. <xsl:template match="product"> <ul><li> <xsl:apply-templates select="product_id" /> <xsl:value-of select="short_desc" /> </li></ul> </xsl:template> <xsl:template match="product/product_id"> <xsl:value-of select="." />: </xsl:template> <xsl:template match="vendor_name"> <p><xsl:value-of select="." /></p> </xsl:template>

  8. <xsl:template match="product"> <ul><li> <xsl:apply-templates select="product_id" /> <xsl:value-of select="short_desc" /> <br /><xsl:apply-templates select="inventory[@color]"/> </li></ul> </xsl:template> <xsl:template match="inventory[@color]"> -- <xsl:value-of select="@color" /> <br/> </xsl:template> <xsl:template match="product/product_id"> <xsl:value-of select="." />: </xsl:template> <xsl:template match="vendor_name"> <p><xsl:value-of select="." /></p> </xsl:template> Displaying Attributes

  9. Checking for a Specific Attribute Values • <xsl:template match=“inventory[@color and @location=‘warehouse’]”>

  10. <xsl:template match="product"> <ul><li> <xsl:apply-templates select="product_id" /> <xsl:value-of select="short_desc" /> <br /><xsl:apply-templates select="inventory[@color]"/> </li></ul> </xsl:template> <xsl:template match="inventory[@color and @location='warehouse']"> -- <xsl:value-of select="@color" /> <br/> </xsl:template>

  11. Adding Sales Prices <xsl:template match="product"> <ul><li> <xsl:apply-templates select="product_id" /> <xsl:value-of select="short_desc" /> <br /><xsl:apply-templates select="inventory[@color]"/> <p><xsl:value-of select="price[@pricetype='sale']"/></p> </li></ul> </xsl:template> <xsl:template match="inventory[@color and @location='warehouse']"> -- <xsl:value-of select="@color" /> <br/> </xsl:template>

  12. Using the Pipe Notation for “or” <xsl:template match="product"> <ul><li> <xsl:apply-templates select="product_id" /> <xsl:value-of select="short_desc" /> <br /><xsl:apply-templates select="inventory[@color]"/> <p><xsl:value-of select="price[@pricetype='sale'] | price[@pricetype != 'cost']"/></p> </li></ul> </xsl:template>

  13. Looking for Descendants Instead of Children <xsl:template match="product"> <ul><li> <xsl:apply-templates select="product_id" /> <xsl:value-of select="short_desc" /> <br /><xsl:apply-templates select="inventory[@color]"/> <p><xsl:value-of select=“.//price[@pricetype='sale'] | .//price[@pricetype != 'cost']"/></p> </li></ul> </xsl:template>

  14. Looking for Retail Prices <xsl:template match="product"> <ul><li> <xsl:apply-templates select="product_id" /> <xsl:value-of select="short_desc" /> <br /><xsl:apply-templates select="inventory[@color]"/> <p><xsl:value-of select="price[@pricetype='sale'] | price[@pricetype = ‘retail']"/></p> </li></ul> </xsl:template>

  15. Looping <xsl:template match="/"> <xsl:for-each select="//vendor"> <h2><xsl:value-of select="vendor_name"/></h2> </xsl:for-each> <hr/> <xsl:apply-templates /> </xsl:template>

  16. Adding Elements • <xsl:template match="/"> • <xsl:for-each select="//vendor" > • <!-- <xsl:sort select="vendor_name" /> --> • <xsl:element name="a"> • <xsl:attribute name="href"> • #<xsl:value-of select="vendor_name" /> • </xsl:attribute> • <h2><xsl:value-of select="vendor_name" /></h2> • </xsl:element> • </xsl:for-each> • <hr/> • <xsl:apply-templates /> • </xsl:template>

  17. Conditionals • <xsl:template match="/"> • <xsl:for-each select="//vendor" > • <xsl:sort select="vendor_name" /> • <xsl:if test="@webvendor != 'no'"> • <xsl:element name="a"> • <xsl:attribute name="href"> • #<xsl:value-of select="vendor_name" /> • </xsl:attribute> • <h2><xsl:value-of select="vendor_name" /></h2> • </xsl:element> • </xsl:if> • </xsl:for-each>

  18. Conditionals (2) • <hr/> • <!-- <xsl:apply-templates /> --> • <xsl:for-each select="//vendor" > • <xsl:sort select="vendor_name" /> • <xsl:if test="@webvendor != 'no'"> • <xsl:apply-templates /> • </xsl:if> • </xsl:for-each> • </xsl:template>

  19. Choose • <xsl:template match="/"> • <xsl:for-each select="//vendor" > • <xsl:sort select="vendor_name" /> • <xsl:choose> • <xsl:when test="@webvendor != 'no'"> • <xsl:element name="a"> • <xsl:attribute name="href"> • #<xsl:value-of select="vendor_name" /> • </xsl:attribute> • <h2><xsl:value-of select="vendor_name" /></h2> • </xsl:element> • </xsl:when> • <xsl:otherwise> • <h2><xsl:value-of select="vendor_name" />*</h2> • </xsl:otherwise> • </xsl:choose> • </xsl:for-each>

  20. Choose • <sup>*</sup>Products available only in showrooms. • <hr/> • <!-- <xsl:apply-templates /> --> • <xsl:for-each select="//vendor" > • <xsl:sort select="vendor_name" /> • <xsl:if test="@webvendor != 'no'"> • <xsl:apply-templates /> • </xsl:if> • </xsl:for-each> • </xsl:template>

More Related