xslt - XPATH error comparing dates -


i'm trying transformation compare dates using xpath

here sample of xml:

 <?xml version="1.0" encoding="utf-8"?><shop xmlns="http://www.dei.isep.ipp.pt/lprog"        xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"         xmlns:lprog="http://www.dei.isep.ipp.pt/lprog"         xsi:schemalocation="http://www.dei.isep.ipp.pt/lprog traxsd.xsd">                 <category nome="fish">                     <article id="1" nome="fish1">                                      <proddate>2018-10-02</proddate>                               </article>                       </category >     </shop> 

and here sample of xslt a

<?xml version="1.0" encoding="utf-8"?>  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0"                 xmlns:lprog="http://www.dei.isep.ipp.pt/lprog">     <xsl:output method="html"/>      <xsl:template match="/">         <html>             <head>                 <title>list of products out of time</title>             </head>             <body>                 <table border="1">                     <tr bgcolor="#9acd32">                         <th style="text-align:left">category</th>                     </tr>                                       <tr>                                   <td>                             <xsl:apply-templates select="//lprog:category/lprog:article"/>                                            </td>                          </tr>                 </table>             </body>         </html>     </xsl:template>       <xsl:template match="lprog:category/lprog:articleo">                 <xsl:value-of select="@nome"/>         <xsl:text>:</xsl:text>          <xsl:value-of select="lprog:proddate[xs:date(lprog:proddate) le xs:date('2016-06-03')]"/>       error here          <xsl:text disable-output-escaping="yes">             <p></p>            </xsl:text>            </xsl:template>  </xsl:stylesheet> 

**error in line ** lprog:proddate[xs:date(lprog:proddate) le xs:date('2016-06-03')]"/>

thank you!

first of all, if want use xs:date , le operator, need use xslt 2.0 processor. furthermore, of course stylesheet needs declare xmlns:xs="http://www.w3.org/2001/xmlschema" namespace.

i think want correct lprog:proddate[xs:date(lprog:proddate) le xs:date('2016-06-03')] lprog:proddate[xs:date(.) le xs:date('2016-06-03')] , match="lprog:category/lprog:articleo" match="lprog:category/lprog:article".

with xslt 1.0 processor can compare e.g. <xsl:value-of select="lprog:proddate[translate(., '-', '') &lt;= 20160603]"/>.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -