Quickest way to parse a DomSource

Monday, 22 July 2019 · 3 messages
ML
Marco Lettere22 Jul 2019 11:32 #
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.
MH
Martin Honnen22 Jul 2019 12:53 #
Quoted text · Marco Lettere · 13 lines
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(javax.xml.namespace.QName,%20javax.xml.transform.Source,%20javax.xml.xquery.XQItemType) 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.
ML
Marco Lettere22 Jul 2019 14:43 #
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.
Quoted text · Martin Honnen · 25 lines
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(javax.xml.namespace.QName,%20javax.xml.transform.Source,%20javax.xml.xquery.XQItemType) > > > 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. > > >

⚡Generated with XQuery