[xquery-talk] Base Xq and extend base to have subclass xqs

Ronald Bourret rpbourret at rpbourret.com
Fri Aug 26 14:14:26 PDT 2011


The short answer is that XQuery does not support subclassing.

One possible workaround is to create functions that do your mapping and 
use these in your "extended" queries. Depending on what you want to do, 
this may or may not work easily (or at all).

For more ideas, see the thread, "Extend and override" in:

    http://x-query.com/pipermail/talk/2011-August/thread.html

-- Ron

sudheshna iyer wrote:
> I have 200  elements in  one xsd. 
> I have to use this xsd to create 6 xquery maps. All of these xqs have 100 elements in common. 
> I want to create one xquery with 100 elements and call that in rest of the 5 xqueries. I don't want to copy the mappings from base xq to rest of 5 xqs.
> I want the functionality similar to java where we create a base class and extend it to create sub classes.
> eg: xsd with following elements: 
> In the eg below, 
> <Customer>
>  <Name>name1</Name>
>  <Phone>111-222-3333</Phone>
>  <Addresses>
>   <Address>
>    <AddressLn1>aa</AddressLn1>
>   </Address>
>  </Addresses>
>  <Payments>
>   <Number>111</Number>
>  </Payments>
> </Customer>
> 
> Base.xq: -> This will only take care of Name and Phone
> <Customer>
>  <Name>name1</Name>
>  <Phone>111-222-3333</Phone>
> </Customer>
> Sub xq: Extend Base and Add additional functionality
> Sub1.xq -> This will only take care of address mapping
> <Customer>
>  <Addresses>
>   <Address>
>    <AddressLn1>aa</AddressLn1>
>   </Address>
>  </Addresses>
> </Customer>
> Sub2.xq -> -> This will only take care of payment mapping
> <Customer>
>  <Payments>
>   <Number>111</Number>
>  </Payments>
> </Customer>
> Result:
> Base1.xq + Sub2.xq.xq + Sub1.xq
> <Customer>
>  <Name>name1</Name>
>  <Phone>111-222-3333</Phone>
>  <Addresses>
>   <Address>
>    <AddressLn1>aa</AddressLn1>
>   </Address>
>  </Addresses>
>  <Payments>
>   <Number>111</Number>
>  </Payments>
> </Customer>
> My question again is can we create subclass of base xquery to inherit the mappings that are already done in base query.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk


More information about the talk mailing list