Re: XdmValue objects returned from applyTemplates()

Michael Kay <[email protected]> Sat, 7 Aug 2021 00:27:01 +0100
Newsgroups gmane.text.xml.saxon.help
Message-ID <[email protected]>
--===============0731438431931273460==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_E9D1592B-0854-4BFE-B63E-D67667D81576"


--Apple-Mail=_E9D1592B-0854-4BFE-B63E-D67667D81576
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

Can you remind me why you want to have more than one =
Processor/Configuration?

And if you do need to have multiple Configurations, is there any reason =
they can't share the same NamePool?

(Note, if you manage to get past Saxon's checks and use a node with the =
wrong NamePool, the likely consequence is that elements will satisfy =
NameTests in expressions and patterns that they shouldn't satisfy, and =
vice versa.)

Michael Kay
Saxonica

> On 6 Aug 2021, at 23:47, Alan Painter <[email protected]> wrote:
>=20
> It appears to me that, in my usages, there are three main categories =
of XdmValue "types" that one would see as a result of an XSLT =
transformation (either principal output or result-document output):
>=20
> a) Plain ol' XML
> b) Maps/Array/Atomics (or what I was calling "JSON-oriented")
> c) Maps/Arrays containing XML data
>=20
> So if I want to feed the XdmValue output from apply-templates() as the =
input selection to apply-templates() of a different processor, I'll need =
to (respectively)
>=20
> a) Use NamePoolConverter=20
> b) No conversion necessary
> c) Pretty substantial undertaking=20
>=20
> a) and b) seem to work using this converter:
> private static XdmValue convertXdmValueForXslt(final XdmValue =
toConvert, final Xslt30Transformer destinationXslt) throws =
XPathException {
>=20
>     if ( !(toConvert instanceof XdmNode) ) {
>         // not XML hence don't convert
>         return toConvert;
>     }
>=20
>     final RawDestination        rawDest  =3D new RawDestination();
>     final PipelineConfiguration pipe     =3D =
destinationXslt.getUnderlyingController().makePipelineConfiguration();
>     final Receiver              receiver =3D rawDest.getReceiver(pipe, =
null);
>=20
>     Sender.send((NodeInfo) toConvert.getUnderlyingValue(), receiver, =
new ParseOptions());
>=20
>     return rawDest.getXdmValue();
> }
> c) would require that substantial undertaking so I will think about =
that later as may not even be very useful
>=20
> I did try a test to see what errors that I would get by transforming =
maps containing XML.  To create this, I used the adaptive output method:
> <xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform =
<http://www.w3.org/1999/XSL/Transform>"
>   version=3D"3.0"
>   exclude-result-prefixes=3D"xsl">
>=20
>   <xsl:output method=3D"adaptive" indent=3D"yes"/>
>=20
>   <xsl:template match=3D".">
>       <xsl:map>
>           <xsl:map-entry key=3D"'anArray'" select=3D"array { 1, 2, =
3.14159, (), true(), 'anArray' }" />
>           <xsl:map-entry key=3D"'someXml'">
>             <here is=3D"some" >
>               <xml>data</xml>
>             </here>
>           </xsl:map-entry>
>           <xsl:map-entry key=3D"'anotherMap'">
>             <xsl:map-entry key=3D"'key1'" select=3D"'value1'" />
>             <xsl:map-entry key=3D"'key2'" select=3D"[ 10, 9, 8 ]" />
>           </xsl:map-entry>
>       </xsl:map>
>   </xsl:template>
> </xsl:stylesheet>
> I used the output of this transformation as the input to an identity =
transformation of a different processor:
> <xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform =
<http://www.w3.org/1999/XSL/Transform>"
>   version=3D"3.0"
>   exclude-result-prefixes=3D"xsl">
>=20
>   <xsl:output method=3D"adaptive" indent=3D"yes"/>
>=20
>   <xsl:template match=3D".">
>       <xsl:copy-of select=3D"." />
>   </xsl:template>
>=20
> </xsl:stylesheet>
> I didn't encounter any errors in the processing, although I understand =
that this doesn't mean that it would always work.
> So it does seem that for maps/arrays containing XML, the embedded XML =
configurations are not checked for compatibility with the processor's =
configuration.
> I do think that I'm getting somewhere.  Thanks again for your help.
> -alan
>=20
>=20
>=20
>=20
> On Thu, Aug 5, 2021 at 12:41 AM Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected] =
<mailto:mike-JkSD5nQpfvpWk0Htik3J/[email protected]>> wrote:
> Depends a bit what you mean by =E2=80=9CJSON-oriented=E2=80=9D. Maps =
and arrays can of course contain XDM nodes in their values (and I =
don=E2=80=99t think we always check that these belong to the right =
Configuration when supplied via external APIs, in the same way that we =
check for nodes). Writing code that converts a map-containing-nodes from =
one Configuration to a map-containing-equivalent-nodes from a different =
Configuration would be a pretty substantial undertaking.
>=20
> =20
>=20
> Sender.send() expects a Source object, and the JAXP Source interface =
is very XML-biased.
>=20
> =20
>=20
> Michael Kay
>=20
> Saxonica
>=20
> =20
>=20
> From: Alan Painter <mailto:[email protected]>
> Sent: 04 August 2021 22:33
> To: Mailing list for the SAXON XSLT and XQuery processor =
<mailto:[email protected]>
> Subject: Re: [saxon] XdmValue objects returned from applyTemplates()
>=20
> =20
>=20
> I see that I was too hasty in saying that it was "working" for me.
>=20
> =20
>=20
> I'd like the XdmValue to be any arbitrary Xdm with un-annotated XML, =
maps, arrays and atomics (no need for functions). =20
>=20
> But maps and and arrays cannot be cast to NodeInfo (or, at least, I'm =
getting an error when doing this).
>=20
> =20
>=20
> Would there be a way to send JSON-oriented XdmValue to Sender.send()? =20=

>=20
> (I'm thinking that a pure JSON XdmValue wouldn't need to have its =
NamePool converted, but what about a mix of XML and maps/arrays?)
>=20
> =20
>=20
> thanks again for any help
>=20
> =20
>=20
> =20
>=20
> =20
>=20
> On Wed, Aug 4, 2021 at 10:12 PM Alan Painter <[email protected] =
<mailto:[email protected]>> wrote:
>=20
> I'm finally getting around to implementing something w.r.t. the =
pointers that you gave me, Michael.
>=20
> =20
>=20
> My objective is to convert a given XdmValue so that it can become the =
input for a Xslt30Transformer with a different NamePool from the origin =
Xslt30Transformer.
>=20
> =20
>=20
> This seems to be working for me.  I'm curious if this is OK and if =
there isn't a shorter way.
>=20
> =20
>=20
> private XdmValue convertXdmValueForXslt(final XdmValue toConvert, =
final Xslt30Transformer destinationXslt) throws XPathException {
>     final RawDestination        rawDest  =3D new RawDestination();
>     final PipelineConfiguration pipe     =3D =
destinationXslt.getUnderlyingController().makePipelineConfiguration();
>     final Receiver              receiver =3D rawDest.getReceiver(pipe, =
null);
>=20
>     Sender.send((NodeInfo) toConvert.getUnderlyingValue(), receiver, =
new ParseOptions());
>=20
>     return rawDest.getXdmValue();
> }
> =20
>=20
> Thanks again for the help
>=20
> =20
>=20
> best regards
>=20
> =20
>=20
> -alan
>=20
> =20
>=20
> On Thu, Jul 15, 2021 at 1:18 AM Michael Kay <[email protected] =
<mailto:[email protected]>> wrote:
>=20
> >I'm wondering what the drawbacks would be for re-using a same =
Processor by a (potentially) large number of Xslt30Transformers in =
parallel.=20
>=20
> For most cases, none.
>=20
> Potentially you could hit limits on the number of names allowed in a =
NamePool. In practice we never see people hitting those limits.
>=20
> Slightly more likely is that you hit a problem that the schema =
components held by a Processor must be consistent (for example, you =
can't have two different types with the same name - which could happen =
if you want to use two different versions of the same schema).
>=20
> In general, you should only create a single Processor unless you have =
clear reasons to do otherwise.
>=20
> There is in fact a low-level mechanism to copy an XdmNode owned by one =
Processor to a different Processor: it's the NamePoolConverter class, =
used by the method Sender.sendDocumentInfo(). But it's not exposed in a =
convenient way at the s9api interface.
>=20
> Michael Kay
> Saxonica
>=20
>=20
>=20
>=20
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/ =
<http://saxon.markmail.org/>
> [email protected] =
<mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/saxon-help =
<https://lists.sourceforge.net/lists/listinfo/saxon-help>
> =20
>=20
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/ =
<http://saxon.markmail.org/>
> [email protected] =
<mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/saxon-help =
<https://lists.sourceforge.net/lists/listinfo/saxon-help>_________________=
______________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


--Apple-Mail=_E9D1592B-0854-4BFE-B63E-D67667D81576
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D"">Can =
you remind me why you want to have more than one =
Processor/Configuration?<div class=3D""><br class=3D""></div><div =
class=3D"">And if you do need to have multiple Configurations, is there =
any reason they can't share the same NamePool?</div><div class=3D""><br =
class=3D""></div><div class=3D"">(Note, if you manage to get past =
Saxon's checks and use a node with the wrong NamePool, the likely =
consequence is that elements will satisfy NameTests in expressions and =
patterns that they shouldn't satisfy, and vice versa.)</div><div =
class=3D""><br class=3D""></div><div class=3D"">Michael Kay</div><div =
class=3D"">Saxonica<br class=3D""><div><br class=3D""><blockquote =
type=3D"cite" class=3D""><div class=3D"">On 6 Aug 2021, at 23:47, Alan =
Painter &lt;<a href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a>&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" =
class=3D"">It appears to me that, in my usages, there are three main =
categories of XdmValue "types" that one would see as a result of an XSLT =
transformation (either principal output or result-document output):<div =
class=3D""><br class=3D""></div><div class=3D"">a) Plain ol' =
XML</div><div class=3D"">b) Maps/Array/Atomics (or what I was calling =
"JSON-oriented")</div><div class=3D"">c) Maps/Arrays containing XML =
data</div><div class=3D""><br class=3D""></div><div class=3D"">So if I =
want to feed the XdmValue output from apply-templates() as the input =
selection to apply-templates() of a different processor, I'll need to =
(respectively)</div><div class=3D""><br class=3D""></div><div =
class=3D"">a) Use NamePoolConverter&nbsp;</div><div class=3D"">b) No =
conversion necessary</div><div class=3D"">c) Pretty substantial =
undertaking&nbsp;</div><div class=3D""><br class=3D""></div><div =
class=3D"">a) and b) seem to work using this converter:</div><div =
class=3D""><pre style=3D"font-family: Menlo; font-size: 9pt;" =
class=3D""><span style=3D"color:rgb(0,0,128);font-weight:bold" =
class=3D"">private static </span>XdmValue convertXdmValueForXslt(<span =
style=3D"color:rgb(0,0,128);font-weight:bold" class=3D"">final =
</span>XdmValue toConvert, <span =
style=3D"color:rgb(0,0,128);font-weight:bold" class=3D"">final =
</span>Xslt30Transformer destinationXslt) <span =
style=3D"color:rgb(0,0,128);font-weight:bold" class=3D"">throws =
</span>XPathException {<br class=3D""><br class=3D"">    <span =
style=3D"color:rgb(0,0,128);font-weight:bold" class=3D"">if </span>( =
!(toConvert <span style=3D"color:rgb(0,0,128);font-weight:bold" =
class=3D"">instanceof </span>XdmNode) ) {<br class=3D"">        <span =
style=3D"color:rgb(128,128,128);font-style:italic" class=3D"">// not XML =
hence don't convert<br class=3D""></span><span =
style=3D"color:rgb(128,128,128);font-style:italic" class=3D"">        =
</span><span style=3D"color:rgb(0,0,128);font-weight:bold" =
class=3D"">return </span>toConvert;<br class=3D"">    }<br class=3D""><br =
class=3D"">    <span style=3D"color:rgb(0,0,128);font-weight:bold" =
class=3D"">final </span>RawDestination        rawDest  =3D <span =
style=3D"color:rgb(0,0,128);font-weight:bold" class=3D"">new =
</span>RawDestination();<br class=3D"">    <span =
style=3D"color:rgb(0,0,128);font-weight:bold" class=3D"">final =
</span>PipelineConfiguration pipe     =3D =
destinationXslt.getUnderlyingController().makePipelineConfiguration();<br =
class=3D"">    <span style=3D"color:rgb(0,0,128);font-weight:bold" =
class=3D"">final </span>Receiver              receiver =3D =
rawDest.getReceiver(pipe, <span =
style=3D"color:rgb(0,0,128);font-weight:bold" class=3D"">null</span>);<br =
class=3D""><br class=3D"">    Sender.<span style=3D"font-style:italic" =
class=3D"">send</span>((NodeInfo) toConvert.getUnderlyingValue(), =
receiver, <span style=3D"color:rgb(0,0,128);font-weight:bold" =
class=3D"">new </span>ParseOptions());<br class=3D""><br class=3D"">    =
<span style=3D"color:rgb(0,0,128);font-weight:bold" class=3D"">return =
</span>rawDest.getXdmValue();<br class=3D"">}</pre></div><div =
class=3D"">c) would require that substantial undertaking so I will think =
about that later as may not even be very useful</div><div class=3D""><br =
class=3D""></div><div class=3D"">I did try a test to see what errors =
that I would get by transforming maps containing XML.&nbsp; To create =
this, I used the adaptive output method:</div><div class=3D""><pre =
style=3D"font-family: Menlo; font-size: 9pt;" class=3D""><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:stylesheet </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xmlns:xsl</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"<a href=3D"http://www.w3.org/1999/XSL/Transform" =
class=3D"">http://www.w3.org/1999/XSL/Transform</a>"<br =
class=3D""></span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">  </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">version</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"3.0"<br class=3D""></span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">  </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">exclude-result-prefixes</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"xsl"</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D""><br class=3D"">  <span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:output </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">method</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"adaptive" </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">indent</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"yes"</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">/&gt;</span><br =
class=3D""><br class=3D"">  <span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:template </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">match</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"."</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D"">      <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:map</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D"">          <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:map-entry </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">key</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"'anArray'" </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">select</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"array { 1, 2, 3.14159, (), true(), 'anArray' }" =
</span><span style=3D"background-color:rgb(247,250,255)" =
class=3D"">/&gt;</span><br class=3D"">          <span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:map-entry </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">key</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"'someXml'"</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D"">            <span style=3D"background-color:rgb(239,239,239)" =
class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:=
bold" class=3D"">here </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(239,239,239);font-weight:=
bold" class=3D"">is</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(239,239,239);font-weight:=
bold" class=3D"">=3D"some" </span><span =
style=3D"background-color:rgb(239,239,239)" class=3D"">&gt;</span><br =
class=3D"">              <span style=3D"background-color:rgb(239,239,239)"=
 class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:=
bold" class=3D"">xml</span><span =
style=3D"background-color:rgb(239,239,239)" =
class=3D"">&gt;</span>data<span =
style=3D"background-color:rgb(239,239,239)" class=3D"">&lt;/</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:=
bold" class=3D"">xml</span><span =
style=3D"background-color:rgb(239,239,239)" class=3D"">&gt;</span><br =
class=3D"">            <span style=3D"background-color:rgb(239,239,239)" =
class=3D"">&lt;/</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:=
bold" class=3D"">here</span><span =
style=3D"background-color:rgb(239,239,239)" class=3D"">&gt;</span><br =
class=3D"">          <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;/</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:map-entry</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D"">          <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:map-entry </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">key</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"'anotherMap'"</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D"">            <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:map-entry </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">key</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"'key1'" </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">select</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"'value1'" </span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">/&gt;</span><br =
class=3D"">            <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:map-entry </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">key</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"'key2'" </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">select</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"[ 10, 9, 8 ]" </span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">/&gt;</span><br =
class=3D"">          <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;/</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:map-entry</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D"">      <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;/</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:map</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D"">  <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;/</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:template</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D""><span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;/</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:stylesheet</span><span =
style=3D"background-color:rgb(247,250,255)" =
class=3D"">&gt;</span></pre><pre style=3D"font-family: Menlo; font-size: =
9pt;" class=3D""><span =
style=3D"font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(=
34,34,34)" class=3D"">I used the&nbsp;output of this transformation as =
the input to an identity transformation of a different =
processor:</span></pre><pre style=3D"font-family: Menlo; font-size: =
9pt;" class=3D""><pre style=3D"font-family:Menlo;font-size:9pt" =
class=3D""><span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:stylesheet </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xmlns:xsl</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"<a href=3D"http://www.w3.org/1999/XSL/Transform" =
class=3D"">http://www.w3.org/1999/XSL/Transform</a>"<br =
class=3D""></span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">  </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">version</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"3.0"<br class=3D""></span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">  </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">exclude-result-prefixes</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"xsl"</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D""><br class=3D"">  <span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:output </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">method</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"adaptive" </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">indent</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"yes"</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">/&gt;</span><br =
class=3D""><br class=3D"">  <span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:template </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">match</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"."</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D"">      <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:copy-of </span><span =
style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">select</span><span =
style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">=3D"." </span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">/&gt;</span><br =
class=3D"">  <span style=3D"background-color:rgb(247,250,255)" =
class=3D"">&lt;/</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:template</span><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&gt;</span><br =
class=3D""><br class=3D""><span =
style=3D"background-color:rgb(247,250,255)" class=3D"">&lt;/</span><span =
style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:=
bold" class=3D"">xsl:stylesheet</span><span =
style=3D"background-color:rgb(247,250,255)" =
class=3D"">&gt;</span></pre></pre><pre style=3D"font-family: Menlo; =
font-size: 9pt;" class=3D""><span =
style=3D"font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(=
34,34,34)" class=3D"">I didn't encounter any errors in the processing, =
although I understand that this doesn't mean that it would always =
work.</span></pre><pre style=3D"font-family: Menlo; font-size: 9pt;" =
class=3D""><span =
style=3D"color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-s=
ize:small" class=3D"">So it does seem that for maps/arrays containing =
XML, the embedded XML configurations are not checked for compatibility =
with the processor's configuration.</span><br class=3D""></pre><pre =
style=3D"font-family: Menlo; font-size: 9pt;" class=3D""><span =
style=3D"color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-s=
ize:small" class=3D"">I do think that I'm getting somewhere.  Thanks =
again for your help.</span></pre><pre style=3D"font-family: Menlo; =
font-size: 9pt;" class=3D"">-alan</pre><pre style=3D"font-family: Menlo; =
font-size: 9pt;" class=3D""><br class=3D""></pre><pre =
style=3D"font-family: Menlo; font-size: 9pt;" class=3D""><span =
style=3D"font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(=
34,34,34)" class=3D""><br class=3D""></span></pre><pre =
style=3D"font-family: Menlo; font-size: 9pt;" class=3D""><span =
style=3D"font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(=
34,34,34)" class=3D""><br class=3D""></span></pre></div></div><br =
class=3D""><div class=3D"gmail_quote"><div dir=3D"ltr" =
class=3D"gmail_attr">On Thu, Aug 5, 2021 at 12:41 AM Michael Kay &lt;<a =
href=3D"mailto:mike-JkSD5nQpfvpWk0Htik3J/[email protected]" class=3D"">mike-JkSD5nQpfvpWk0Htik3J/[email protected]</a>&gt; =
wrote:<br class=3D""></div><blockquote class=3D"gmail_quote" =
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex"><div lang=3D"EN-GB" =
style=3D"overflow-wrap: break-word;" class=3D""><div =
class=3D"gmail-m_-876889316942839831WordSection1"><p =
class=3D"MsoNormal">Depends a bit what you mean by =E2=80=9CJSON-oriented=E2=
=80=9D. Maps and arrays can of course contain XDM nodes in their values =
(and I don=E2=80=99t think we always check that these belong to the =
right Configuration when supplied via external APIs, in the same way =
that we check for nodes). Writing code that converts a =
map-containing-nodes from one Configuration to a =
map-containing-equivalent-nodes from a different Configuration would be =
a pretty substantial undertaking.</p><p class=3D"MsoNormal"><u =
class=3D""></u>&nbsp;<u class=3D""></u></p><p =
class=3D"MsoNormal">Sender.send() expects a Source object, and the JAXP =
Source interface is very XML-biased.</p><p class=3D"MsoNormal"><u =
class=3D""></u>&nbsp;<u class=3D""></u></p><p class=3D"MsoNormal">Michael =
Kay</p><p class=3D"MsoNormal">Saxonica</p><p class=3D"MsoNormal"><u =
class=3D""></u>&nbsp;<u class=3D""></u></p><div =
style=3D"border-right:none;border-bottom:none;border-left:none;border-top:=
1pt solid rgb(225,225,225);padding:3pt 0cm 0cm" class=3D""><p =
class=3D"MsoNormal" style=3D"border:none;padding:0cm"><b class=3D"">From: =
</b><a href=3D"mailto:[email protected]" target=3D"_blank" =
class=3D"">Alan Painter</a><br class=3D""><b class=3D"">Sent: </b>04 =
August 2021 22:33<br class=3D""><b class=3D"">To: </b><a =
href=3D"mailto:[email protected]" target=3D"_blank" =
class=3D"">Mailing list for the SAXON XSLT and XQuery processor</a><br =
class=3D""><b class=3D"">Subject: </b>Re: [saxon] XdmValue objects =
returned from applyTemplates()</p></div><p class=3D"MsoNormal"><u =
class=3D""></u>&nbsp;<u class=3D""></u></p><div class=3D""><p =
class=3D"MsoNormal">I see that I was too hasty in saying that it was =
"working" for me.</p><div class=3D""><p class=3D"MsoNormal"><u =
class=3D""></u>&nbsp;<u class=3D""></u></p></div><div class=3D""><p =
class=3D"MsoNormal">I'd like the XdmValue to be any arbitrary Xdm with =
un-annotated XML, maps, arrays and atomics (no need for =
functions).&nbsp;&nbsp;</p></div><div class=3D""><p =
class=3D"MsoNormal">But maps and and arrays cannot be cast to NodeInfo =
(or, at least, I'm getting an error when doing this).</p></div><div =
class=3D""><p class=3D"MsoNormal"><u class=3D""></u>&nbsp;<u =
class=3D""></u></p></div><div class=3D""><p class=3D"MsoNormal">Would =
there be a way to send JSON-oriented XdmValue to =
Sender.send()?&nbsp;&nbsp;</p></div><div class=3D""><p =
class=3D"MsoNormal">(I'm thinking that a pure JSON XdmValue wouldn't =
need to have its NamePool converted, but what about a mix of XML and =
maps/arrays?)</p></div><div class=3D""><p class=3D"MsoNormal"><u =
class=3D""></u>&nbsp;<u class=3D""></u></p></div><div class=3D""><p =
class=3D"MsoNormal">thanks again for any help</p></div><div class=3D""><p =
class=3D"MsoNormal"><u class=3D""></u>&nbsp;<u =
class=3D""></u></p></div><div class=3D""><p class=3D"MsoNormal"><u =
class=3D""></u>&nbsp;<u class=3D""></u></p></div></div><p =
class=3D"MsoNormal"><u class=3D""></u>&nbsp;<u class=3D""></u></p><div =
class=3D""><div class=3D""><p class=3D"MsoNormal">On Wed, Aug 4, 2021 at =
10:12 PM Alan Painter &lt;<a href=3D"mailto:[email protected]" =
target=3D"_blank" class=3D"">[email protected]</a>&gt; =
wrote:</p></div><blockquote =
style=3D"border-top:none;border-right:none;border-bottom:none;border-left:=
1pt solid rgb(204,204,204);padding:0cm 0cm 0cm =
6pt;margin-left:4.8pt;margin-right:0cm" class=3D""><div class=3D""><p =
class=3D"MsoNormal">I'm finally getting around to implementing something =
w.r.t. the pointers that you gave me, Michael.</p><div class=3D""><p =
class=3D"MsoNormal"><u class=3D""></u>&nbsp;<u =
class=3D""></u></p></div><div class=3D""><p class=3D"MsoNormal">My =
objective is to convert a given XdmValue so that it can become the input =
for a Xslt30Transformer&nbsp;with a different NamePool from the origin =
Xslt30Transformer.</p></div><div class=3D""><p class=3D"MsoNormal"><u =
class=3D""></u>&nbsp;<u class=3D""></u></p></div><div class=3D""><p =
class=3D"MsoNormal">This seems to be working for me.&nbsp; I'm curious =
if this is OK and if there isn't a shorter way.</p></div><div =
class=3D""><p class=3D"MsoNormal"><u class=3D""></u>&nbsp;<u =
class=3D""></u></p></div><div class=3D""><pre class=3D""><b =
class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" =
class=3D"">private </span></b><span style=3D"font-size: 9pt; =
font-family: Menlo, serif;" class=3D"">XdmValue =
convertXdmValueForXslt(</span><b class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" =
class=3D"">final </span></b><span style=3D"font-size: 9pt; font-family: =
Menlo, serif;" class=3D"">XdmValue toConvert, </span><b class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" =
class=3D"">final </span></b><span style=3D"font-size: 9pt; font-family: =
Menlo, serif;" class=3D"">Xslt30Transformer destinationXslt) </span><b =
class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" =
class=3D"">throws </span></b><span style=3D"font-size: 9pt; font-family: =
Menlo, serif;" class=3D"">XPathException {<br =
class=3D"">&nbsp;&nbsp;&nbsp; </span><b class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" =
class=3D"">final </span></b><span style=3D"font-size: 9pt; font-family: =
Menlo, serif;" =
class=3D"">RawDestination&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
rawDest&nbsp; =3D </span><b class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" class=3D"">new =
</span></b><span style=3D"font-size: 9pt; font-family: Menlo, serif;" =
class=3D"">RawDestination();<br class=3D"">&nbsp;&nbsp;&nbsp; </span><b =
class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" =
class=3D"">final </span></b><span style=3D"font-size: 9pt; font-family: =
Menlo, serif;" class=3D"">PipelineConfiguration =
pipe&nbsp;&nbsp;&nbsp;&nbsp; =3D =
destinationXslt.getUnderlyingController().makePipelineConfiguration();<br =
class=3D"">&nbsp;&nbsp;&nbsp; </span><b class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" =
class=3D"">final </span></b><span style=3D"font-size: 9pt; font-family: =
Menlo, serif;" class=3D"">Receiver&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;receiver=
 =3D rawDest.getReceiver(pipe, </span><b class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" =
class=3D"">null</span></b><span style=3D"font-size: 9pt; font-family: =
Menlo, serif;" class=3D"">);<br class=3D""><br =
class=3D"">&nbsp;&nbsp;&nbsp; Sender.<i class=3D"">send</i>((NodeInfo) =
toConvert.getUnderlyingValue(), receiver, </span><b class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" class=3D"">new =
</span></b><span style=3D"font-size: 9pt; font-family: Menlo, serif;" =
class=3D"">ParseOptions());<br class=3D""><br =
class=3D"">&nbsp;&nbsp;&nbsp; </span><b class=3D""><span =
style=3D"font-size:9pt;font-family:Menlo,serif;color:navy" =
class=3D"">return </span></b><span style=3D"font-size: 9pt; font-family: =
Menlo, serif;" class=3D"">rawDest.getXdmValue();<br class=3D"">}<u =
class=3D""></u><u class=3D""></u></span></pre></div><div class=3D""><p =
class=3D"MsoNormal"><u class=3D""></u>&nbsp;<u =
class=3D""></u></p></div><div class=3D""><p class=3D"MsoNormal">Thanks =
again for the help</p></div><div class=3D""><p class=3D"MsoNormal"><u =
class=3D""></u>&nbsp;<u class=3D""></u></p></div><div class=3D""><p =
class=3D"MsoNormal">best regards</p></div><div class=3D""><p =
class=3D"MsoNormal"><u class=3D""></u>&nbsp;<u =
class=3D""></u></p></div><div class=3D""><p =
class=3D"MsoNormal">-alan</p></div></div><p class=3D"MsoNormal"><u =
class=3D""></u>&nbsp;<u class=3D""></u></p><div class=3D""><div =
class=3D""><p class=3D"MsoNormal">On Thu, Jul 15, 2021 at 1:18 AM =
Michael Kay &lt;<a href=3D"mailto:[email protected]" =
target=3D"_blank" class=3D"">[email protected]</a>&gt; =
wrote:</p></div></div></blockquote></div><p class=3D"MsoNormal" =
style=3D"margin-left:9.6pt">&gt;I'm wondering what the drawbacks would =
be for re-using a same Processor by a (potentially) large number of =
Xslt30Transformers in parallel. <br class=3D""><br class=3D"">For most =
cases, none.<br class=3D""><br class=3D"">Potentially you could hit =
limits on the number of names allowed in a NamePool. In practice we =
never see people hitting those limits.<br class=3D""><br =
class=3D"">Slightly more likely is that you hit a problem that the =
schema components held by a Processor must be consistent (for example, =
you can't have two different types with the same name - which could =
happen if you want to use two different versions of the same schema).<br =
class=3D""><br class=3D"">In general, you should only create a single =
Processor unless you have clear reasons to do otherwise.<br class=3D""><br=
 class=3D"">There is in fact a low-level mechanism to copy an XdmNode =
owned by one Processor to a different Processor: it's the =
NamePoolConverter class, used by the method Sender.sendDocumentInfo(). =
But it's not exposed in a convenient way at the s9api interface.<br =
class=3D""><br class=3D"">Michael Kay<br class=3D"">Saxonica<br =
class=3D""><br class=3D""><br class=3D""><br class=3D""><br =
class=3D"">_______________________________________________<br =
class=3D"">saxon-help mailing list archived at <a =
href=3D"http://saxon.markmail.org/" target=3D"_blank" =
class=3D"">http://saxon.markmail.org/</a><br class=3D""><a =
href=3D"mailto:[email protected]" target=3D"_blank" =
class=3D"">[email protected]</a><br class=3D""><a =
href=3D"https://lists.sourceforge.net/lists/listinfo/saxon-help" =
target=3D"_blank" =
class=3D"">https://lists.sourceforge.net/lists/listinfo/saxon-help</a> =
</p><p class=3D"MsoNormal"><u class=3D""></u>&nbsp;<u =
class=3D""></u></p></div></div>___________________________________________=
____<br class=3D"">
saxon-help mailing list archived at <a href=3D"http://saxon.markmail.org/"=
 rel=3D"noreferrer" target=3D"_blank" =
class=3D"">http://saxon.markmail.org/</a><br class=3D"">
<a href=3D"mailto:[email protected]" target=3D"_blank" =
class=3D"">[email protected]</a><br class=3D"">
<a href=3D"https://lists.sourceforge.net/lists/listinfo/saxon-help" =
rel=3D"noreferrer" target=3D"_blank" =
class=3D"">https://lists.sourceforge.net/lists/listinfo/saxon-help</a> =
</blockquote></div>
_______________________________________________<br class=3D"">saxon-help =
mailing list archived at <a href=3D"http://saxon.markmail.org/" =
class=3D"">http://saxon.markmail.org/</a><br class=3D""><a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a><br =
class=3D"">https://lists.sourceforge.net/lists/listinfo/saxon-help =
</div></blockquote></div><br class=3D""></div></body></html>=

--Apple-Mail=_E9D1592B-0854-4BFE-B63E-D67667D81576--


--===============0731438431931273460==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============0731438431931273460==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
--===============0731438431931273460==--