Re: [2.1] cinclude using a pipeline as a generator source

2016-05-10 Thread Nico Verwer

On 7-5-2016 15:10, Christopher Schultz wrote:

On 5/7/16 7:38 AM, warrell harries wrote:

cocoon:// is understood as standard

Awesome. I was hoping it would be something simple like that.

You can use something like

src="cocoon://{normalize-path:{request:sitemapURIPrefix}../somewhere/else}/whatever.xml"/>


The RequestModule is standard, and the NormalizePathInputModule comes 
from this project .

Doing this will make you project "relocatable" relative to the sitemap root.
This works in Cocoon 2.1, which for me is still preferable over 2.2 or 3.

It is good to see that people are still using Cocoon (2.1)!

Best regards,
Nico


Re: jars in Cocoon 2.1

2012-07-17 Thread Nico Verwer

On 17-7-2012 2:38, Huib Verweij wrote:

Hi Peter,

did you see this earlier discussion about using FOP 0.9x?

http://comments.gmane.org/gmane.text.xml.cocoon.user/62898

It might work the same for v1.0.


I have had some success using FOP 1.0, using the Cocoon 2.1.12 
development branch.


Download FOP-1.0 from http://xmlgraphics.apache.org/fop/download.html

Update jars in %COCOON_HOME%\lib\*:
-replace %COCOON_HOME%\lib\optional\batik-all-1.6.jar with 
%FOP_HOME%\lib\batik-all-1.7.jar
-replace %COCOON_HOME%\lib\optional\fop-0.95.jar with 
%FOP_HOME%\build\fop.jar
-replace %COCOON_HOME%\lib\optional\xmlgraphics-commons-1.3.1.jar 
with %FOP_HOME%\lib\xmlgraphics-commons-1.4.jar

-copy %FOP_HOME%\lib\serializer-2.7.0.jar to %COCOON_HOME%\lib\optional
-copy %FOP_HOME%\lib\xml-apis-ext-1.3.04.jar to 
%COCOON_HOME%\lib\endorsed


Update references to these jars in %COCOON_HOME%\lib\jars.xml 
(https://issues.apache.org/jira/secure/attachment/12450490/jars.patch)

* %COCOON_HOME%\lib\optional\batik-all-1.7.jar
* %COCOON_HOME%\lib\optional\fop.jar
- %COCOON_HOME%\lib\optional\xmlgraphics-commons-1.4.jar
- %COCOON_HOME%\lib\optional\serializer-2.7.0.jar
* %COCOON_HOME%\lib\endorsed\xml-apis-ext-1.3.04.jar

Build Cocoon

This was some time ago, but I think it worked this way.

Good luck!
Nico


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



Re: Cocoon Sparql Transformer ?

2008-03-03 Thread Nico Verwer
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 codequery/code in the 
namespace http://apache.org/cocoon/sparql/1.0;.

* These elements must not be nested.
* The codesrc/code attribute contains the url which points to a 
SPARQL endpoint.
* The optional codemethod/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 codequery/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/Person17846 .
* }
*   ]]
*   /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);
   }
 }

}

begin:vcard
fn:Nico Verwer
n:Verwer;Nico
email;internet:[EMAIL PROTECTED]
tel;work:+31 6 29546405
version:2.1

Re: cinclude a request to a sparql endpoint, character escaping

2007-09-25 Thread Nico Verwer
There was a small error in the Java code in my previous message. Line 
113 should be:

 SourceUtil.toSAX(source, this.xmlConsumer, typeParameters, true);


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cinclude a request to a sparql endpoint, character escaping

2007-09-21 Thread Nico Verwer

Al Brown wrote:
I'm trying to use cinclude to include the response from a jena-joseki 
rdf server sparql endpoint.

This requires that I send a query string with stuff like:

PREFIX dc:  http://purl.org/dc/elements/1.1/

in it.
I'm using the cinclude:includexml form and I can not figure out how to 
get the  character into the url.

I have tried cinclude:value![CDATA[ .. ]]/cinclude:value
and I have tried lt;

in both cases the extra encoding stuff get in and not the %3c which is 
what I need.


What am I doing wrong? 
The cinclude transformer makes your parameter into serialized XML 
(URI-encoded) when it sends this parameter.
The serialization process will see a CDATA event in the SAX stream 
(which is recorded inside cinclude), and decides that the best way to 
serialize this is to output ![CDATA[ etcetera.


So you don't want the parameter to be sent as serialized XML. But that 
is what cinclude:includexml does. It is great for sending XML documents, 
but not so great for sending SPARQL queries.


I am looking at the same problem at the moment, and triied several 
things (like the IncludeTransformer). My next attempt will be to build a 
SPARQLTransformer. When it is ready, I'll let you know.


Best regards,
Nico Verwer

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cinclude a request to a sparql endpoint, character escaping

2007-09-21 Thread Nico Verwer

Nico Verwer wrote:
I am looking at the same problem at the moment, and triied several 
things (like the IncludeTransformer). My next attempt will be to build 
a SPARQLTransformer. When it is ready, I'll let you know.
I think the following code works. Please try it, and let me know if it 
works.


The Java 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 codequery/code in the 
namespace http://apache.org/cocoon/sparql/1.0;.

* These elements must not be nested.
* The codesrc/code attribute contains the url which points to a 
SPARQL endpoint.
* The optional codemethod/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 codequery/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/Person17846 .
* }
*   ]]
*   /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);
   }
 }

}


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail

RE: http headers

2007-08-27 Thread Nico Verwer
Franco Pace writes:
 

How about setting the http response code from an action or 
transformer?
The reason I ask is that I would like to use cocoon as a REST 
server
framework.

This is also possible, see 
http://wiki.apache.org/cocoon/ResponseHeaderTransformer.

Cheers, Nico

winmail.dat-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

RE: accessing uri-prefix from within a sub-sitemap

2007-01-25 Thread Nico Verwer
Stephen Winnall wrote:

I'd like to reuse a sub-sitemap for a number of different uri-
prefixes. I can set this up in the main sitemap as follows:

map:match pattern=^(company|consulting|translation|research|
support)(.*)$ type=regexp
map:mount check-reload=yes src=design/area/sitemap.xmap 
uri-
prefix={1} /
/map:match

Is there a way in the sub-sitemap (design/area/sitemap.xmap) of 
accessing the uri-prefix that was used in its invocation?

There is, via the request input module: {request:sitemapURIPrefix} .

winmail.dat-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

RE: relative paths in flowscript [was: realpath: doesn't return realpath]

2007-01-18 Thread Nico Verwer
Steven D. Majewski wrote:


Looking for an alternative way of solving my problem:

   What is the working directory for a flowscript ?

If it's based on the directory of the script or the sitemap,
then I can probably just construct a relative path.


I wrote an input module for this, which might help. See 
http://wiki.apache.org/cocoon/SitemapPathModule .
The version on the wiki is not up-to-date, so I will update the code in the 
attachment.
 
Best regards,
Nico
 
winmail.dat-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

RE: Pipeline testing

2006-06-14 Thread Nico Verwer
Roberto Manicardi wrote:

I'm now trying to find how to test a single pipeline without 
using HtmlUnit. The requirement to use HtmlUnit is to have a webapp up and 
running in an application/servlet container. I would like to test a pipeline 
without doing any deploy of the webapp. What  I need is a testing framework 
that create a mock cocoon context in which I can run my pipeline

A while ago I wrote 
[http://wiki.apache.org/cocoon/UnitTestingStylesheetsAndPipelines], and 
[http://new.cocoondev.org/main/117/104.html]. Since then, I have moved on to 
other projects, but I still intend to work on the CoUnit unit-test framework 
when I have time. This might be of use to you.
 
Best regards,
Nico Verwer
winmail.dat-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: how to save results to disk?

2006-03-28 Thread Nico Verwer

Paula Estrella wrote:

Hi, I'm developing a small application with cocoon 2.1.8 under windows 
and I'd like to know if it's possible to store (server side) a 
dinamically generated xml document, i.e. I genrate a document 
result.xml with some input from users and I want to perform some 
action to store this document in the server as user-result.xml

Any ideas how I could do this?


Have a look at the SourceWritingTransformer 
(http://cocoon.apache.org/2.1/userdocs/sourcewriting-transformer.html). 
This will do what you want.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: {realpath:xxx} and mount-table

2005-11-27 Thread Nico Verwer

Jean-Claude Moissinac wrote:


So, is there a simple way to know the directory of a sitemap?


There is, see http://wiki.apache.org/cocoon/SitemapPathModule?action=show
Regards, Nico Verwer

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Status-code from sitemap

2005-11-17 Thread Nico Verwer




Upayavira wrote:

  Felix Rthenbacher wrote:
  
  
Hi

Is it possible to send a status code only from the sitemap?
For example to send 204 back after a put request?

  
  I believe serializers can do that. Look in the provided sitemaps within
the map:handle-errors code for examples.
  

Another way, which works a bit differently, is described in
http://wiki.apache.org/cocoon/ResponseHeaderTransformer

Cheers, Nico