<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(., '&#xfeff;')">
        <!--<p:text-replace pattern="&#xfeff;" 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 03:40:05 UTC