Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error XPST0003:Unexpected token "{" when using p:xquery step with XQuery inline code with embedded expression #300

Closed
martin-honnen opened this issue Feb 25, 2020 · 3 comments

Comments

@martin-honnen
Copy link

When I run the code

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step name="test1"
    xmlns:p="http://www.w3.org/ns/xproc"
    xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0"
    xpath-version="2.0">
    <p:input port="source"/>
    <p:output port="result"/>
    <p:xquery>
        <p:input port="query">
            <p:inline>
                <c:query><result>{document-uri(.)}</result></c:query>
            </p:inline>
        </p:input>
        <p:input port="parameters">
            <p:empty/>
        </p:input>
    </p:xquery>
</p:declare-step>

with Calabash 1.1.30-99 against any input source it gives the following error:

ERROR: file:/C:/SomePath/test-document-uri3.xpl:1:0:XPST0003:Unexpected token "{" at start of expression
ERROR: Unexpected token "{" at start of expression
ERROR: cause: file:/C:/SomePath/test-document-uri3.xpl:1:0:XPST0003:Unexpected token "{" at start of expression
ERROR: Pipeline failed: Unexpected token "{" at start of expression
ERROR: Underlying exception: Unexpected token "{" at start of expression

MorganaXProc 1.0.15 runs that code fine.

@ndw
Copy link
Owner

ndw commented Feb 25, 2020

It appears to me that the query you're trying to run is

{document-uri(.)}

Which I wouldn't expect to succeed. The curly braces do indeed look unexpected to me.

Does it work if you take the curly braces out?

(I can't explain why this works in MorganaXProc, but I'll ask Achim.)

@martin-honnen
Copy link
Author

The query I am trying to run is

<result>{document-uri(.)}</result>

and this is what MorganaXProc executes, i.e. a literal result element named result with an embedded expression {document-uri(.)}, then returning e.g.

<result>file:///C:/SomePath/input.xml</result>

It seems I struggle to understand to understand how to embed XQuery code literally in the c:query element, although judging by the difference in the implementations it seems there is a different way the implementors handle that.

If I take the curly braces out I get <result>document-uri(.)</result> from MorganaXProc and test-document-uri4.xpl:8:15:p:xquery returned atomic value from Calabash.

I will need to have a closer look at the XProc 1 spec and p:xquery and c:query details in there.

@martin-honnen
Copy link
Author

OK, I think I overlooked "text" in "the text descendants" of the c:query description. So I need to wrap my XQuery code in a CDATA section <c:query><![CDATA[<result>{document-uri(.)}</result>]]></c:query>.

My bad, seems if there is an issue then with MorganaXProc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants