Re: define views using xquery

MessageLET $p := document("spj.xml")//part[price > 100]
RETURN filter($p/../.. | $p/.. | $p//*)

BTW, what is your SQL equivalent for the example
you have given ?

NB: you can't code at the algebra layer and the surface syntax 
at the same time. I don't think the 2 grammars can co-exist without 
ambiguities.

combination of XML-Schema and XQuery is not a problem.
If you require your view function to return a typed result,
encapsulate it in a function.

rgds.
  ----- Original Message ----- 
  From: Chen Ya Bing 
  To: Peter Fankhauser 
  Cc: www-ql@w3.org 
  Sent: Monday, February 25, 2002 9:34 AM
  Subject: Re: define views using xquery


  one of the actual difficulties is like that:

  there is a XML document (spj.xml):
  <db>

    <project jno="j001">

      <supplier sno="s001">

          <part pno="p001">

             <price> 100</price>

          </part>

      </supplier>

      <supplier sno="s002">

          <part pno="p001">

              <price> 110</price>

          </part>

      </supplier>

    </project>

  </db>

   

  we want to define a view which selects such project, supplier and part that their sub element price is greater than 100.  the view definition may be:



  define view test as

  For      $j In document("spj.xml")//project[//price >100]

               Return 

                        <project jno = {$j/@jno}>

                          { For $s In $j/supplier[//price >100]

                             Return

                                    <supplier sno = {$s/@sno}> 

                                      { For $p In $s/part[price > 100]

                                         Return                          

                                           <part pno = {$p/@pno}> 

                                                 {$p/price} 

                                           </part>

                                       } 

                                    </supplier>

                          } 

                       </project>

   

  we can see that for such a simple view, we need to repeat the predicate "price >100" three times, which will lead to a very low performance of query processing, because we need to search the tree three times. the view definition is not only complex and wordy, but also low-performance.

  Is there any other way to write the query?

   

  as a view definition, one of favorite feature is that it is declarative, so that we don't need to write a very complex definition.

   

  can we just use a more simple way to write view, can XML Algebra provide any help?

   

  the view is just to put a predicate to filter some elements. if we define a view that change some structures, the view definition will be more complex.

   

  until now, we do not consider the problem of view updatability and the combination of XML-Schema and XQuery.

   

  Best regards,

   

    ----- Original Message ----- 
    From: Peter Fankhauser 
    To: 'Chen Ya Bing' ; www-ql@w3.org 
    Sent: Thursday, February 21, 2002 9:40 PM
    Subject: RE: define views using xquery


    As a starter from the scientific side you may check out
    some recent papers by Serge Abiteboul and others (one of
    Serge's favorite themes is views in all disguises).

    I'd be also be interested in the actual difficulties that you
    encountered when trying views with XQuery. In principle
    one can regard a view as a "stored" query which can be
    composed with other queries. As one of XQuery's virtues
    is compositionality, another is closure, so I wonder where exactly
    the difficulty lies.

    (1) Is it the combination of XML-Schema and XQuery that
    you (presumably) need.

    (2) Is it updatability of views that concern you?

    (3) Is it that your notion of "simple view" doesn't translate
    to an XQuery notion of a "simple query"?

    (4) Which sort of views do you want to define?

    Have you got any concrete examples, usecases, requirements?
    Where exactly do you encounter inefficiency?

    Best regards,

    Peter


      -----Original Message-----
      From: www-ql-request@w3.org [mailto:www-ql-request@w3.org] On Behalf Of Chen Ya Bing
      Sent: Donnerstag, 21. Februar 2002 10:02
      To: www-ql@w3.org
      Subject: define views using xquery


      I'd like to use XQuery as a view definition language to define XML views. but I find that it is difficult to use it as the view definition language, because a simple view definition have to lead to a complex XQuery. even more, it may be inefficient. comparing with view definition in SQL, it is inconvenient.

      can anybody give me advices of how to utilize XQuery to define XML view more efficiently?
      and how will the XQuery WD support the view facility.

      Best regards,
      Chen

Received on Monday, 25 February 2002 01:29:59 UTC