xsl-2 cosc643 internet supply-chain management sungchul hong
TRANSCRIPT
![Page 1: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/1.jpg)
XSL-2
COSC643
Internet Supply-Chain Management
Sungchul Hong
![Page 2: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/2.jpg)
Last Class
• DTD
• XSL– Template– <xsl:value-of– <xsl:apply-templates>
![Page 3: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/3.jpg)
Today
• More XSL– List elements
![Page 4: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/4.jpg)
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>
![Page 5: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/5.jpg)
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>
![Page 6: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/6.jpg)
<?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>
![Page 7: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/7.jpg)
![Page 8: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/8.jpg)
<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>
![Page 9: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/9.jpg)
![Page 10: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/10.jpg)
Displaying Attributes<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>
![Page 11: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/11.jpg)
![Page 12: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/12.jpg)
Checking for a Specific Attribute Values
• <xsl:template match=“inventory[@color and @location=‘warehouse’]”>
![Page 13: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/13.jpg)
<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>
![Page 14: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/14.jpg)
![Page 15: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/15.jpg)
<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>
Adding Sales Prices
![Page 16: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/16.jpg)
![Page 17: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/17.jpg)
<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>
Using the Pipe Notation for “or”
![Page 18: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/18.jpg)
![Page 19: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/19.jpg)
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>
![Page 20: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/20.jpg)
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>
![Page 21: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/21.jpg)
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>
![Page 22: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/22.jpg)
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>
![Page 23: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/23.jpg)
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>••
![Page 24: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/24.jpg)
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>
![Page 25: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/25.jpg)
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>
![Page 26: XSL-2 COSC643 Internet Supply-Chain Management Sungchul Hong](https://reader030.vdocument.in/reader030/viewer/2022032701/56649c7e5503460f94933759/html5/thumbnails/26.jpg)
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>