Formatting code for XDMSerializeUseCase2
======XDM Serialization Use Case 2======
=====Exchange of XDM data between XDM Tools from different vendors in the same environment=====
An XDM Producer (for example XPath 2.0) outputs XDM data that it would like to exchange with an XDM Consumer (for example XQuery) which is running in the same environment but the XDM Tools are from different vendors. This likely means that the in-memory representations (e.g. in Java the Class or Interface objects) are not the same and may not have wrappers to convert them from Vendor A's XDM representation to Vendor B's represetnation.
If Vendor A and Vendor B agree on a standard text serialization format then data may still be interchanged.
===Actors===
==XDM Producer==
Vendor A implementation of an XPath 2.0 processor
Example, an xpath that returns a sequence of nodes
%%
/foo/bar
%%
==XDM Consumer==
Vendor B implementation of an XQuery processor which expects a sequence of nodes as an external variable
Example
%%
declare variable $list as element(bar)* external ;
%%
===Expected Use===
To pass the results from Vendor A's XDM Producer to the Vendor B's XDM Consumer within the same (or different) environment, a text serialization is produced by the XDM Producer and the resulting byte stream is reconstituted using the API of Vendor B's implementation of the XDM Consumer.
Simplified example of a Java API passing results through serialization using a hypethetical VendorA and VendorB implementations of XPath and XQuery.
%%
// Vendor A's XPath
VendorA.XdmValue result = VendorA.Xpath.execute("/foo/bar");
byte[] serialized = result.serialize();
// Vendor B's XQuery
VendorB.XdmValue value = VendorB.XdmValue.deserialize( serialized );
VendorB.XQuery xquery = new VendorB.XQuery( "declare variable $list as element(bar)* external ; ... ") ;
xquery.setParameter( "list" , value );
xquery.execute();
%%
----
[[XDMSerialize]]
=====Exchange of XDM data between XDM Tools from different vendors in the same environment=====
An XDM Producer (for example XPath 2.0) outputs XDM data that it would like to exchange with an XDM Consumer (for example XQuery) which is running in the same environment but the XDM Tools are from different vendors. This likely means that the in-memory representations (e.g. in Java the Class or Interface objects) are not the same and may not have wrappers to convert them from Vendor A's XDM representation to Vendor B's represetnation.
If Vendor A and Vendor B agree on a standard text serialization format then data may still be interchanged.
===Actors===
==XDM Producer==
Vendor A implementation of an XPath 2.0 processor
Example, an xpath that returns a sequence of nodes
%%
/foo/bar
%%
==XDM Consumer==
Vendor B implementation of an XQuery processor which expects a sequence of nodes as an external variable
Example
%%
declare variable $list as element(bar)* external ;
%%
===Expected Use===
To pass the results from Vendor A's XDM Producer to the Vendor B's XDM Consumer within the same (or different) environment, a text serialization is produced by the XDM Producer and the resulting byte stream is reconstituted using the API of Vendor B's implementation of the XDM Consumer.
Simplified example of a Java API passing results through serialization using a hypethetical VendorA and VendorB implementations of XPath and XQuery.
%%
// Vendor A's XPath
VendorA.XdmValue result = VendorA.Xpath.execute("/foo/bar");
byte[] serialized = result.serialize();
// Vendor B's XQuery
VendorB.XdmValue value = VendorB.XdmValue.deserialize( serialized );
VendorB.XQuery xquery = new VendorB.XQuery( "declare variable $list as element(bar)* external ; ... ") ;
xquery.setParameter( "list" , value );
xquery.execute();
%%
----
[[XDMSerialize]]