David:
Maybe do it in Python
Me:
C++, which is what I use most of the time (XSL is infrequent
Just so's you know, my mention of C++ and XSL actually means that's all I use -
I think. (C# is on the horizon, and I once wrote something in Java, though
that was because I couldn't find a MIB reading library for C++, else I'd have
done that)
I don't use Python at all, so that really isn't an option.
So - if it's XML it'll be XSL to process it.
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
richard(_dot_)kerry(_at_)atos(_dot_)net<https://webmail.siemens-it-solutions.com/owa/redir.aspx?C=9fb20d019e3e4cb99344d708709a3177&URL=mailto%3arichard.kerry%40atos.net>
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: David Farmer farmer(_at_)aimath(_dot_)org
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: 03 March 2020 15:46
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
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.
Maybe do it in Python with the "lxml" module?
On Tue, 3 Mar 2020, Kerry, Richard richard(_dot_)kerry(_at_)atos(_dot_)net
wrote:
Ok,
Thanks all for the explanations. I'll look at the alternatives.
If this was C++, which is what I use most of the time (XSL is infrequent,
just when I want to manipulate some XML) I would
use some kind of polymorphism to achieve this. I'd define a couple of
one-line functions with the different variables, or
calls, and pass the appropriate one to the outer function so they could be
run on its results (somewhat garbled,
abbreviated explanation, sorry). I'm not aware of anything in XSL that looks
like polymorphism, but I would be interested
to know if there was a construct that might be similar, or usable for cases
like this one.
Granted I can't construct variable names dynamically, but I can have a number
of variables existing simultaneously and
select one and pass it around by address if I need to. I don't see an
analogous construct in XSL, except to use
choose/when to select a line of code based on an actual variable.
I could send my examples if that would be best, but I think that would
provide a lot of unnecessary code just to show a
small bit of context.
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.
Blue line
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
richard(_dot_)kerry(_at_)atos(_dot_)net
--~----------------------------------------------------------------
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
--~--