Re: Is there any easy way to provide XdmValue as a source for the standard XsltTransformer?

Michael Kay <[email protected]> Mon, 28 Jun 2021 17:10:30 +0100
Newsgroups gmane.text.xml.saxon.help
Message-ID <[email protected]>
This all looks terribly XSLT 1.0 focussed - not even sure where s9api concepts like XdmValue fit in, let alone JSON, as it's all JAXP based.

Good luck with this!

Michael Kay
Saxonica

> On 28 Jun 2021, at 14:14, Alan Painter <[email protected]> wrote:
> 
> I may have to go that route for continuing with the standard XsltTransformer.  Thanks for the advice.
> 
> For completeness, I'll mention that I'm trying to use this standard transformer component from Spring Integration:
> 
> https://docs.spring.io/spring-integration/docs/5.3.2.RELEASE/reference/html/xml.html#xml-xslt-payload-transformers <https://docs.spring.io/spring-integration/docs/5.3.2.RELEASE/reference/html/xml.html#xml-xslt-payload-transformers>
> 
> https://github.com/spring-projects/spring-integration/blob/5.3.x/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java <https://github.com/spring-projects/spring-integration/blob/5.3.x/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java>
> 
> It's instantiating a net.sf.saxon.TransformerFactory and then it assumes that the payload of the message is the source document, trying to convert it to a Source prior to invoking transform(), hence the problem.
> 
> The other option will be to create a custom component for instantiating the Xslt30Transformer and calling the applyTemplates(XdmValue, Destination) method.
> I'll probably go this route.
> 
> thanks again and best regards
> 
> On Mon, Jun 28, 2021 at 9:09 AM Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected] <mailto:mike-JkSD5nQpfvpWk0Htik3J/[email protected]>> wrote:
> If you can organise it so the XdmValue is passed as a stylesheet parameter, rather than as the initial context item / match selection, then there should be no problem using the XsltTransformer.
> 
> Michael Kay
> Saxonica
> 
>> On 27 Jun 2021, at 21:03, Alan Painter <[email protected] <mailto:[email protected]>> wrote:
>> 
>> Hi Michael,
>> 
>> In fact, that's the objective of this exercise, to avoid deserializing/reserializing from XdmValues that are the source/results of cascading transformations orchestrated within Spring Integration.  
>> 
>> Spring Integration has a message payload that is passed around within it.  I am shooting for an XdmValue message payload that can be transformed without serialization.
>> 
>> This may well mean that I must forego the XsltTransformer for the Xslt30Transformer, but I was hoping that there could be a simpler solution since there is already a lot of implementation dependency on XsltTransformer.
>> 
>> thanks for your help and best regards
>> 
>> -alan
>> 
>> 
>> 
>> 
>> On Sun, Jun 27, 2021 at 9:25 PM Michael Kay <[email protected] <mailto:[email protected]>> wrote:
>> If the XdmValue represents an XML node, then it will (probably) be an XdmNode, and the NodeInfo can be obtained using XdmNode.getUnderlyingValue().
>> 
>> However, if the XdmValue is an XdmMap or XdmArray (representing a JSON input), then the XsltTransformer isn't really set up for this. You would probably want to pass it in as a string-valued parameter and parse it from within the stylesheet.
>> 
>> Michael Kay
>> Saxonica
>> 
>> > On 27 Jun 2021, at 16:48, Alan Painter <[email protected] <mailto:[email protected]>> wrote:
>> > 
>> > Hello fellow XML knowledge workers,
>> > 
>> > I'm trying to reuse the implementations in Spring Integration that do XSLT transformations using the XsltTransformer.
>> > 
>> > I'd like to be able to pass an XdmValue as a source for transformations so that the source could be JSON or XML, writing output to a RawDestination or XdmDestination. I understand that this is possible using Xslt30Transformer, but since the tooling that I'd like to reuse is based upon the older XsltTransformer, I'm a bit stuck.
>> > 
>> > I see that it's possible to provide a NodeInfo source value.  Could it be relatively easy to have an XdmValue presented as NodeInfo?
>> > 
>> > thanks for any pointers and best regards
>> > 
>> > -alan
>> > 
>> > _______________________________________________
>> > 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/ <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/ <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/ <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

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