ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> exslt
exslt
[exslt] Error in date:format-date EXSLT template?
by Greg Cymbala other posts by this author
Mar 18 2006 3:49PM messages near this date
[exslt] URIs Module | [exslt] str:split
& XSLT I've been using the date:format-date XSLT template (date.format-date.template.xsl) fo
r some time now, but just recently tried using it with some single-quoted literals in it.  I
 found that if there was only one single-quoted literal, it did fine, but if there were mult
iple literals, it failed, seeming to lump them all together as one long literal.
 
for example: 
 
EEEE dd' of 'MMMM' of 'yyyy
or
yyyy'$BG/(J'M'$B7n(J'd'$BF|(J'
 
would return something like "Wednesday 22 of MMMM of 2006" or "2006$BG/(JM$B7n(Jd$BF|(
J".
 
After about a day of trying to figure it out, I think I traced it back to changing a "2" to 
a "3" in this parameter:
 
<xsl:with-param name="pattern" select="substring($pattern, string-length($literal-value) + 3
)" /> 
 
near the bottom of this xsl:when in the <xsl:template name="date:_format-date">  template:
 
<xsl:when test='$char = "&apos;"'> 
 <xsl:choose> 
  <xsl:when test='substring($pattern, 2, 1) = "&apos;"'> 
   <xsl:text> &apos;</xsl:text>
   <xsl:call-template name="date:_format-date"> 
    <xsl:with-param name="year" select="$year" /> 
    <xsl:with-param name="month" select="$month" /> 
    <xsl:with-param name="day" select="$day" /> 
    <xsl:with-param name="hour" select="$hour" /> 
    <xsl:with-param name="minute" select="$minute" /> 
    <xsl:with-param name="second" select="$second" /> 
    <xsl:with-param name="timezone" select="$timezone" /> 
    <xsl:with-param name="pattern" select="substring($pattern, 3)" /> 
   </xsl:call-template> 
  </xsl:when> 
  <xsl:otherwise> 
   <xsl:variable name="literal-value" select='substring-before(substring($pattern, 2), "&apo
s;")' /> 
   <xsl:value-of select="$literal-value" /> 
   <!--<br /> [char=&quot;<xsl:value-of select="$char"/>&quot;]<br />
      <br /> [$pattern=&quot;<xsl:value-of select="$pattern"/>&quot;]<br />-->
   <xsl:call-template name="date:_format-date"> 
    <xsl:with-param name="year" select="$year" /> 
    <xsl:with-param name="month" select="$month" /> 
    <xsl:with-param name="day" select="$day" /> 
    <xsl:with-param name="hour" select="$hour" /> 
    <xsl:with-param name="minute" select="$minute" /> 
    <xsl:with-param name="second" select="$second" /> 
    <xsl:with-param name="timezone" select="$timezone" /> 
    <xsl:with-param name="pattern" select="substring($pattern, string-length($literal-value)
 + 3)" /> 
   </xsl:call-template> 
  </xsl:otherwise> 
 </xsl:choose> 
</xsl:when> 
 
I've not tested this extensively, pretty much just with the examples I gave above, plus a fe
w variations on them.  I hope that you can add this change in to help others from getting as
 frustrated as I was with this little glitch.
 
Greg Cymbala

The information in this electronic mail message is sender's 
business Confidential and may be legally privileged.  It is 
intended solely for the addressee(s).  Access to this Internet 
electronic mail message by anyone else is unauthorized.  If 
you are not the intended recipient, any disclosure, copying, 
distribution or any action taken or omitted to be taken in 
reliance on it is prohibited and may be unlawful. The sender 
believes that this E-mail and any attachments were free of 
any virus, worm, Trojan horse, and/or malicious code when 
sent. This message and its attachments could have been 
infected during  transmission. By reading the message and 
opening any attachments, the recipient accepts full 
responsibility for taking protective and remedial action about 
viruses and other defects. Cendant is not liable for any loss 
or damage arising in any way from this message or its 
attachments.
Attachments:
unknown1
unknown2
unknown3
unknown4


Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved