Re: [xsl] How to do macro substitution in XPath?

Subject: Re: [xsl] How to do macro substitution in XPath?
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 2 Dec 2023 22:31:13 -0000
On Sat, 2023-12-02 at 15:36 +0000, Roger L Costello costello@xxxxxxxxx
> Hi Folks,
> I am converting prose like this:
> If the title = "Path to Power" and the author = "Robert A. Caro"
> (Lyndon Baines Johnson (LBJ)), then
> process LBJ as follows
> B B B  action 1
> If the title = "Power Broker" and the author = "Robert A. Caro"
> (Robert Moses (RM)), then
> process RM as follows
> B B B  action 2
> Neither LBJ nor RM
> B B B  action 3

Overall, ibd start (as you may have started) by asking some

1. who is generating this prose? Are they people who know XPath? Could
a form-filling approach work for them instead?

2. How often does the prose change? How much is there?

3. Is a manual conversion sufficient or must it be automated?

Depending on the answers, i might go for a small document,
maybe something like,

    <author>Robert Al. Caro</author>
    <title>Path to Power</title>
      <p>Donald Trump really enjoyed this book.</p>

Ibd then write XSLT to process that file.

Doing this means someone can't put XPath syntax errors or malicious
code into the pipeline, and is probably safer to edit.

The next level of complexity might be to make an XSLT 3 file that
defines a map, and parse that, maybe with the built-in json support.

Whether these approaches might work depends on the context in which
this prose is used, of course, which wasn't in your question.


Liam Quin,B
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B

Current Thread