You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by pedrosacosta <pe...@netcabo.pt> on 2005/06/06 01:45:18 UTC

xsp question

Hi, i hope this is the place to send my xsp doubt.

I've difficulty to understand what's wrong with my xsp code, and i already looked to the documentation of the xsp, in the net and in a book. But, i still have the problem. this is my xsp file:

<?xml version="1.0"?>
 
<xsp:page language="java"                                       xmlns:xsp="http://apache.org/xsp"
                                        xmlns:xsp-request="http://apache.org/xsp/request/2.0">

<xsp:logic>
        StringBuffer buf = new StringBuffer();
        CharSequence sampleText="abcdeabcde";
        String sampleRegex="abc";
        java.util.regex.Pattern p = java.util.regex.Pattern.compile(sampleRegex);
        java.util.regex.Matcher m = p.matcher(sampleText);

        while(m.find()){
                String replaceStr = m.group();
 
                replaceStr = replaceStr.toUpperCase();
 
                m.appendReplacement(buf, replaceStr);
        }
        m.appendTail(buf);
        String result = buf.toString();
</xsp:logic>
 
<xsp:expr>result</xsp:expr>
</xsp:page>

The purpose of my code is to replace the string abcdeabcde with ABCdeABCde.

The code is correct, because i've already tested. But, when i run this code it appears:


org.apache.cocoon.ProcessingException: Language Exception: org.apache.cocoon.components.language.LanguageException: Error compiling SimpleRegexTest_xsp: ERROR 1 (org/apache/cocoon/www/samples/simpleform/projecto2/SimpleRegexTest_xsp.java): ... StringBuffer buf = new StringBuffer(); CharSequence sampleText="abcdeabcde"; String sampleRegex="abc"; java.util.regex.Pattern p = java.util.regex.Pattern.compile(sampleRegex); // start error (lines 67-67) "Syntax error on token ";", { expected after this token" java.util.regex.Matcher m = p.matcher(sampleText); // end error while(m.find()){ String replaceStr = m.group(); ... ERROR 2 (org/apache/cocoon/www/samples/simpleform/projecto2/SimpleRegexTest_xsp.java): ... String sampleRegex="abc"; java.util.regex.Pattern p = java.util.regex.Pattern.compile(sampleRegex); java.util.regex.Matcher m = p.matcher(sampleText); // start error (lines 69-69) "Syntax error on token(s), misplaced construct(s)" while(m.find()){ // end error String replaceStr = m.group(); replaceStr = replaceStr.toUpperCase(); ... Line 67, column 0: Syntax error on token ";", { expected after this token Line 69, column 0: Syntax error on token(s), misplaced construct(s)


I don't know what to do to this work properly. Can you help me?

My sitemap is:

<map:match pattern="test">
  <map:generate src="SimpleRegexTest.xsp" type="serverpages"/>
  <map:serialize type="html"/>
</map:match>



My second question is:

My final objective to do with this file is, to get a sequence of characters that was passed in url, by http GET, and do the replace. My only question is, how to get the sequence that is passes by url.
Example of url:
http://localhost:8888/samples/simpleform/projecto2/sequence?seq=%0AMKFLILLFNILCLF%0A

I've already looked at hello-world example that comes in cocoon documents, and put my xsp file in a xsl file, and created other xsp file like the greeting.xsp. But the problem is the same, as the described above.

what should i do?

Thanks.



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


Re: xsp question

Posted by Mark Leicester <ma...@efurbishment.com>.
Hello,

I think you need to add a root element to your XSP, and move your  
xsp:logic tag inside it, i.e.
<xsp:page>
<anyTag>
<xsp:logic>
...
</xsp:logic>
</anyTag>
</xsp:page>

Without the < anyTag >, your xsp logic is currently being compiled at  
class level (and not in the generation method). You can see that your  
output won't be XML without this tag. You can choose any tag you like,  
but you need to have one.

HTH,
Mark

On 6 Jun 2005, at 10:33, Carlos M. S. Bento Nogueira wrote:

> Oi :)
> Try adding to your xml header this : encoding="ISO-8859-1" ?>
> It might do the trick.
>
> Greetings,
> CarlosN.
>
> On Mon, 6 Jun 2005, pedrosacosta wrote:
>
>> Hi, i hope this is the place to send my xsp doubt.
>>
>> I've difficulty to understand what's wrong with my xsp code, and i  
>> already looked to the documentation of the xsp, in the net and in a  
>> book. But, i still have the problem. this is my xsp file:
>>
>> <?xml version="1.0"?>
>>
>> <xsp:page language="java"                                        
>> xmlns:xsp="http://apache.org/xsp"
>>                                         
>> xmlns:xsp-request="http://apache.org/xsp/request/2.0">
>>
>> <xsp:logic>
>>        StringBuffer buf = new StringBuffer();
>>        CharSequence sampleText="abcdeabcde";
>>        String sampleRegex="abc";
>>        java.util.regex.Pattern p =  
>> java.util.regex.Pattern.compile(sampleRegex);
>>        java.util.regex.Matcher m = p.matcher(sampleText);
>>
>>        while(m.find()){
>>                String replaceStr = m.group();
>>
>>                replaceStr = replaceStr.toUpperCase();
>>
>>                m.appendReplacement(buf, replaceStr);
>>        }
>>        m.appendTail(buf);
>>        String result = buf.toString();
>> </xsp:logic>
>>
>> <xsp:expr>result</xsp:expr>
>> </xsp:page>
>>
>> The purpose of my code is to replace the string abcdeabcde with  
>> ABCdeABCde.
>>
>> The code is correct, because i've already tested. But, when i run  
>> this code it appears:
>>
>>
>> org.apache.cocoon.ProcessingException: Language Exception:  
>> org.apache.cocoon.components.language.LanguageException: Error  
>> compiling SimpleRegexTest_xsp: ERROR 1  
>> (org/apache/cocoon/www/samples/simpleform/projecto2/ 
>> SimpleRegexTest_xsp.java): ... StringBuffer buf = new StringBuffer();  
>> CharSequence sampleText="abcdeabcde"; String sampleRegex="abc";  
>> java.util.regex.Pattern p =  
>> java.util.regex.Pattern.compile(sampleRegex); // start error (lines  
>> 67-67) "Syntax error on token ";", { expected after this token"  
>> java.util.regex.Matcher m = p.matcher(sampleText); // end error  
>> while(m.find()){ String replaceStr = m.group(); ... ERROR 2  
>> (org/apache/cocoon/www/samples/simpleform/projecto2/ 
>> SimpleRegexTest_xsp.java): ... String sampleRegex="abc";  
>> java.util.regex.Pattern p =  
>> java.util.regex.Pattern.compile(sampleRegex); java.util.regex.Matcher  
>> m = p.matcher(sampleText); // start error (lines 69-69) "Syntax error  
>> on token(s), misplaced construct(s)" while(m.find()){ // end error  
>> String repla!
> ceStr = m.group(); replaceStr = replaceStr.toUpperCase(); ... Line 67,  
> column 0: Syntax error on token ";", { expected after this token Line  
> 69, column 0: Syntax error on token(s), misplaced construct(s)
>>
>>
>> I don't know what to do to this work properly. Can you help me?
>>
>> My sitemap is:
>>
>> <map:match pattern="test">
>>  <map:generate src="SimpleRegexTest.xsp" type="serverpages"/>
>>  <map:serialize type="html"/>
>> </map:match>
>>
>>
>>
>> My second question is:
>>
>> My final objective to do with this file is, to get a sequence of  
>> characters that was passed in url, by http GET, and do the replace.  
>> My only question is, how to get the sequence that is passes by url.
>> Example of url:
>> http://localhost:8888/samples/simpleform/projecto2/sequence? 
>> seq=%0AMKFLILLFNILCLF%0A
>>
>> I've already looked at hello-world example that comes in cocoon  
>> documents, and put my xsp file in a xsl file, and created other xsp  
>> file like the greeting.xsp. But the problem is the same, as the  
>> described above.
>>
>> what should i do?
>>
>> Thanks.
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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


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


Re: xsp question

Posted by "Carlos M. S. Bento Nogueira" <cm...@student.dei.uc.pt>.
Oi :)
Try adding to your xml header this : encoding="ISO-8859-1" ?>
It might do the trick.

Greetings,
CarlosN.

On Mon, 6 Jun 2005, pedrosacosta wrote:

> Hi, i hope this is the place to send my xsp doubt.
>
> I've difficulty to understand what's wrong with my xsp code, and i already looked to the documentation of the xsp, in the net and in a book. But, i still have the problem. this is my xsp file:
>
> <?xml version="1.0"?>
>
> <xsp:page language="java"                                       xmlns:xsp="http://apache.org/xsp"
>                                        xmlns:xsp-request="http://apache.org/xsp/request/2.0">
>
> <xsp:logic>
>        StringBuffer buf = new StringBuffer();
>        CharSequence sampleText="abcdeabcde";
>        String sampleRegex="abc";
>        java.util.regex.Pattern p = java.util.regex.Pattern.compile(sampleRegex);
>        java.util.regex.Matcher m = p.matcher(sampleText);
>
>        while(m.find()){
>                String replaceStr = m.group();
>
>                replaceStr = replaceStr.toUpperCase();
>
>                m.appendReplacement(buf, replaceStr);
>        }
>        m.appendTail(buf);
>        String result = buf.toString();
> </xsp:logic>
>
> <xsp:expr>result</xsp:expr>
> </xsp:page>
>
> The purpose of my code is to replace the string abcdeabcde with ABCdeABCde.
>
> The code is correct, because i've already tested. But, when i run this code it appears:
>
>
> org.apache.cocoon.ProcessingException: Language Exception: org.apache.cocoon.components.language.LanguageException: Error compiling SimpleRegexTest_xsp: ERROR 1 (org/apache/cocoon/www/samples/simpleform/projecto2/SimpleRegexTest_xsp.java): ... StringBuffer buf = new StringBuffer(); CharSequence sampleText="abcdeabcde"; String sampleRegex="abc"; java.util.regex.Pattern p = java.util.regex.Pattern.compile(sampleRegex); // start error (lines 67-67) "Syntax error on token ";", { expected after this token" java.util.regex.Matcher m = p.matcher(sampleText); // end error while(m.find()){ String replaceStr = m.group(); ... ERROR 2 (org/apache/cocoon/www/samples/simpleform/projecto2/SimpleRegexTest_xsp.java): ... String sampleRegex="abc"; java.util.regex.Pattern p = java.util.regex.Pattern.compile(sampleRegex); java.util.regex.Matcher m = p.matcher(sampleText); // start error (lines 69-69) "Syntax error on token(s), misplaced construct(s)" while(m.find()){ // end error String repla!
 ceStr = m.group(); replaceStr = replaceStr.toUpperCase(); ... Line 67, column 0: Syntax error on token ";", { expected after this token Line 69, column 0: Syntax error on token(s), misplaced construct(s)
>
>
> I don't know what to do to this work properly. Can you help me?
>
> My sitemap is:
>
> <map:match pattern="test">
>  <map:generate src="SimpleRegexTest.xsp" type="serverpages"/>
>  <map:serialize type="html"/>
> </map:match>
>
>
>
> My second question is:
>
> My final objective to do with this file is, to get a sequence of characters that was passed in url, by http GET, and do the replace. My only question is, how to get the sequence that is passes by url.
> Example of url:
> http://localhost:8888/samples/simpleform/projecto2/sequence?seq=%0AMKFLILLFNILCLF%0A
>
> I've already looked at hello-world example that comes in cocoon documents, and put my xsp file in a xsl file, and created other xsp file like the greeting.xsp. But the problem is the same, as the described above.
>
> what should i do?
>
> Thanks.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

--