xsl-list
[Top] [All Lists]

Re: [xsl] Xslt string Operation

2016-08-24 16:59:39
Hi,

this also returns the expected result in your sample.

replace($fileHref, '(^.*/)([^.]*)(.*$)', concat('$1', $outDir,
'/$2-Formatted$3'))

It might be better in terms of shorter or easier to read...

Heiko



So,
The params had default values and that is exactly the way i am expecting
the caller to send these params. With fwd slashes, with .xml as file name
extention and always windows file name.. that is kind of why i put the
value in the param to give an example.
What i did works, but wanted to know if there was a better way.
Dak.

On Aug 24, 2016 4:13 PM, "Michael Kay mike(_at_)saxonica(_dot_)com" <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Actually, you want OutFileName to be a function of fileHref and outDir,
and you are asking us to work out what that function does from one
example
of its input and output. To do this properly we need to know what the
possible range of values of fileHref and outDir is: for example, is
fileHref always a Windows filename using forwards slashes to separate
the
parts of the path? Will it always end in ".xml"? Or since it's a param,
might someone pass in a filename using backslashes, with no file
extension?

I would encourage you to use URIs rather than filenames. You could then
use the resolve-uri() function for at least part of the task.

Michael Kay
Saxonica

On 24 Aug 2016, at 17:16, Mailing Lists Mail daktapaal(_at_)gmail(_dot_)com <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Dear all,
I have the following two params
<xsl:param name = â??fileHrefâ?? select = â??
â??P:/developers/perf/bigPayload.xmlâ??
â??/>
<xsl:param name="outDir" select="'outDir'"/>

  I want OutFileName to be : â??P:/developers/perf/outDir/
bigPayload-Formatted.xmlâ??

Is there a better way to do this than what I did?
<xsl:variable name="OutFileName" select=" substring-before($fileHref,
tokenize($fileHref,'/')[last() -1 ] ) || $outDir || '/' ||
substring-before( tokenize($fileHref,'/')[last()] ,'.xml') ||
'-Formatted.xml'"/>

thanks.
Dt
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://-list/293509> (by email)


XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <-list/1311928> (by
email <>)


--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>