Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filter by Current Date
Message
From
23/06/2007 22:01:52
 
 
To
All
General information
Forum:
Internet
Category:
XLST
Title:
Filter by Current Date
Miscellaneous
Thread ID:
01235223
Message ID:
01235223
Views:
55
I have an XML document and style sheet like below. What I want to do is to filter the xml so that if the "Expire" date is less than the current date it is not processed by the style sheet and thus not included in the HTML produced. How do I do this?
<?xml version="1.0" standalone="yes"?>
<PICNews>
  <xsd:schema id="VFPData" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:element name="VFPData" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="news" minOccurs="0" maxOccurs="unbounded">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="Date" type="xsd:date"/>
                <xsd:element name="Expires" type="xsd:date"/>
                <xsd:element name="Author">
                  <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                    </xsd:restriction>
                  </xsd:simpleType>
                </xsd:element>
                <xsd:element name="Type">
                  <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                    </xsd:restriction>
                  </xsd:simpleType>
                </xsd:element>
                <xsd:element name="Text">
                  <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                    </xsd:restriction>
                  </xsd:simpleType>
                </xsd:element>
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
        <xsd:anyAttribute namespace="http://www.w3.org/XML/1998/namespace" processContents="lax"/>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>

  <news>
    <Date>6/21/2007</Date>
    <Expires>6/30/2007</Expires>
    <Author>Dan Jurden</Author>
    <Type>Memo</Type>
    <Text>This is a memo.</Text>
  </news>
  <news>
    <Date>6/21/2007</Date>
    <Expires>6/30/2007</Expires>
    <Author>Dan Jurden</Author>
    <Type>News</Type>
    <Text>This is some news.</Text>
  </news>
  <news>
    <Date>6/22/2007</Date>
    <Expires>6/23/2007</Expires>
    <Author>Dan Jurden</Author>
    <Type>Alert</Type>
    <Text>This is an alert.</Text>
  </news>
</PICNews>
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ddwrt2="urn:frontpage:internal">
  <xsl:template match="/">
    <h2>PIC Information</h2>
    <table width="100%">
      <xsl:for-each select="PICNews/news">
      <xsl:sort select="Date" order="descending" />
      <tr>
        <xsl:if test="Type = 'Memo'">
          <td width="32px"><img src="images/memo.jpg" width="32px" /></td>
        </xsl:if>
        <xsl:if test="Type = 'News'">
          <td width="32px"><img src="images/news.jpg" width="32px" /></td>
        <xsl:if>
        <xsl:if test="Type = 'Alert'">
          <td width="32px"><img src="images/alert.jpg" width="32px" /></td>
        </xsl:if>
        <td>Date: <xsl:value-of select="Date"/></td>
      </tr>
      <tr>
        <td colspan="2"><span class="news-text"><xsl:value-of disable-output-escaping="yes" select="Text" /></span></td>
      </tr>
      <tr>
        <td colspan="2"><br/></td>
      </tr>
    </xsl:for-each>
    </table>
  </xsl:template>
</xsl:stylesheet>
Thanks,
Dan Jurden
djurden@outlook.com
Reply
Map
View

Click here to load this message in the networking platform