I'm trying to use xquery from within WS02/Synapse/Axis2. I've developed a mediator that appears to work correctly up to the point that it invokes the following xquery. This fails as follows:


net.sf.saxon.javax.xml.xquery.XQException: XQuery syntax error in #...ple,dc=technica,dc=com") let $#:

    Prefix ldap has not been declared

at net.sf.saxon.xqj.SaxonXQConnection.prepareExpression(SaxonXQConnection.java:131)

at net.sf.saxon.xqj.SaxonXQConnection.prepareExpression(SaxonXQConnection.java:117)

at com.technica.pbac.pdp.PbacPDP.mediate(PbacPDP.java:189)


These instructions at http://saxon.sourceforge.net/saxon7.9.1/using-xquery.html seem to be incorrect; shouldn't the namespace be quoted?


The Saxon XQuery implementation allows you to call Java methods as external functions. The function does not need to be declared. Use a namespace declaration such as declare namespace math=java:java.lang.Math, and invoke the method as math:sqrt(2).


Here's the xquery script


xquery version "1.0";

declare copy-namespaces no-preserve, inherit;

declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/";

declare namespace wsa="http://www.w3.org/2005/08/addressing";

declare namespace m0="http://services.samples";

declare namespace os="urn:oasis:names:tc:xacml:2.0:context:schema:os";

declare namespace ldap="java:com.technica.ldap.query.LdapQuery";

declare default element namespace"urn:oasis:names:tc:xacml:2.0:context:schema:os";

declare variable $doc as document-node(element(*, xs:untyped)) external; 


let $subject := $doc/soapenv:Envelope/soapenv:Body/m0:getQuote/m0:request/m0:symbol/text()

let $ldap := ldap:getAttributeValue("ldap://localhost:389/uid={$subject},ou=People,dc=technica,dc=com")


And the extension function I'm trying to invoke:


package com.technica.ldap.query;

public class LdapQuery

{

public static String getAttributeValue(org.apache.xalan.extensions.XSLProcessorContext context, String attributeName) 

throws NamingException

{

...omitted...

}

}


Would it be possible to provide instructions specific to xquery without reference to XSLT? Its quite confusing as it stands.