- From: Piez, Wendell A. (Fed) <wendell.piez@nist.gov>
- Date: Wed, 22 Jan 2025 14:16:17 +0000
- To: David Birnbaum <djbpitt@gmail.com>, XProc Dev <xproc-dev@w3.org>
- Message-ID: <MN2PR09MB5817B84ED9A82F22F90CC688FFE12@MN2PR09MB5817.namprd09.prod.outlook.com>
Dear David,
On my system, it worked when I added content-type=”text/plain” (apologies for botched quotes, it’s a robot) to p:xquery/p:with-input/p:inline.
My best guess this is because unless it is given a hint, the XProc engine does not know it can see XQuery if it looks at the plain text value of an XML document (fragment), even just a text node. The content-type again forces it to be plain, not XML.
I am sure others can elucidate it better.
As for applying XPath to text, isn’t that what you are doing with p:text-replace?
Good start to the day ---
Wendell
From: David Birnbaum <djbpitt@gmail.com>
Sent: Tuesday, January 21, 2025 10:40 PM
To: XProc Dev <xproc-dev@w3.org>
Subject: <p:xquery> with inline query?
Dear XProc Dev,
I've been fumbling with trying to apply an XPath function to a plain-text input document as part of an XProc 3 pipeline and unable to tease an answer out of the documentation I can find. I'm using Morgana 1.4.8.
Perhaps the following is simply wrong-headed, but I thought of using a <p:xquery> step, along the lines of the following, which tests for a BOM on a plain-text document that was read on the main source port and removes the BOM if it is present. The following code is just what I tried most recently, and it doesn't work:
<p:if test="starts-with(., '')">
<!--<p:text-replace pattern="" replacement=""/>-->
<p:xquery>
<p:with-input port="query">
<p:inline>substring(.,2)</p:inline>
</p:with-input>
</p:xquery>
</p:if>
It raises XD0030 with the message "No proper query document found: substring(.,2)".
If I remove the <p:xquery> step and un-comment the <p:text-replace> one, it removes the BOM without error, but beyond BOM-disposal, I'd like to learn how to apply XPath functions that don't have specific XProc counterparts to plain-text documents. And I'd like the XPath expression to be inline, since it's small enough that the code is more legible if I spell it out in place as part of the step instead of reading an external XQuery document.
I'd be grateful if someone could please advise me about the following:
1. What would be a clean, idiomatic way of applying an arbitrary XPath function to a plain-text document as part of an XProc 3 pipeline?
2. Where in the spec or online tutorials or elsewhere should I have been able to find an answer to this question?
With thanks for any guidance,
David
Received on Wednesday, 22 January 2025 14:16:23 UTC