Hello Devs,
by reading that another Question crossed my mind:
Have you ever thought of giving XWiki also some semantic capabilities?
I mean the Idea of Semantic Wikis is not new:
In Xwiki you could just put a Link in a 2-tuple form for letting it
fulfil the "subject - predicate - object"-Association, with the Subject
as the Site where the link is set and the Object the Site where the link
is pointing to, so only the predicate is missing.
And sometimes I really think it could make Sense. Especially in Xwiki
where you could exploit Information stored that way directly via Scripts
  and Applications developed in XWiki itself.
Cheers and greetings
Jonas
Artem Melentyev wrote:
  Hi, devs.
 I would like to discuss about the new xwiki query language.
 
http://dev.xwiki.org/xwiki/bin/view/Design/XWikiQueryLanguage
 We need to choose a syntax and data model of the query language
 There are some examples in
 
http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificati…
 I already have a prototype based on my JPQL parser (SableCC based) and
 hql generator. It is quite easy to modify syntax and generator. Results
 of my query parser research in the end of the message.
 I propose:
 0) Name: XWiki Query Language, XWQL as a name of the new language.
 1) Data Model: Choose query method #1 from specification
 
http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificati…
 with corrections:
 add Document as a virtual class for our XWikiDocument.
 use "docalias.XWiki.ClassName instead" of "XWiki.ClassName". docalias
is
 some alias for Document.
 add optional select clause.
 example:
 "select doc.fullName
   from Document as doc, doc.XWiki.XWikiUsers as user
   where user.email like '%xwiki.com' and  doc.author=:username"
 "select doc.fullName from Document as doc" may be omitted. It will be
 added if there is no Document in query statement. So "from
 doc.XWiki.XWikiUsers as user" is correct query statement.
 It is possible to use several documents and objects in one query.
 Attachment, Class, and other xwiki entities will be added later if needed.
 2) Syntax: XWQL will be JPQL subset.
   (hint: JPQL is part of Java Persistance API standard, JSR#317. HQL is
 a superset of JPQL. Hibernate support JPA)
   All JPQL features and all hibernate data model will be accessible for
 hibernate store. But it is not true for JCR store.
   Only described data model will be available for XWQL on JCRStore. (But
 we may add some extensions later)
   In JCRv2 will not work (JCRSQL2 constraint):
    arithmetic expressions (+-*/)
    aggregation funtions (max,min,sum,avg)
    some other functions
   In JCRv1 also will not work (XPath constraint):
    query on several documents (from Document as doc1, Document as doc2)
   Some JPQL limitations compared with HQL:
    no arithmetic expressions (+-*/) in select clause
    aliases at from clause are mandatory (from Document as alias)
 So the main idea is to use simple JPQL preprocessor to rewrite virtual
 data model to real.
 This is quite easy for HQL and JCRSQL2. But it is hard(but doable) for
 JCRv1 XPath.
 WDYT?
 Appendix:
 I researched a many of query engines and found nothing appropriate. All
 query engines/parsers is either very specific or cannot be used
 standalone or cannot be used as a preprocessor. JCRSQL2 language parser
 from Jackrabbit is still unusable.
 Next I researched a parser generators and found that SableCC is best
 choose for my needs. Other tools (ANTLR, JavaCC, Cup, Beaver) requires
 much more hand work to write parse tree (AST) and preprocessors
 (Visitors and ast.toString). JTB and JJTree also generate AST and
 visitors, but SableCC generated code is much more clean.
 SableCC generate all of this from one clear grammar file. Maybe it is
 not as perfect as hand-written one, but it is quite suitable.
 Reason to choose sql-like syntax:
 XPath isn't still much spread. XPath language is deprecated in JCRv2.
 JCRv2 uses JCRSQL2 and criteria-like AQM instead. JCRSQL2 is much more
 powerful (in expression sense) than JCR's XPath and JCRSQL1.
 --
    Artem Melentyev
 _______________________________________________
 devs mailing list
 devs(a)xwiki.org
 
http://lists.xwiki.org/mailman/listinfo/devs