You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Chabot Bernard <be...@pcotech.fr> on 2008/02/26 15:08:05 UTC

Re: Cocoon Sparql Transformer ?

Hello Kjetil,

In fact, I have some RDF triples in a Sesame repository.
I want treat some of those triples in a sort of "semantic pipe" (
http://pipes.deri.org/) with cocoon
So I'm looking for a Sparql Cocoon Transformer both to extract triples with
a SELECT query ...
... or to build others triples tith a CONSTRUCT query ...
... to be able to send this result to a XSLT transformer for exemple ...
... and then produce some Web Page

Regards,

Bernard

On Tue, Feb 26, 2008 at 2:54 PM, Kjetil Kjernsmo <
Kjetil.Kjernsmo@computas.com> wrote:

> On Tuesday 26 February 2008 13:59:55 Chabot Bernard wrote:
> > Is there any Sparql Transformer to handle xml-rdf document ?
>
> We're doing some work in that area, but the answer to that question
> depends on
> what you want to achieve. Do you want to take RDF/XML-data, parse it, then
> do
> a SPARQL SELECT query on it to get the SPARQL Result set, or a DESCRIBE or
> CONSTRUCT query to get more RDF/XML, or something completely different?
>
>
> Kind regards
>
> Kjetil Kjernsmo
> --
> Senior Knowledge Engineer
> Direct: +47 6783 1136 | Mobile: +47 986 48 234
> Email: kjetil.kjernsmo@computas.com
> Web: http://www.computas.com/
>
> |  SHARE YOUR KNOWLEDGE  |
>
> Computas AS  Vollsveien 9, PO Box 482, N-1327 Lysaker | Phone:+47 6783
> 1000 |
> Fax:+47 6783 1001
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: Cocoon Sparql Transformer ?

Posted by Chabot Bernard <be...@pcotech.fr>.
Thank you very much Nico, that's exacly what I'm looking for ...
Bernard

On Tue, Feb 26, 2008 at 4:53 PM, netBrackets <je...@mac.com> wrote:

> Hello,
>   We've built just such an engine complete with a model integration
> framework here at Boeing.  Works great, but don't think I'll be at liberty
> to "release it into the wild" anytime soon.  Would love to present it at a
> conference, but the boss won't even allow that.
>
> Jeff
>
>
> On Tuesday, February 26, 2008, at 09:45AM, "Kjetil Kjernsmo" <
> Kjetil.Kjernsmo@computas.com> wrote:
> >On Tuesday 26 February 2008 15:08:05 Chabot Bernard wrote:
> >> In fact, I have some RDF triples in a Sesame repository.
> >> I want treat some of those triples in a sort of "semantic pipe" (
> >> http://pipes.deri.org/) with cocoon
> >> So I'm looking for a Sparql Cocoon Transformer both to extract triples
> with
> >> a SELECT query ...
> >
> >Actually, that's a good idea, I've been thinking along those lines, but
> >without coming to the conclusion that this was the way to do it. If
> someone
> >else has done the experimentation (and DERI is one of the formost in this
> >field).
> >
> >> ... or to build others triples tith a CONSTRUCT query ...
> >> ... to be able to send this result to a XSLT transformer for exemple
> ...
> >> ... and then produce some Web Page
> >
> >Yup, it would be a nice thing to have. We haven't done it, though. I
> would be
> >interested in hearing more about it if it comes to existence, and it is
> not
> >unthinkable that we will do it and release it at some point, but not
> >yet... :-) (We're working on a Semantic Web project for libraries in
> Norway,
> >based on Cocoon and SPARQL).
> >
> >Kind regards
> >
> >Kjetil Kjernsmo
> >--
> >Senior Knowledge Engineer
> >Direct: +47 6783 1136 | Mobile: +47 986 48 234
> >Email: kjetil.kjernsmo@computas.com
> >Web: http://www.computas.com/
> >
> >|  SHARE YOUR KNOWLEDGE  |
> >
> >Computas AS  Vollsveien 9, PO Box 482, N-1327 Lysaker | Phone:+47 6783
> 1000 |
> >Fax:+47 6783 1001
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: Cocoon Sparql Transformer ?

Posted by netBrackets <je...@mac.com>.
Hello,
   We've built just such an engine complete with a model integration framework here at Boeing.  Works great, but don't think I'll be at liberty to "release it into the wild" anytime soon.  Would love to present it at a conference, but the boss won't even allow that.

Jeff

 
On Tuesday, February 26, 2008, at 09:45AM, "Kjetil Kjernsmo" <Kj...@computas.com> wrote:
>On Tuesday 26 February 2008 15:08:05 Chabot Bernard wrote:
>> In fact, I have some RDF triples in a Sesame repository.
>> I want treat some of those triples in a sort of "semantic pipe" (
>> http://pipes.deri.org/) with cocoon
>> So I'm looking for a Sparql Cocoon Transformer both to extract triples with
>> a SELECT query ...
>
>Actually, that's a good idea, I've been thinking along those lines, but 
>without coming to the conclusion that this was the way to do it. If someone 
>else has done the experimentation (and DERI is one of the formost in this 
>field).
>
>> ... or to build others triples tith a CONSTRUCT query ...
>> ... to be able to send this result to a XSLT transformer for exemple ...
>> ... and then produce some Web Page
>
>Yup, it would be a nice thing to have. We haven't done it, though. I would be 
>interested in hearing more about it if it comes to existence, and it is not 
>unthinkable that we will do it and release it at some point, but not 
>yet... :-) (We're working on a Semantic Web project for libraries in Norway, 
>based on Cocoon and SPARQL).
>
>Kind regards 
>
>Kjetil Kjernsmo
>-- 
>Senior Knowledge Engineer
>Direct: +47 6783 1136 | Mobile: +47 986 48 234
>Email: kjetil.kjernsmo@computas.com   
>Web: http://www.computas.com/
>
>|  SHARE YOUR KNOWLEDGE  |
>
>Computas AS  Vollsveien 9, PO Box 482, N-1327 Lysaker | Phone:+47 6783 1000 | 
>Fax:+47 6783 1001
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon Sparql Transformer ?

Posted by Kjetil Kjernsmo <Kj...@computas.com>.
On Tuesday 26 February 2008 15:08:05 Chabot Bernard wrote:
> In fact, I have some RDF triples in a Sesame repository.
> I want treat some of those triples in a sort of "semantic pipe" (
> http://pipes.deri.org/) with cocoon
> So I'm looking for a Sparql Cocoon Transformer both to extract triples with
> a SELECT query ...

Actually, that's a good idea, I've been thinking along those lines, but 
without coming to the conclusion that this was the way to do it. If someone 
else has done the experimentation (and DERI is one of the formost in this 
field).

> ... or to build others triples tith a CONSTRUCT query ...
> ... to be able to send this result to a XSLT transformer for exemple ...
> ... and then produce some Web Page

Yup, it would be a nice thing to have. We haven't done it, though. I would be 
interested in hearing more about it if it comes to existence, and it is not 
unthinkable that we will do it and release it at some point, but not 
yet... :-) (We're working on a Semantic Web project for libraries in Norway, 
based on Cocoon and SPARQL).

Kind regards 

Kjetil Kjernsmo
-- 
Senior Knowledge Engineer
Direct: +47 6783 1136 | Mobile: +47 986 48 234
Email: kjetil.kjernsmo@computas.com   
Web: http://www.computas.com/

|  SHARE YOUR KNOWLEDGE  |

Computas AS  Vollsveien 9, PO Box 482, N-1327 Lysaker | Phone:+47 6783 1000 | 
Fax:+47 6783 1001


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon Sparql Transformer ?

Posted by Nico Verwer <nv...@be-value.nl>.
Some time ago, I made a simple SPARQL transformer. The code should be 
out there, somewher on the web, and you can also download it from my 
'cocooncomponents' project on Google code. I'll include the code below.
If this is useful, we might want to set up a project for semantic web 
components on cocoondev, or something similar?

--- code follows ---
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.cocoon.transformation;

import java.io.IOException;
import java.util.Map;

import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceParameters;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

/**
 *  * @cocoon.sitemap.component.documentation
 * This transformer triggers for the element <code>query</code> in the 
namespace "http://apache.org/cocoon/sparql/1.0".
 * These elements must not be nested.
 * The <code>src</code> attribute contains the url which points to a 
SPARQL endpoint.
 * The optional <code>method</code> attribute contains the HTTP method 
for the request (default is GET).
 * Attributes in the "http://apache.org/cocoon/sparql/1.0" namespace are 
used as request parameters (using the local name).
 * This allows for parameters such as 'format' or 'maxrows'.
 * The text of the content of the <code>query</code> element is passed 
as the value of the 'query' parameter.
 *
 * The XML input to this transformer would look like:
 * <pre>
 *   <sparql:query xmlns:sparql="http://apache.org/cocoon/sparql/1.0"
 *     method="POST" src="http://dbpedia.org/sparql"
 *     sparql:maxrows="25" sparql:format="XML"
 *   >
 *   <![CDATA[
 *     PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 *     SELECT *
 *     FROM <http://dbpedia.org>
 *     WHERE {
 *       ?person rdf:type <http://dbpedia.org/class/yago/Person100007846> .
 *     }
 *   ]]>
 *   </sparql:query>
 * </pre>
 *
 * @author Nico Verwer
 *
 */
public class SparqlTransformer extends AbstractSAXTransformer {
 
  public static final String SPARQL_NAMESPACE_URI = 
"http://apache.org/cocoon/sparql/1.0";
  public static final String QUERY_ELEMENT = "query";
  public static final String METHOD_ATTR = "method";
  public static final String SRC_ATTR = "src";
  public static final String QUERY_PARAM = "query";
 
  private boolean inQuery;
  private String src;
  private String method;
  private SourceParameters requestParameters;

  public SparqlTransformer() {
    this.defaultNamespaceURI = SPARQL_NAMESPACE_URI;
  }

  public void setup(SourceResolver resolver, Map objectModel, String src,
      Parameters params) throws ProcessingException, SAXException, 
IOException {
    super.setup(resolver, objectModel, src, params);
    inQuery = false;
  }

  public void startTransformingElement(String uri, String name, String 
raw, Attributes attr)
      throws ProcessingException, IOException, SAXException {
    if (name.equals(QUERY_ELEMENT)) {
      if (inQuery) {
        throw new ProcessingException("Nested SPARQL queries are not 
allowed.");
      }
      inQuery = true;
      src = attr.getValue(SRC_ATTR);
      method = attr.getValue(METHOD_ATTR);
      method = (method == null ? "GET" : method.toUpperCase());
      requestParameters = new SourceParameters();
      for (int i = 0; i < attr.getLength(); ++i) {
        if (attr.getURI(i).equals(SPARQL_NAMESPACE_URI)) {
          requestParameters.setParameter(attr.getLocalName(i), 
attr.getValue(i));
        }
      }
      startTextRecording();
    }
  }

  public void endTransformingElement(String uri, String name, String raw)
      throws ProcessingException, IOException, SAXException {
    if (name.equals(QUERY_ELEMENT)) {
      inQuery = false;
      String query = endTextRecording();
      requestParameters.setParameter(QUERY_PARAM, query);
      Parameters typeParameters = new Parameters();
      typeParameters.setParameter("method", method);
      Source source = SourceUtil.getSource(src, typeParameters, 
requestParameters, resolver);
      SourceUtil.toSAX(source, this.xmlConsumer, typeParameters, true);
    }
  }
 
}


Re: Cocoon Sparql Transformer ?

Posted by Chabot Bernard <be...@pcotech.fr>.
Hello David,

Well Fresnel is also a topic I'm looking with many interests ... especially
:
   - LONGWELL : http://simile.mit.edu/wiki/Longwell
   - LENA : http://isweb.uni-koblenz.de/Research/lena

Thanks for this new fresnel link (http://jfresnel.gforge.inria.fr/)

It seem I have to wait a little bit for a Cocoon intergration of such
features ;-)

Bernard

On Tue, Feb 26, 2008 at 6:18 PM, David Legg <da...@searchevent.co.uk>
wrote:

> Hi Bernard,
>
> > So I'm looking for a Sparql Cocoon Transformer both to extract triples
> > with a SELECT query ...
> > ... or to build others triples tith a CONSTRUCT query ...
> > ... to be able to send this result to a XSLT transformer for exemple ...
> > ... and then produce some Web Page
>
> I've toyed with this idea too.  You may want to check out Fresnel [1].
>
> When you think about it, RDF deals with graphs and graphs are difficult
> to manipulate with XPath (and hence XSLT) because XPath assumes the data
> is in the form of a tree.
>
> Fresnel is a bit like XSLT for RDF.  Given a set of instructions, some
> RDF data and a location in the RDF to be displayed it transforms some or
> all of the RDF into a DOM tree and then optionally formats the tree
> ready for display on a web page or further processing using XSLT.
>
> Now the question is... how to fit it into Cocoon in a modular way!
>
> David Legg.
>
> [1] http://jfresnel.gforge.inria.fr/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: Cocoon Sparql Transformer ?

Posted by David Legg <da...@searchevent.co.uk>.
Hi Bernard,

> So I'm looking for a Sparql Cocoon Transformer both to extract triples 
> with a SELECT query ...
> ... or to build others triples tith a CONSTRUCT query ...
> ... to be able to send this result to a XSLT transformer for exemple ...
> ... and then produce some Web Page

I've toyed with this idea too.  You may want to check out Fresnel [1].

When you think about it, RDF deals with graphs and graphs are difficult 
to manipulate with XPath (and hence XSLT) because XPath assumes the data 
is in the form of a tree.

Fresnel is a bit like XSLT for RDF.  Given a set of instructions, some 
RDF data and a location in the RDF to be displayed it transforms some or 
all of the RDF into a DOM tree and then optionally formats the tree 
ready for display on a web page or further processing using XSLT.

Now the question is... how to fit it into Cocoon in a modular way!

David Legg.

[1] http://jfresnel.gforge.inria.fr/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org