[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to do macro substitution in XPath?

Subject: Re: 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
Re:  How to do macro substitution in XPath?
On Sat, 2023-12-02 at 15:36 +0000, Roger L Costello costello@xxxxxxxxx
wrote:
> 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
questions...

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,

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

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

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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.