XSLT - Saxon malformed URL unknown protocol: xmldb - xslt-2.0

In eXist 4.4/XQuery 3.1 I perform an XSL 2.0 transformation using transform:transform(). In the transformation I pass a parameter into the XSL transformation for Saxon to use to access information in the database.
<param name="paramSaxondatapath" value="xmldb:exist:///db/apps/deheresi/data/"/>
Everything works great: Saxon retrieves the nodes needed from documents in eXist-DB and the XSL transformation is successful.
Now, I am trying to do execute the same but from outside the eXist-DB environment (local drive, using Oxygen). Thus, in the XSLT document I have hardcoded the parameter:
<xsl:param name="paramSaxondatapath">xmldb:exist:///db/apps/deheresi/data/</xsl:param>
Yet when I fire this XSLT file off locally (in Oxygen, local XSLT file, Saxon-HE 9.6.0.7), Saxon throws me an exception unknown protocol: xmldb
FODC0002: Exception thrown by URIResolver:
Malformed URL
xmldb:exist:///db/apps/deheresi/data/bibliography.xml
(base file:/Users/foo/Desktop/De_Heresi/deheresi_TEI/fo_dep_single.xsl):
unknown protocol: xmldb
Considering that this is passed to Saxon in identical manner (ie wrapped in doc(concat(paramSaxondatapath,'somefile.xml')), I'm surprised this isn't reacting the same way both times.
Is there a different URI I should be using?
Many thanks.
EDIT: Curiously, if I use command line for the transformation (ie not triggered by Oxygen), Saxon accepts it and performs the transformation. It appears to have something to do with Oxygen...

My guess is that when eXist invokes Saxon, it sets a URIResolver that recognizes URIs with the "xmldb:exist:" prefix and handles them itself. Outside the eXist environment, you would need to supply your own URIResolver that does something similar - connects to the database and retrieves the required document.

Related

Query failed with dynamic error: Cannot serialize a map using this output method

This has to be a noob issue, as I'm just starting with XQuery. I was successfully able to build a simple XQuery for eXist that runs an XSL transform. But I have been unsuccessful in building a similar XQuery for Saxon (9.9.1.5J) that runs an XSL transform.
Working XQuery for eXist:
xquery version "3.0";
transform:transform(doc("sample.xml"), doc("sample.xsl"), ())
Failing XQuery for Saxon:
xquery version "3.1";
transform(map{'source-node': doc('sample.xml'),'stylesheet-node':doc('sample.xsl')})
The error reported by Saxon is:
Query failed with dynamic error: Cannot serialize a map using this
output method
I've searched Google and SO for this error, but get nothing. I have tried it with and without the output declaration, and with and without an output declaration in the XSL. I've tried it with fn:transform() and transform(). I put in a declaration for the fn namespace too. The transform works from the Saxon command line and from eXist. So I must be missing something simple about the building of the map for the options to fn:transform().
The result of the fn:transform() function is a map, and it looks like you are running the query in a way where the query result gets serialized using the default XML output method. Trying to serialize a map using the XML output method will fail.
There are several things you could do, depending what exactly you want to achieve. The simplest fix might be to change the body of the query to
transform(map{'source-node': doc('sample.xml'),'stylesheet-node':doc('sample.xsl')})
? output
in which case the result will be the principal result document of the transformation, which is probably what you are most interested in.

How does sightly HTML files access global implicit objects in AEM 6

Unlike inclusion of global.jsp with every component jsp in CQ5, sightly does not include any such dependency. How does it actually access all the global objects. What is the backend process of it. And how sightly code compiles to java??
how sightly code compiles to java?
Sling sightly API has two bundles to support this, the first step is to compile sightly into Abstract Syntax Tree (The Abstract Syntax Tree maps plain Java source code in a tree form. This tree is more convenient and reliable to analyse and modify programmatically than text-based source.) This is done by Apache Sling Scripting Sightly Compiler
Next is to convert (transpile) the Abstract Syntax Tree into java source code. This is achieved in bundle Java Compiler
How does it actually access all the global objects.
To understand this you need to understand how script resolution occurs in Sling and how are resource resolved to scripts which is core to Sling Scripting engine. To understand basics of ScriptEngine look at java docs here, implementation of this is SightlyScriptEngine
The way script resolution works is that the resource is adapted to DefaultSlingScript , this is done by SlingScriptAdapterFactory.
SlingScriptAdapterFactory has references to BindingsValuesProvider which is passed to the DefaultSlingScript. One of the implementation of BindingsValuesProvider is AEMSightlyBindingsValuesProvider (you can see this as a service in /system/console/services) which provides the default objects.
The DefaultSlingScript then responsible for invoking SightlyScriptEngine and calling its method eval which populates the default objects in binding and then setting this binding as request attribute.

Transform Multiple xml input source as stream to one xslt using saxon

I am new to saxon and xslt, we have business in which feeder delivere more than one xml files, xslt generated from altov) create one output xml files , we have selected saxon as transformer.
so far i am able to transform single xml file
do any body have example where xslt takes more than one xmls as input stream, transform using saxon.
Thanks & regards,
Kumar
You haven't told us enough about the requirements, but there are several techniques to be aware of:
You can pass additional documents as stylesheet parameters declared using xsl:param
You can read a document (given its URI) using the doc() or document() functions
You can read a whole collection of documents (e.g. the contents of a directory) using the collection() function

Iterating over DOM Objects being returned by Java methods in XSLT

We have been using Xalan for XSL transformations for quite a while and recently moved over to Saxon for XSL transformation Version 1.0 (Backward Compatibility mode). I am calling a Java Method from XSL which returns a document object and iterating over the document object for further transformations . The transformations are proper in case of Xalan whereas I am unable to achieve the same in case of Saxon. Please let me know how to achieve the same while working with Saxon XSLT parser.
You have raised the same question in a direct support request to Saxonica and we are trying to help you via that channel.

NullPointerException in saxon IdentityTransformer.transform when extracting data from javax DOMSource

I am using Spring Webservice (2.1.0) Client to send a very simple Message to a Soap UI Mock Webservice. (Hello World style, no namespaces)
Before Sending the DOMSource via the SpringWebserviceTemplate it is extracted from
a jdom2.Element as jdom2.transform.JDOMSource. (JDOM 2.0.2)
The Transformer is Saxon 9.4.0.4.
While calling the Spring Webservice Template function sendSourceAndReceiveToResult
the net.sf.saxon.IdentityTransformer throws a NullPointerException when executing
the transform(DOMSource,responseResult) function.
Since DOMSource is available at that point I do not know what could have gone wrong.
Stacktrace tells me the Nullpointer was thrown at:
net.sf.saxon.lib.SerializerFactory.getReceiver (line 239).
It would help me greatly if you could speculate on possible causes.
Please note that the best way of reporting a Saxon problem is to use either the Saxon forums at http://saxonica.plan.io, or the saxon-help mailing list on SourceForge. We try to monitor questions on StackOverflow, but it's often a few days before we notice them.
With this kind of problem, the cause is often that some piece of software (like Spring Webservice) is using the JAXP TransformerFactory mechanism to load whatever XSLT transformer it finds on the classpath, but hasn't actually done the testing to ensure that it works with an arbitrary XSLT transformer; people often test only with the default one provided by the JDK. It's not clear from your question whether you actually intended for it to use Saxon or not.
Line 239 of SerializerFactory is actually doing
throw new IllegalArgumentException("Unknown type of result: " + result.getClass());
(having tested whether result is one of the kinds of Result that it recognizes); so it looks to me as if result (which is probably the value passed to the transform() method) is null. Check the contents of your responseResult value.

Resources