Re: XdmValue objects returned from applyTemplates()
Alan Painter <[email protected]> Sun, 8 Aug 2021 00:30:52 +0200
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <CAN+GtW3=pfxU-5N4qv98YvaZENh6ueDYNQMKHrj8ONgMdErNeg@mail.gmail.com> |
--===============7066007300136544797== Content-Type: multipart/alternative; boundary="000000000000cd788d05c8ffb4f4" --000000000000cd788d05c8ffb4f4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable What's motivating my quest for XdmValue conversion is that I'm looking at instantiating a number of different transformations as spring-beans that are used within spring-integration as part of the implementation of micro-services. The transformations are instantiated separately in fairly independent contexts. There is some coupling introduced by requiring all of the transformations instances to use the same Processor. I'm really looking at avoiding this coupling. Also, although I probably will not see this case, I was imagining systems that could receive a lot of different namespaces, types, etc, and that the NamePool could grow very large over time. These are microservices and are systems that can run for a very long timespan (months, years). The fact that the NamePool is synchronized also is a minor performance drawback for a large number of independent transformations. So although I probably won't run into any NamePool problems, I'd like to know that, if I did, that there was a solution for it. NamePoolConverter seems to be such a solution for the XML documents. A little extra effort could probably also find a similar solution for maps/arrays containing XML documents. At this point, I think that I have a solution for at least the XML and the pure maps/arrays type of XdmValue. I'll wait a bit to see if maps/arrays containing xml is a requirement before thinking about the substantial undertaking. thanks very much for help and best regards -alan On Sat, Aug 7, 2021 at 1:28 AM Michael Kay <[email protected]> wrote: > 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 vi= ce > versa.) > > Michael Kay > Saxonica > > On 6 Aug 2021, at 23:47, Alan Painter <[email protected]> wrote: > > 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): > > a) Plain ol' XML > b) Maps/Array/Atomics (or what I was calling "JSON-oriented") > c) Maps/Arrays containing XML data > > 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) > > a) Use NamePoolConverter > b) No conversion necessary > c) Pretty substantial undertaking > > a) and b) seem to work using this converter: > > private static XdmValue convertXdmValueForXslt(final XdmValue toConvert, = final Xslt30Transformer destinationXslt) throws XPathException { > > if ( !(toConvert instanceof XdmNode) ) { > // not XML hence don't convert > return toConvert; > } > > final RawDestination rawDest =3D new RawDestination(); > final PipelineConfiguration pipe =3D destinationXslt.getUnderlyin= gController().makePipelineConfiguration(); > final Receiver receiver =3D rawDest.getReceiver(pipe, nu= ll); > > Sender.send((NodeInfo) toConvert.getUnderlyingValue(), receiver, new = ParseOptions()); > > return rawDest.getXdmValue(); > } > > c) would require that substantial undertaking so I will think about that > later as may not even be very useful > > 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" > version=3D"3.0" > exclude-result-prefixes=3D"xsl"> > > <xsl:output method=3D"adaptive" indent=3D"yes"/> > > <xsl:template match=3D"."> > <xsl:map> > <xsl:map-entry key=3D"'anArray'" select=3D"array { 1, 2, 3.1415= 9, (), 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 tran= sformation of a different processor: > > <xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform" > version=3D"3.0" > exclude-result-prefixes=3D"xsl"> > > <xsl:output method=3D"adaptive" indent=3D"yes"/> > > <xsl:template match=3D"."> > <xsl:copy-of select=3D"." /> > </xsl:template> > > </xsl:stylesheet> > > I didn't encounter any errors in the processing, although I understand th= at this doesn't mean that it would always work. > > So it does seem that for maps/arrays containing XML, the embedded XML con= figurations are not checked for compatibility with the processor's configur= ation. > > I do think that I'm getting somewhere. Thanks again for your help. > > -alan > > > > > > On Thu, Aug 5, 2021 at 12:41 AM Michael Kay <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 a= lways 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 conver= ts >> a map-containing-nodes from one Configuration to a >> map-containing-equivalent-nodes from a different Configuration would be = a >> pretty substantial undertaking. >> >> >> >> Sender.send() expects a Source object, and the JAXP Source interface is >> very XML-biased. >> >> >> >> Michael Kay >> >> Saxonica >> >> >> >> *From: *Alan Painter <[email protected]> >> *Sent: *04 August 2021 22:33 >> *To: *Mailing list for the SAXON XSLT and XQuery processor >> <[email protected]> >> *Subject: *Re: [saxon] XdmValue objects returned from applyTemplates() >> >> >> >> I see that I was too hasty in saying that it was "working" for me. >> >> >> >> I'd like the XdmValue to be any arbitrary Xdm with un-annotated XML, >> maps, arrays and atomics (no need for functions). >> >> But maps and and arrays cannot be cast to NodeInfo (or, at least, I'm >> getting an error when doing this). >> >> >> >> Would there be a way to send JSON-oriented XdmValue to Sender.send()? >> >> (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?) >> >> >> >> thanks again for any help >> >> >> >> >> >> >> >> On Wed, Aug 4, 2021 at 10:12 PM Alan Painter <[email protected]> >> wrote: >> >> I'm finally getting around to implementing something w.r.t. the pointers >> that you gave me, Michael. >> >> >> >> 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. >> >> >> >> This seems to be working for me. I'm curious if this is OK and if there >> isn't a shorter way. >> >> >> >> *private *XdmValue convertXdmValueForXslt(*final *XdmValue toConvert, *f= inal *Xslt30Transformer destinationXslt) *throws *XPathException { >> *final *RawDestination rawDest =3D *new *RawDestination(); >> *final *PipelineConfiguration pipe =3D destinationXslt.getUnderl= yingController().makePipelineConfiguration(); >> *final *Receiver receiver =3D rawDest.getReceiver(pipe,= *null*); >> >> Sender.*send*((NodeInfo) toConvert.getUnderlyingValue(), receiver, *= new *ParseOptions()); >> >> *return *rawDest.getXdmValue(); >> } >> >> >> >> Thanks again for the help >> >> >> >> best regards >> >> >> >> -alan >> >> >> >> On Thu, Jul 15, 2021 at 1:18 AM Michael Kay <[email protected]> >> wrote: >> >> >I'm wondering what the drawbacks would be for re-using a same Processor >> by a (potentially) large number of Xslt30Transformers in parallel. >> >> For most cases, none. >> >> Potentially you could hit limits on the number of names allowed in a >> NamePool. In practice we never see people hitting those limits. >> >> Slightly more likely is that you hit a problem that the schema component= s >> 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 u= se >> two different versions of the same schema). >> >> In general, you should only create a single Processor unless you have >> clear reasons to do otherwise. >> >> 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, us= ed >> by the method Sender.sendDocumentInfo(). But it's not exposed in a >> convenient way at the s9api interface. >> >> Michael Kay >> Saxonica >> >> >> >> >> _______________________________________________ >> saxon-help mailing list archived at http://saxon.markmail.org/ >> [email protected] >> 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 > > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [email protected] > 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 --000000000000cd788d05c8ffb4f4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">What's motivating my quest for XdmValue conversion is = that I'm looking at instantiating a number of different transformations= as spring-beans that are used within spring-integration as part of the imp= lementation of micro-services.=C2=A0 The transformations are instantiated s= eparately in fairly independent contexts.=C2=A0 There is some coupling intr= oduced by requiring all of the transformations instances to use the same Pr= ocessor.=C2=A0 I'm really looking at avoiding this coupling.<div><br></= div><div>Also, although I probably will not see this case, I was imagining = systems that could receive a lot of different namespaces, types, etc, and t= hat the NamePool could grow very large over time.=C2=A0 These are microserv= ices and are systems that can run for a very long timespan (months, years).= <div><br></div><div>The fact that the NamePool is synchronized also is a mi= nor performance drawback for a large number of independent transformations.= </div><div><br></div><div>So although I probably won't run into any Nam= ePool problems, I'd like to know that, if I did, that there was a solut= ion for it.=C2=A0 NamePoolConverter seems to be such a solution for the XML= documents.=C2=A0 A little extra effort could probably also find a similar = solution for maps/arrays containing XML documents.</div><div><br></div><div= >At this point, I think that I have a solution for at least the XML and the= pure maps/arrays type of XdmValue.=C2=A0 I'll wait a bit to see if map= s/arrays containing xml is a requirement before thinking about the substant= ial undertaking.</div><div><br></div><div>thanks very much for help and bes= t regards</div><div><br></div><div>-alan</div><div><br></div><div><br></div= ><div><br></div><div><br></div><div><br></div></div></div><br><div class=3D= "gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, Aug 7, 2021 at = 1:28 AM Michael Kay <<a href=3D"mailto:[email protected]">michaelka= [email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_quote" sty= le=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddi= ng-left:1ex"><div style=3D"overflow-wrap: break-word;">Can you remind me wh= y you want to have more than one Processor/Configuration?<div><br></div><di= v>And if you do need to have multiple Configurations, is there any reason t= hey can't share the same NamePool?</div><div><br></div><div>(Note, if y= ou manage to get past Saxon's checks and use a node with the wrong Name= Pool, the likely consequence is that elements will satisfy NameTests in exp= ressions and patterns that they shouldn't satisfy, and vice versa.)</di= v><div><br></div><div>Michael Kay</div><div>Saxonica<br><div><br><blockquot= e type=3D"cite"><div>On 6 Aug 2021, at 23:47, Alan Painter <<a href=3D"m= ailto:[email protected]" target=3D"_blank">[email protected]</a>&= gt; wrote:</div><br><div><div dir=3D"ltr">It appears to me that, in my usag= es, 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><br></div><div>a) Plain ol' XML</div><div= >b) Maps/Array/Atomics (or what I was calling "JSON-oriented")</d= iv><div>c) Maps/Arrays containing XML data</div><div><br></div><div>So if I= want to feed the XdmValue output from apply-templates() as the input selec= tion to apply-templates() of a different processor, I'll need to (respe= ctively)</div><div><br></div><div>a) Use NamePoolConverter=C2=A0</div><div>= b) No conversion necessary</div><div>c) Pretty substantial undertaking=C2= =A0</div><div><br></div><div>a) and b) seem to work using this converter:</= div><div><pre style=3D"font-family:Menlo;font-size:9pt"><span style=3D"colo= r:rgb(0,0,128);font-weight:bold">private static </span>XdmValue convertXdmV= alueForXslt(<span style=3D"color:rgb(0,0,128);font-weight:bold">final </spa= n>XdmValue toConvert, <span style=3D"color:rgb(0,0,128);font-weight:bold">f= inal </span>Xslt30Transformer destinationXslt) <span style=3D"color:rgb(0,0= ,128);font-weight:bold">throws </span>XPathException {<br><br> <span sty= le=3D"color:rgb(0,0,128);font-weight:bold">if </span>( !(toConvert <span st= yle=3D"color:rgb(0,0,128);font-weight:bold">instanceof </span>XdmNode) ) {<= br> <span style=3D"color:rgb(128,128,128);font-style:italic">// not = XML hence don't convert<br></span><span style=3D"color:rgb(128,128,128)= ;font-style:italic"> </span><span style=3D"color:rgb(0,0,128);font-w= eight:bold">return </span>toConvert;<br> }<br><br> <span style=3D"col= or:rgb(0,0,128);font-weight:bold">final </span>RawDestination rawDes= t =3D <span style=3D"color:rgb(0,0,128);font-weight:bold">new </span>RawDe= stination();<br> <span style=3D"color:rgb(0,0,128);font-weight:bold">fin= al </span>PipelineConfiguration pipe =3D destinationXslt.getUnderlyingC= ontroller().makePipelineConfiguration();<br> <span style=3D"color:rgb(0,= 0,128);font-weight:bold">final </span>Receiver receiver =3D ra= wDest.getReceiver(pipe, <span style=3D"color:rgb(0,0,128);font-weight:bold"= >null</span>);<br><br> Sender.<span style=3D"font-style:italic">send</sp= an>((NodeInfo) toConvert.getUnderlyingValue(), receiver, <span style=3D"col= or:rgb(0,0,128);font-weight:bold">new </span>ParseOptions());<br><br> <s= pan style=3D"color:rgb(0,0,128);font-weight:bold">return </span>rawDest.get= XdmValue();<br>}</pre></div><div>c) would require that substantial undertak= ing so I will think about that later as may not even be very useful</div><d= iv><br></div><div>I did try a test to see what errors that I would get by t= ransforming maps containing XML.=C2=A0 To create this, I used the adaptive = output method:</div><div><pre style=3D"font-family:Menlo;font-size:9pt"><sp= an style=3D"background-color:rgb(247,250,255)"><</span><span style=3D"co= lor:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:bold">xsl:st= ylesheet </span><span style=3D"color:rgb(0,0,255);background-color:rgb(247,= 250,255);font-weight:bold">xmlns:xsl</span><span style=3D"color:rgb(0,128,0= );background-color:rgb(247,250,255);font-weight:bold">=3D"<a href=3D"h= ttp://www.w3.org/1999/XSL/Transform" target=3D"_blank">http://www.w3.org/19= 99/XSL/Transform</a>"<br></span><span style=3D"color:rgb(0,128,0);back= ground-color:rgb(247,250,255);font-weight:bold"> </span><span style=3D"col= or:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:bold">version= </span><span style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);= font-weight:bold">=3D"3.0"<br></span><span style=3D"color:rgb(0,1= 28,0);background-color:rgb(247,250,255);font-weight:bold"> </span><span st= yle=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:bol= d">exclude-result-prefixes</span><span style=3D"color:rgb(0,128,0);backgrou= nd-color:rgb(247,250,255);font-weight:bold">=3D"xsl"</span><span = style=3D"background-color:rgb(247,250,255)">></span><br><br> <span styl= e=3D"background-color:rgb(247,250,255)"><</span><span style=3D"color:rgb= (0,0,128);background-color:rgb(247,250,255);font-weight:bold">xsl:output </= span><span style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);fo= nt-weight:bold">method</span><span style=3D"color:rgb(0,128,0);background-c= olor:rgb(247,250,255);font-weight:bold">=3D"adaptive" </span><spa= n style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight= :bold">indent</span><span style=3D"color:rgb(0,128,0);background-color:rgb(= 247,250,255);font-weight:bold">=3D"yes"</span><span style=3D"back= ground-color:rgb(247,250,255)">/></span><br><br> <span style=3D"backgro= und-color:rgb(247,250,255)"><</span><span style=3D"color:rgb(0,0,128);ba= ckground-color:rgb(247,250,255);font-weight:bold">xsl:template </span><span= style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:= bold">match</span><span style=3D"color:rgb(0,128,0);background-color:rgb(24= 7,250,255);font-weight:bold">=3D"."</span><span style=3D"backgrou= nd-color:rgb(247,250,255)">></span><br> <span style=3D"background-c= olor:rgb(247,250,255)"><</span><span style=3D"color:rgb(0,0,128);backgro= und-color:rgb(247,250,255);font-weight:bold">xsl:map</span><span style=3D"b= ackground-color:rgb(247,250,255)">></span><br> <span style=3D"b= ackground-color:rgb(247,250,255)"><</span><span style=3D"color:rgb(0,0,1= 28);background-color:rgb(247,250,255);font-weight:bold">xsl:map-entry </spa= n><span style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-= weight:bold">key</span><span style=3D"color:rgb(0,128,0);background-color:r= gb(247,250,255);font-weight:bold">=3D"'anArray'" </span><= span style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-wei= ght:bold">select</span><span style=3D"color:rgb(0,128,0);background-color:r= gb(247,250,255);font-weight:bold">=3D"array { 1, 2, 3.14159, (), true(= ), 'anArray' }" </span><span style=3D"background-color:rgb(247= ,250,255)">/></span><br> <span style=3D"background-color:rgb(24= 7,250,255)"><</span><span style=3D"color:rgb(0,0,128);background-color:r= gb(247,250,255);font-weight:bold">xsl:map-entry </span><span style=3D"color= :rgb(0,0,255);background-color:rgb(247,250,255);font-weight:bold">key</span= ><span style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-w= eight:bold">=3D"'someXml'"</span><span style=3D"backgroun= d-color:rgb(247,250,255)">></span><br> <span style=3D"backgro= und-color:rgb(239,239,239)"><</span><span style=3D"color:rgb(0,0,128);ba= ckground-color:rgb(239,239,239);font-weight:bold">here </span><span style= =3D"color:rgb(0,0,255);background-color:rgb(239,239,239);font-weight:bold">= is</span><span style=3D"color:rgb(0,128,0);background-color:rgb(239,239,239= );font-weight:bold">=3D"some" </span><span style=3D"background-co= lor:rgb(239,239,239)">></span><br> <span style=3D"backgroun= d-color:rgb(239,239,239)"><</span><span style=3D"color:rgb(0,0,128);back= ground-color:rgb(239,239,239);font-weight:bold">xml</span><span style=3D"ba= ckground-color:rgb(239,239,239)">></span>data<span style=3D"background-c= olor:rgb(239,239,239)"></</span><span style=3D"color:rgb(0,0,128);backgr= ound-color:rgb(239,239,239);font-weight:bold">xml</span><span style=3D"back= ground-color:rgb(239,239,239)">></span><br> <span style=3D"ba= ckground-color:rgb(239,239,239)"></</span><span style=3D"color:rgb(0,0,1= 28);background-color:rgb(239,239,239);font-weight:bold">here</span><span st= yle=3D"background-color:rgb(239,239,239)">></span><br> <span st= yle=3D"background-color:rgb(247,250,255)"></</span><span style=3D"color:= rgb(0,0,128);background-color:rgb(247,250,255);font-weight:bold">xsl:map-en= try</span><span style=3D"background-color:rgb(247,250,255)">></span><br>= <span style=3D"background-color:rgb(247,250,255)"><</span><spa= n style=3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight= :bold">xsl:map-entry </span><span style=3D"color:rgb(0,0,255);background-co= lor:rgb(247,250,255);font-weight:bold">key</span><span style=3D"color:rgb(0= ,128,0);background-color:rgb(247,250,255);font-weight:bold">=3D"'a= notherMap'"</span><span style=3D"background-color:rgb(247,250,255)= ">></span><br> <span style=3D"background-color:rgb(247,250,25= 5)"><</span><span style=3D"color:rgb(0,0,128);background-color:rgb(247,2= 50,255);font-weight:bold">xsl:map-entry </span><span style=3D"color:rgb(0,0= ,255);background-color:rgb(247,250,255);font-weight:bold">key</span><span s= tyle=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:bo= ld">=3D"'key1'" </span><span style=3D"color:rgb(0,0,255);= background-color:rgb(247,250,255);font-weight:bold">select</span><span styl= e=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);font-weight:bold"= >=3D"'value1'" </span><span style=3D"background-color:rgb= (247,250,255)">/></span><br> <span style=3D"background-color:= rgb(247,250,255)"><</span><span style=3D"color:rgb(0,0,128);background-c= olor:rgb(247,250,255);font-weight:bold">xsl:map-entry </span><span style=3D= "color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:bold">key= </span><span style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);= font-weight:bold">=3D"'key2'" </span><span style=3D"color= :rgb(0,0,255);background-color:rgb(247,250,255);font-weight:bold">select</s= pan><span style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);fon= t-weight:bold">=3D"[ 10, 9, 8 ]" </span><span style=3D"background= -color:rgb(247,250,255)">/></span><br> <span style=3D"backgroun= d-color:rgb(247,250,255)"></</span><span style=3D"color:rgb(0,0,128);bac= kground-color:rgb(247,250,255);font-weight:bold">xsl:map-entry</span><span = style=3D"background-color:rgb(247,250,255)">></span><br> <span styl= e=3D"background-color:rgb(247,250,255)"></</span><span style=3D"color:rg= b(0,0,128);background-color:rgb(247,250,255);font-weight:bold">xsl:map</spa= n><span style=3D"background-color:rgb(247,250,255)">></span><br> <span = style=3D"background-color:rgb(247,250,255)"></</span><span style=3D"colo= r:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:bold">xsl:temp= late</span><span style=3D"background-color:rgb(247,250,255)">></span><br= ><span style=3D"background-color:rgb(247,250,255)"></</span><span style= =3D"color:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:bold">= xsl:stylesheet</span><span style=3D"background-color:rgb(247,250,255)">>= </span></pre><pre style=3D"font-family:Menlo;font-size:9pt"><span style=3D"= font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)"= >I used the=C2=A0output of this transformation as the input to an identity = transformation of a different processor:</span></pre><pre style=3D"font-fam= ily:Menlo;font-size:9pt"><pre style=3D"font-family:Menlo;font-size:9pt"><sp= an style=3D"background-color:rgb(247,250,255)"><</span><span style=3D"co= lor:rgb(0,0,128);background-color:rgb(247,250,255);font-weight:bold">xsl:st= ylesheet </span><span style=3D"color:rgb(0,0,255);background-color:rgb(247,= 250,255);font-weight:bold">xmlns:xsl</span><span style=3D"color:rgb(0,128,0= );background-color:rgb(247,250,255);font-weight:bold">=3D"<a href=3D"h= ttp://www.w3.org/1999/XSL/Transform" target=3D"_blank">http://www.w3.org/19= 99/XSL/Transform</a>"<br></span><span style=3D"color:rgb(0,128,0);back= ground-color:rgb(247,250,255);font-weight:bold"> </span><span style=3D"col= or:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:bold">version= </span><span style=3D"color:rgb(0,128,0);background-color:rgb(247,250,255);= font-weight:bold">=3D"3.0"<br></span><span style=3D"color:rgb(0,1= 28,0);background-color:rgb(247,250,255);font-weight:bold"> </span><span st= yle=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:bol= d">exclude-result-prefixes</span><span style=3D"color:rgb(0,128,0);backgrou= nd-color:rgb(247,250,255);font-weight:bold">=3D"xsl"</span><span = style=3D"background-color:rgb(247,250,255)">></span><br><br> <span styl= e=3D"background-color:rgb(247,250,255)"><</span><span style=3D"color:rgb= (0,0,128);background-color:rgb(247,250,255);font-weight:bold">xsl:output </= span><span style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);fo= nt-weight:bold">method</span><span style=3D"color:rgb(0,128,0);background-c= olor:rgb(247,250,255);font-weight:bold">=3D"adaptive" </span><spa= n style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight= :bold">indent</span><span style=3D"color:rgb(0,128,0);background-color:rgb(= 247,250,255);font-weight:bold">=3D"yes"</span><span style=3D"back= ground-color:rgb(247,250,255)">/></span><br><br> <span style=3D"backgro= und-color:rgb(247,250,255)"><</span><span style=3D"color:rgb(0,0,128);ba= ckground-color:rgb(247,250,255);font-weight:bold">xsl:template </span><span= style=3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:= bold">match</span><span style=3D"color:rgb(0,128,0);background-color:rgb(24= 7,250,255);font-weight:bold">=3D"."</span><span style=3D"backgrou= nd-color:rgb(247,250,255)">></span><br> <span style=3D"background-c= olor:rgb(247,250,255)"><</span><span style=3D"color:rgb(0,0,128);backgro= und-color:rgb(247,250,255);font-weight:bold">xsl:copy-of </span><span style= =3D"color:rgb(0,0,255);background-color:rgb(247,250,255);font-weight:bold">= select</span><span style=3D"color:rgb(0,128,0);background-color:rgb(247,250= ,255);font-weight:bold">=3D"." </span><span style=3D"background-c= olor:rgb(247,250,255)">/></span><br> <span style=3D"background-color:rg= b(247,250,255)"></</span><span style=3D"color:rgb(0,0,128);background-co= lor:rgb(247,250,255);font-weight:bold">xsl:template</span><span style=3D"ba= ckground-color:rgb(247,250,255)">></span><br><br><span style=3D"backgrou= nd-color:rgb(247,250,255)"></</span><span style=3D"color:rgb(0,0,128);ba= ckground-color:rgb(247,250,255);font-weight:bold">xsl:stylesheet</span><spa= n style=3D"background-color:rgb(247,250,255)">></span></pre></pre><pre s= tyle=3D"font-family:Menlo;font-size:9pt"><span style=3D"font-family:Arial,H= elvetica,sans-serif;font-size:small;color:rgb(34,34,34)">I didn't encou= nter any errors in the processing, although I understand that this doesn= 9;t mean that it would always work.</span></pre><pre style=3D"font-family:M= enlo;font-size:9pt"><span style=3D"color:rgb(34,34,34);font-family:Arial,He= lvetica,sans-serif;font-size:small">So it does seem that for maps/arrays co= ntaining XML, the embedded XML configurations are not checked for compatibi= lity with the processor's configuration.</span><br></pre><pre style=3D"= font-family:Menlo;font-size:9pt"><span style=3D"color:rgb(34,34,34);font-fa= mily:Arial,Helvetica,sans-serif;font-size:small">I do think that I'm ge= tting somewhere. Thanks again for your help.</span></pre><pre style=3D"fon= t-family:Menlo;font-size:9pt">-alan</pre><pre style=3D"font-family:Menlo;fo= nt-size:9pt"><br></pre><pre style=3D"font-family:Menlo;font-size:9pt"><span= style=3D"font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(= 34,34,34)"><br></span></pre><pre style=3D"font-family:Menlo;font-size:9pt">= <span style=3D"font-family:Arial,Helvetica,sans-serif;font-size:small;color= :rgb(34,34,34)"><br></span></pre></div></div><br><div class=3D"gmail_quote"= ><div dir=3D"ltr" class=3D"gmail_attr">On Thu, Aug 5, 2021 at 12:41 AM Mich= ael Kay <<a href=3D"mailto:mike-JkSD5nQpfvpWk0Htik3J/[email protected]" target=3D"_blank">mike@sax= onica.com</a>> wrote:<br></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"><div><p class=3D"MsoNormal">Depends a bit wh= at you mean by =E2=80=9CJSON-oriented=E2=80=9D. Maps and arrays can of cour= se contain XDM nodes in their values (and I don=E2=80=99t think we always c= heck that these belong to the right Configuration when supplied via externa= l APIs, in the same way that we check for nodes). Writing code that convert= s a map-containing-nodes from one Configuration to a map-containing-equival= ent-nodes from a different Configuration would be a pretty substantial unde= rtaking.</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=3D"MsoN= ormal">Sender.send() expects a Source object, and the JAXP Source interface= is very XML-biased.</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p c= lass=3D"MsoNormal">Michael Kay</p><p class=3D"MsoNormal">Saxonica</p><p cla= ss=3D"MsoNormal"><u></u>=C2=A0<u></u></p><div style=3D"border-right:none;bo= rder-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);pad= ding:3pt 0cm 0cm"><p class=3D"MsoNormal" style=3D"border:none;padding:0cm">= <b>From: </b><a href=3D"mailto:[email protected]" target=3D"_blank">Al= an Painter</a><br><b>Sent: </b>04 August 2021 22:33<br><b>To: </b><a href= =3D"mailto:[email protected]" target=3D"_blank">Mailing list= for the SAXON XSLT and XQuery processor</a><br><b>Subject: </b>Re: [saxon]= XdmValue objects returned from applyTemplates()</p></div><p class=3D"MsoNo= rmal"><u></u>=C2=A0<u></u></p><div><p class=3D"MsoNormal">I see that I was = too hasty in saying that it was "working" for me.</p><div><p clas= s=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p class=3D"MsoNormal">I= 'd like the XdmValue to be any arbitrary Xdm with un-annotated XML, map= s, arrays and atomics (no need for functions).=C2=A0=C2=A0</p></div><div><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><p cla= ss=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p class=3D"MsoNormal">= Would there be a way to send JSON-oriented XdmValue to Sender.send()?=C2=A0= =C2=A0</p></div><div><p class=3D"MsoNormal">(I'm thinking that a pure J= SON XdmValue wouldn't need to have its NamePool converted, but what abo= ut a mix of XML and maps/arrays?)</p></div><div><p class=3D"MsoNormal"><u><= /u>=C2=A0<u></u></p></div><div><p class=3D"MsoNormal">thanks again for any = help</p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><di= v><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div></div><p class=3D"Ms= oNormal"><u></u>=C2=A0<u></u></p><div><div><p class=3D"MsoNormal">On Wed, A= ug 4, 2021 at 10:12 PM Alan Painter <<a href=3D"mailto:alan.painter@gmai= l.com" target=3D"_blank">[email protected]</a>> wrote:</p></div><bl= ockquote style=3D"border-top:none;border-right:none;border-bottom:none;bord= er-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8p= t;margin-right:0cm"><div><p class=3D"MsoNormal">I'm finally getting aro= und to implementing something w.r.t. the pointers that you gave me, Michael= .</p><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p clas= s=3D"MsoNormal">My objective is to convert a given XdmValue so that it can = become the input for a Xslt30Transformer=C2=A0with a different NamePool fro= m the origin Xslt30Transformer.</p></div><div><p class=3D"MsoNormal"><u></u= >=C2=A0<u></u></p></div><div><p class=3D"MsoNormal">This seems to be workin= g for me.=C2=A0 I'm curious if this is OK and if there isn't a shor= ter way.</p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div= ><div><pre><b><span style=3D"font-size:9pt;font-family:Menlo,serif;color:na= vy">private </span></b><span style=3D"font-size:9pt;font-family:Menlo,serif= ">XdmValue convertXdmValueForXslt(</span><b><span style=3D"font-size:9pt;fo= nt-family:Menlo,serif;color:navy">final </span></b><span style=3D"font-size= :9pt;font-family:Menlo,serif">XdmValue toConvert, </span><b><span style=3D"= font-size:9pt;font-family:Menlo,serif;color:navy">final </span></b><span st= yle=3D"font-size:9pt;font-family:Menlo,serif">Xslt30Transformer destination= Xslt) </span><b><span style=3D"font-size:9pt;font-family:Menlo,serif;color:= navy">throws </span></b><span style=3D"font-size:9pt;font-family:Menlo,seri= f">XPathException {<br>=C2=A0=C2=A0=C2=A0 </span><b><span style=3D"font-siz= e:9pt;font-family:Menlo,serif;color:navy">final </span></b><span style=3D"f= ont-size:9pt;font-family:Menlo,serif">RawDestination=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 rawDest=C2=A0 =3D </span><b><span style=3D"font-size:= 9pt;font-family:Menlo,serif;color:navy">new </span></b><span style=3D"font-= size:9pt;font-family:Menlo,serif">RawDestination();<br>=C2=A0=C2=A0=C2=A0 <= /span><b><span style=3D"font-size:9pt;font-family:Menlo,serif;color:navy">f= inal </span></b><span style=3D"font-size:9pt;font-family:Menlo,serif">Pipel= ineConfiguration pipe=C2=A0=C2=A0=C2=A0=C2=A0 =3D destinationXslt.getUnderl= yingController().makePipelineConfiguration();<br>=C2=A0=C2=A0=C2=A0 </span>= <b><span style=3D"font-size:9pt;font-family:Menlo,serif;color:navy">final <= /span></b><span style=3D"font-size:9pt;font-family:Menlo,serif">Receiver=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0receiver =3D rawDest.getReceiver(pipe, </span><b><span style=3D"font-siz= e:9pt;font-family:Menlo,serif;color:navy">null</span></b><span style=3D"fon= t-size:9pt;font-family:Menlo,serif">);<br><br>=C2=A0=C2=A0=C2=A0 Sender.<i>= send</i>((NodeInfo) toConvert.getUnderlyingValue(), receiver, </span><b><sp= an style=3D"font-size:9pt;font-family:Menlo,serif;color:navy">new </span></= b><span style=3D"font-size:9pt;font-family:Menlo,serif">ParseOptions());<br= ><br>=C2=A0=C2=A0=C2=A0 </span><b><span style=3D"font-size:9pt;font-family:= Menlo,serif;color:navy">return </span></b><span style=3D"font-size:9pt;font= -family:Menlo,serif">rawDest.getXdmValue();<br>}<u></u><u></u></span></pre>= </div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p cla= ss=3D"MsoNormal">Thanks again for the help</p></div><div><p class=3D"MsoNor= mal"><u></u>=C2=A0<u></u></p></div><div><p class=3D"MsoNormal">best regards= </p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p= class=3D"MsoNormal">-alan</p></div></div><p class=3D"MsoNormal"><u></u>=C2= =A0<u></u></p><div><div><p class=3D"MsoNormal">On Thu, Jul 15, 2021 at 1:18= AM Michael Kay <<a href=3D"mailto:[email protected]" target=3D"_bl= ank">[email protected]</a>> wrote:</p></div></div></blockquote></di= v><p class=3D"MsoNormal" style=3D"margin-left:9.6pt">>I'm wondering = what the drawbacks would be for re-using a same Processor by a (potentially= ) large number of Xslt30Transformers in parallel. <br><br>For most cases, n= one.<br><br>Potentially you could hit limits on the number of names allowed= in a NamePool. In practice we never see people hitting those limits.<br><b= r>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 tw= o different types with the same name - which could happen if you want to us= e two different versions of the same schema).<br><br>In general, you should= only create a single Processor unless you have clear reasons to do otherwi= se.<br><br>There is in fact a low-level mechanism to copy an XdmNode owned = by one Processor to a different Processor: it's the NamePoolConverter c= lass, used by the method Sender.sendDocumentInfo(). But it's not expose= d in a convenient way at the s9api interface.<br><br>Michael Kay<br>Saxonic= a<br><br><br><br><br>_______________________________________________<br>sax= on-help mailing list archived at <a href=3D"http://saxon.markmail.org/" tar= get=3D"_blank">http://saxon.markmail.org/</a><br><a href=3D"mailto:saxon-he= [email protected]" target=3D"_blank">[email protected]= t</a><br><a href=3D"https://lists.sourceforge.net/lists/listinfo/saxon-help= " target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/saxon-help= </a> </p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div></div>_______= ________________________________________<br> saxon-help mailing list archived at <a href=3D"http://saxon.markmail.org/" = rel=3D"noreferrer" target=3D"_blank">http://saxon.markmail.org/</a><br> <a href=3D"mailto:[email protected]" target=3D"_blank">saxon= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/saxon-help" rel=3D"= noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/= saxon-help</a> </blockquote></div> _______________________________________________<br>saxon-help mailing list = archived at <a href=3D"http://saxon.markmail.org/" target=3D"_blank">http:/= /saxon.markmail.org/</a><br><a href=3D"mailto:[email protected]= net" target=3D"_blank">[email protected]</a><br><a href=3D"h= ttps://lists.sourceforge.net/lists/listinfo/saxon-help" target=3D"_blank">h= ttps://lists.sourceforge.net/lists/listinfo/saxon-help</a> </div></blockquo= te></div><br></div></div>_______________________________________________<br= > saxon-help mailing list archived at <a href=3D"http://saxon.markmail.org/" = rel=3D"noreferrer" target=3D"_blank">http://saxon.markmail.org/</a><br> <a href=3D"mailto:[email protected]" target=3D"_blank">saxon= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/saxon-help" rel=3D"= noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/= saxon-help</a> </blockquote></div> --000000000000cd788d05c8ffb4f4-- --===============7066007300136544797== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============7066007300136544797== 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 --===============7066007300136544797==--