Quickest way to parse a DomSource
Hi all, I'm currently working on the usage of BaseX Xquery scripts inside a BPMN engine. I have to access portions of the XML representation of the BPMN file by binding the engine's API. The closest that I can get to a standard XML representation is currently a javax.xml.transform.dom.DOMSource. What is the shortest way to transform (in XQuery) this DomSource to a BaseX representation of the Document in order to query it? Thanks, Marco.
Am 22.07.2019 um 11:32 schrieb Marco Lettere:
I have to access portions of the XML representation of the BPMN file by binding the engine's API.
The closest that I can get to a standard XML representation is currently a javax.xml.transform.dom.DOMSource.
What is the shortest way to transform (in XQuery) this DomSource to a BaseX representation of the Document in order to query it?
The XQJ API seems to have a method http://xqj.net/javadoc/javax/xml/xquery/XQDynamicContext.html#bindDocument(j...) to allow passing in a java.xml.transform.Source so that seems at least one way to deal with a DOMSource. But it happens on the Java side and is tied to that particular XQJ API.
Thank you Martin. It's worth experimenting.... In the meanwhile (thanks to my colleague who had a closer look at the DOMSource API) I got to understand that there's a getNode() method returning the underlying DOM Node. This allows for minimizing the module import statements. Thus, fyi, at the moment this is my work-around: (: Import DOMSource API:) declare namespace source = "javax.xml.transform.dom.DOMSource"; (:... code to get to the custom Document representation stored in a variable called $document... :) (: get the DOMSource through custom API:) let $source := bpmndom:getDomSource($document) (:DOMSource API to get underlying Document Node :) let $doc := source:getNode($source) (:Now this Xpath expression works :) return $doc//*:userTask Cheers, Marco. On 22/07/19 12:53, Martin Honnen wrote:
Am 22.07.2019 um 11:32 schrieb Marco Lettere:
I have to access portions of the XML representation of the BPMN file by binding the engine's API.
The closest that I can get to a standard XML representation is currently a javax.xml.transform.dom.DOMSource.
What is the shortest way to transform (in XQuery) this DomSource to a BaseX representation of the Document in order to query it?
The XQJ API seems to have a method
http://xqj.net/javadoc/javax/xml/xquery/XQDynamicContext.html#bindDocument(j...)
to allow passing in a java.xml.transform.Source so that seems at least one way to deal with a DOMSource. But it happens on the Java side and is tied to that particular XQJ API.
participants (2)
-
Marco Lettere -
Martin Honnen