Hi Marco,

this one is not too obvious, yet:

the type of $body is „document-node()“ not element, so what I think happens is the following:

validate:xsd-info($body…
receives a document-node() and somehow* BaseX passes a documents string representation to validate:xsd-info(), which happens the be the documents base-uri(), hence: "`tmp/basex/POST.xml` could not be found".


I am not 100% sure my explanation is correct, yet you could solve your problem by passing the element child of that document-node to the validate function, as follows: 

declare
  %rest:path("/testxsd")
  %rest:POST("{$body}")
  %rest:consumes("application/xml")
function page:testxsd($body as document-node()){
    validate:xsd-report(
    $body/element(),
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a"/></xs:schema>)
};

See this gist for my experiments:

https://gist.github.com/micheee/025ffed4fbb06bc4b4200ab959755e3b


Hope this helps
Michael

* -> somehow means: most probably specified by rules I do not know of ;-)

Am 13.05.2016 um 09:57 schrieb Marco Lettere <m.lettere@gmail.com>:

Dear all,
this question triggers a dejavu in my head and I'm pretty sure this has been discussed some time ago so I'm not sure why it strikes back at us ...
With the latest snapshot (but with 8.4.4 it's the same) downloaded just few minutes ago I start the basehttp server.
Then I add the foolowing RestXQ to the restxq.xqm file:

declare
 %rest:path("/testxsd")
 %rest:POST("{$body}")
 %rest:consumes("application/xml")
function page:testxsd($body){
 validate:xsd-info($body, "xsd.xsd")
};

I store the following dummy xsd as xsd.xsd in the webapp folder:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="a"/>

</xs:schema>


I invoke the restxq with:

curl -vd "<a/>"  http://localhost:5000/testxsd -H "Content-type:application/xml"

Getting back the following error:

Error 400 Stopped at /tmp/basex/webapp/restxq.xqm, 12/20:
[bxerr:BXVA0002] Validation could not be started: Resource "/tmp/basex/POST.xml (No such file or directory)" not found.</title>

This happens no matter what xml and what xsd is used. If I change $body with <a/> in the call to validate:xsd-info everything works smoothly ...
Any ideas?
Thanks,
Marco.


--
Michael Seiferle, BaseX GmbH, http://www.basexgmbh.de
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
|   Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Fon: +49 7531 916 82 77