Creating a sequence of XdmAtomicValue

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

Creating a sequence of XdmAtomicValue

cmarchand
Hello,

I want to create a sequence of XdmAtomicValue ; for example, this : (4,
5, 6) where 4, 5& 6 are xs:int.

XdmValue.append(XdmValue) does not change the size of the sequence.

How should I do ?

Thanks,
Christophe


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Creating a sequence of XdmAtomicValue

Michael Kay
You can use XdmValue.append() - just remember that it creates a new immutable XdmValue rather than modifying the one supplied as the argument. This also means that creating a value of size N this way has performance O(N^2).

This way you would do

XdmValue.wrap(new XdmAtomicValue(1)).append(new XdmAtomicValue(2)).append(new XdmAtomicValue(3)).

So you're probably better off using the constructor

public XdmValue(Iterable<? extends XdmItem> items)

which allows you to do

new XdmValue(Arrays.asList(new XdmAtomicValue[]{new XdmAtomicValue(1), new XdmAtomicValue(2), new XdmAtomicValue(3)}))

You can probably do something much smarter with Java 8 streams but I haven't really mastered that yet.

Michael Kay
Saxonica


> On 31 Mar 2017, at 10:39, Christophe Marchand <[hidden email]> wrote:
>
> Hello,
>
> I want to create a sequence of XdmAtomicValue ; for example, this : (4,
> 5, 6) where 4, 5& 6 are xs:int.
>
> XdmValue.append(XdmValue) does not change the size of the sequence.
>
> How should I do ?
>
> Thanks,
> Christophe
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Creating a sequence of XdmAtomicValue

cmarchand
Thanks a lot !

Christophe


Le 31/03/2017 à 12:17, Michael Kay a écrit :

> You can use XdmValue.append() - just remember that it creates a new immutable XdmValue rather than modifying the one supplied as the argument. This also means that creating a value of size N this way has performance O(N^2).
>
> This way you would do
>
> XdmValue.wrap(new XdmAtomicValue(1)).append(new XdmAtomicValue(2)).append(new XdmAtomicValue(3)).
>
> So you're probably better off using the constructor
>
> public XdmValue(Iterable<? extends XdmItem> items)
>
> which allows you to do
>
> new XdmValue(Arrays.asList(new XdmAtomicValue[]{new XdmAtomicValue(1), new XdmAtomicValue(2), new XdmAtomicValue(3)}))
>
> You can probably do something much smarter with Java 8 streams but I haven't really mastered that yet.
>
> Michael Kay
> Saxonica
>
>
>> On 31 Mar 2017, at 10:39, Christophe Marchand <[hidden email]> wrote:
>>
>> Hello,
>>
>> I want to create a sequence of XdmAtomicValue ; for example, this : (4,
>> 5, 6) where 4, 5& 6 are xs:int.
>>
>> XdmValue.append(XdmValue) does not change the size of the sequence.
>>
>> How should I do ?
>>
>> Thanks,
>> Christophe
>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help