cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: Taglib-Block doesn't work? (Deprecated?)
Date Mon, 14 Jun 2004 07:15:14 GMT

the problem is a ClassCastException because the code was changed to use a
ServiceSelector, but the configuration uses a ExtendedComponentSelector. I
send you the diff what was changed. You can replace ServiceSelector back to
ComponentSelector and it will work again. It seam that there is no
ExtendedServiceSelector available.


Index: java/org/apache/cocoon/transformation/
RCS file:
retrieving revision 1.6
diff -u -r1.6
--- java/org/apache/cocoon/transformation/     5 Mar
2004 13:02:25 -0000     1.6
+++ java/org/apache/cocoon/transformation/     14 Jun
2004 06:26:55 -0000
@@ -28,6 +28,7 @@
 import org.apache.avalon.excalibur.pool.Recyclable;
 import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.component.ComponentSelector;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -194,7 +195,7 @@

         Tag tag = (Tag) tagStack.pop();
         if (tag != null) {
-            ServiceSelector tagSelector
= (ServiceSelector)tagSelectorStack.pop();
+            ComponentSelector tagSelector
= (ComponentSelector)tagSelectorStack.pop();
             try {
                 if (saxFragment != null) {
                     //start Iteration
@@ -315,7 +316,7 @@
             Tag tag = (Tag) tagStack.pop();
             if (tag == null)
-            ServiceSelector tagSelector
= (ServiceSelector)tagSelectorStack.pop();
+            ComponentSelector tagSelector
= (ComponentSelector)tagSelectorStack.pop();

@@ -424,10 +425,10 @@

         Tag tag = null;
         if (namespaceURI != null && namespaceURI.length() > 0) {
-            ServiceSelector tagSelector = null;
+            ComponentSelector tagSelector = null;
             Transformer tagTransformer = null;
             try {
-                tagSelector = (ServiceSelector);
+                tagSelector = (ComponentSelector);

                 // namespace matches tag library, lookup tag now.


I had tried to write my own taglib using the TagTransformer but it
doesn't work. I can't find some informations about it, so I had copied
the example and changed something but it doesn't work. I want to use a
tag <hello/> to print out "HELLO WORLD". My changes in detail:

1.) I had written my own class HelloWorldTag:


import org.apache.cocoon.taglib.XMLProducerTagSupport;
import org.xml.sax.SAXException;
import org.xml.sax.Attributes;

public class HelloWorldTag extends XMLProducerTagSupport {

   public int doStartTag(String namespaceURI, String localName, String
qName, Attributes atts)
       throws SAXException {
                String hello = "HELLO WORLD";
                 this.xmlConsumer.characters(hello.toCharArray(), 0,
             this.getLogger().error("T E X T = " + hello);
             return this.EVAL_BODY;

2.) I had created a subproject tagtest containing a xml file tagtest.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<root xmlns:test="urn:apache:taglib:hello">

3.) My sitemap looks as follow:

<?xml version="1.0" encoding="UTF-8"?>
<map:sitemap xmlns:map="">


  <map:transformers default="tag">
     <map:transformer name="tag"
src="org.apache.cocoon.transformation.TagTransformer" pool-max="64"
pool-min="0" pool-grow="2" logger="sitemap.transformer.newtag">



     <map:match pattern="">
        <map:generate type="file" src="tagtest.xml"/>
        <map:transform type="tag"/>
        <map:serialize type="xml"/>



3.) In cocoon.xconf I had registered the tag :

logger="sitemap.taglib.core" name="urn:apache:taglib:hello">
     <tag class=""
logger="sitemap.taglib.core.source" name="hello"/>

4.) After calling http://localhost:8080/cocoon/tagtest the tag <hello/>
will not be replaces by "HELLO WORLD". I got the following output -
nothing parsed:

<?xml version="1.0" encoding="ISO-8859-1" ?>
   <root xmlns:test="urn:apache:taglib:hello">
   <test:hello />

What is wrong here? Thank you for your help.

PS: I had tried the taglib block it seems it doesn't work, too! Whats
about this block? Is it deprecated?


View raw message