">
Xsl 2
This presentation is the property of its rightful owner.
Sponsored Links
1 / 26

XSL-2 PowerPoint PPT Presentation


  • 79 Views
  • Uploaded on
  • Presentation posted in: General

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"?>

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Xsl 2

XSL-2

COSC643

Internet Supply-Chain Management

Sungchul Hong


Last class

Last Class

  • DTD

  • XSL

    • Template

    • <xsl:value-of

    • <xsl:apply-templates>


Today

Today

  • More XSL

    • List elements


Passing the node for further processing

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>


Getting specific

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>


Xsl 2

<?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>


Xsl 2

<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>


Xsl 2

<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


Checking for a specific attribute values

Checking for a Specific Attribute Values

  • <xsl:template match=“inventory[@color and @location=‘warehouse’]”>


Xsl 2

<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>


Xsl 2

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>


Xsl 2

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>


Looking for descendants instead of children

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>


Looking for retail prices

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>


Looping

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>


Adding elements

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>


Conditionals

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>


Conditionals 2

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>


Choose

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>


Choose1

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>


  • Login