You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Peter C. Verhage" <pe...@zeelandnet.nl> on 2001/03/26 21:24:40 UTC

Is there also something like the above to get only the path, and not the
filename? I can extract the path of the above using the following XSLT code:

<xsl:param name="filename"/>

<xsl:template name="get-path">
  <xsl:param name="file"/>
  <xsl:param name="path"/>
  <xsl:choose>
    <xsl:when test="string-length($file) > 0 and contains($file, '/')">
      <xsl:call-template name="get-path">
        <xsl:with-param name="file" select="substring-after($file, '/')"/>
        <xsl:with-param name="path" select="concat($path,
substring-before($file, '/'), '/')"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$path"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:variable name="path">
  <xsl:call-template name="get-path">
    <xsl:with-param name="file" select="$filename"/>
    <xsl:with-param name="path"/>
  </xsl:call-template>
</xsl:variable>

But maybe there is a faster way in doing this (btw, this example only works
within a Unix like environment, because it uses the '/' instead of the '\').

Peter


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re:

Posted by "Peter C. Verhage" <pe...@zeelandnet.nl>.
----- Original Message -----
From: "flourish" <co...@dork.com>
To: <co...@xml.apache.org>
Sent: Monday, March 26, 2001 9:46 PM
Subject: Re: <xsl:param name="filename"/>


: You could do it much more simply with xsp using the file utility methods
: provided by xsp, if you can/are will to run this through xsp at some
point.

This will be used within an XSP taglib, but, I use the document function to
read a certain document, specified within some user's XML file relative to
the path of that XML file... so for example:

<mytaglib:config file="../file.xml"/>

I will read this like this in my taglib:

<xsl:variable name="file">
  <xsl:choose>
    <xsl:when test="starts-with(//mytaglib:config/@file, '/')">
      <xsl:value-of select="//mytaglib:config/@file"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="concat($path, //mytaglib:config/@file)"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<xsl:variable name="config" select="document($file)/config"/>

After this I can point to $config to get certain data from the configuration
file. Anyways, as you can see, to do this I can't switch to some java code
because I'm using it within XSL...

Peter


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re:

Posted by flourish <co...@dork.com>.
You could do it much more simply with xsp using the file utility methods
provided by xsp, if you can/are will to run this through xsp at some point.

----- Original Message -----
From: "Peter C. Verhage" <pe...@zeelandnet.nl>
To: <co...@xml.apache.org>
Sent: Monday, March 26, 2001 2:24 PM
Subject: <xsl:param name="filename"/>


> Is there also something like the above to get only the path, and not the
> filename? I can extract the path of the above using the following XSLT
code:
>
> <xsl:param name="filename"/>
>
> <xsl:template name="get-path">
>   <xsl:param name="file"/>
>   <xsl:param name="path"/>
>   <xsl:choose>
>     <xsl:when test="string-length($file) > 0 and contains($file, '/')">
>       <xsl:call-template name="get-path">
>         <xsl:with-param name="file" select="substring-after($file, '/')"/>
>         <xsl:with-param name="path" select="concat($path,
> substring-before($file, '/'), '/')"/>
>       </xsl:call-template>
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:value-of select="$path"/>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
>
> <xsl:variable name="path">
>   <xsl:call-template name="get-path">
>     <xsl:with-param name="file" select="$filename"/>
>     <xsl:with-param name="path"/>
>   </xsl:call-template>
> </xsl:variable>
>
> But maybe there is a faster way in doing this (btw, this example only
works
> within a Unix like environment, because it uses the '/' instead of the
'\').
>
> Peter
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>