Re: [xsl] How do I pass the mode as a string?

Subject: Re: [xsl] How do I pass the mode as a string?
From: "Kerry, Richard richard.kerry@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 3 Mar 2020 16:20:41 -0000
Ok, that's a possibility then.
If I understand it you mean I could do the search/filter as a completely
separate action, storing the resultant list of files as a variable, then pass
the list of files variable to apply-template.
I might try that.

Richard Kerry
BNCS Engineer, SI SOL Telco & Media Vertical Practice
M: +44 (0)7812 325518
2nd Floor, MidCity Place, 71 High Holborn, London, WC1V 6EA

This e-mail and the documents attached are confidential and intended solely
for the addressee; it may also be privileged. If you receive this e-mail in
error, please notify the sender immediately and destroy it. As its integrity
cannot be secured on the Internet, the Atos group liability cannot be
triggered for the message content. Although the sender endeavours to maintain
a computer virus-free network, the sender does not warrant that this
transmission is virus-free and will not be liable for any damages resulting
from any virus transmitted.

From: Graydon graydon@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: 03 March 2020 15:54
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [xsl] How do I pass the mode as a string?

Caution! Atos External email. Do not open attachments or click links, unless
this email comes from a known sender and you know the content is safe.

On Tue, Mar 03, 2020 at 03:37:51PM -0000, Kerry, Richard
richard.kerry@xxxxxxxx scripsit:
> What I am actually trying to do is to get a number of XML files processed.
The files are in similar folders, called 'input' and 'output'.  The files'
names follow a couple of name patterns, acq_(\d{4}) and out_(\d{4}). There is
identical code to scan through the folders and identify the files I want to
process (and extract the numbers from the filenames).  They are then passed to
apply-templates with the different modes as mentioned.
> So the file scanning, while not especially complicated, is not entirely
trivial and I'd like to have it written just once.  And then, because the
contents of the files differs in structure, they are handled by different
templates, with different modes.

If you have a sequence of document nodes in a variable, $inputFiles,

<xsl:apply-templates mode="AsAppropriate"
select="$inputFiles[local:selectFunction(.)]" />

will let you filter $inputFiles on the basis of your locally
defined selectFunction returning true or false. (or some other
predicate; you might not even need to define a function,
could be all you need.)

You can do this sequentially in the main template with repeated
apply-templates using different select functions in the predicates.

At least with Saxon, this kind of pattern is reasonably efficient.

-- Graydon

Current Thread