[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: system call?

Subject: Re: system call?
From: TGolshan@xxxxxxxxxxxx
Date: Mon, 19 Sep 2005 11:24:54 -0700
xsl if test this year
Thanks Jay! This is exactly what I was looking for. -troy



JBryant@xxxxxxxxx 
09/19/2005 11:06 AM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
Re:  system call?






I have a comment and an idea:

<xsl:variable name="year">
        <xsl:value-of select="article/fm/hdr/hdr2/pdt/yr"/>
</xsl:variable>

can be just

<xsl:variable name="year" elect="article/fm/hdr/hdr2/pdt/yr"/>

Also, I strongly suspect that you need / in front of that select string.

Now for the idea:

If you use an XSLT 2.0 processor (such as Saxon 8), you can get the 
current year as follows:

<xsl:variable name="thisyear" select="format-date(current-date(), 
'[Y0001]')"/>

Then you can use

<xsl:if test="$year = $thisyear">

The FAQ has information about getting the current date in XSLT 1.0:
http://www.dpawson.co.uk/xsl/sect2/dates.html

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)




TGolshan@xxxxxxxxxxxx 
09/19/2005 12:30 PM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
 system call?






I am trying to disable URL links from legacy files. I am not sure how to 
do this without hard-coding the $year to the current year, 2005. Any 
better ideas? I have heard that one might be able to do a system call, but 


that completely escaped me. 

Thanks in advance,
troy

**************************

XML file
<hdr2>
        <obi>
                <volno></volno>
                        <issno></issno>
        </obi>
        <pdt>
                <mo></mo>
                        <yr>2005</yr>
        </pdt>
        <pp</pp>
</hdr2>

<p><url>URL TEXT HERE</url></p>
 

Code
<xsl:variable name="year">
        <xsl:value-of select="article/fm/hdr/hdr2/pdt/yr"/>
</xsl:variable>

<xsl:template match="url">
                <xsl:if test="$year='2005'">
                        <a>
                                <xsl:choose>
                                        <xsl:when test="
substring(text(),1,5)='http:'">
                                                <xsl:attribute name="href
"><xsl:value-of select="text()"/></xsl:attribute>
                                        </xsl:when>
                                        <xsl:when test="
substring(text(),1,4)='ftp:'">
                                                <xsl:attribute name="href
"><xsl:value-of select="text()"/></xsl:attribute>
                                        </xsl:when>
                                        <xsl:otherwise>
                                                <xsl:attribute name="href
"><xsl:value-of select="concat('http://',text())"/></xsl:attribute>
                                        </xsl:otherwise>
                                </xsl:choose>
                                        <xsl:attribute name="target">blank
</xsl:attribute>
                                                <xsl:apply-templates/>
                        </a>
                </xsl:if> 
                <xsl:if test="$year!='2005'">
                        <xsl:apply-templates/>
                </xsl:if>
        </xsl:template>

Current Thread
  • system call?
    • TGolshan - 19 Sep 2005 17:32:13 -0000
      • JBryant - 19 Sep 2005 17:59:41 -0000
        • TGolshan - 19 Sep 2005 18:25:14 -0000 <=
        • Michael Kay - 20 Sep 2005 04:34:35 -0000
      • <Possible follow-ups>
      • cknell - 19 Sep 2005 17:42:51 -0000

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.