Saxon extension function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Saxon extension function

Sindhya Kumari
Hi,

I have created a saxon extension functions using the integrated extension function. Some of the extension functions return a string value and some return a node sequence (net.sf.saxon.type.SequenceType.NODE_SEQUENCE). In case of functions that return node sequence I don't know how to wrap the string result to a node and create a XdmNode.
For example:
The following code is to create a XdmItem from a string value.

XdmItem resultItem = new XdmAtomicValue((String) (result));

Can you please tell me how to create a XdmNode from a string or if there is any other way to create a node and return the result as a node.

Thanks in advance.!

--
Thanks and Regards
Sindhya Kumari N

------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Saxon extension function

Michael Kay
Does the string contain lexical xml that needs to be parsed? In that case you need to call Configuration.buildDocument() to parse it. This returns a DocumentInfo. DocumentInfo implements NodeInfo which implements Item which implements Sequence, so you should be able to return it directly.

However, constructing lexical XML and parsing it is not the best way to create a node. Frankly, it’s much easier to create nodes in XSLT than in Java. The best way of doing it in Java rather depends on how complex it is and where the data is coming from.

Michael Kay
Saxonica

> On 4 Jun 2015, at 06:32, Sindhya Kumari <[hidden email]> wrote:
>
> Hi,
>
> I have created a saxon extension functions using the integrated extension function. Some of the extension functions return a string value and some return a node sequence (net.sf.saxon.type.SequenceType.NODE_SEQUENCE). In case of functions that return node sequence I don't know how to wrap the string result to a node and create a XdmNode.
> For example:
> The following code is to create a XdmItem from a string value.
>
> XdmItem resultItem = new XdmAtomicValue((String) (result));
>
> Can you please tell me how to create a XdmNode from a string or if there is any other way to create a node and return the result as a node.
>
> Thanks in advance.!
>
> --
> Thanks and Regards
> Sindhya Kumari N
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


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