Hi,
I would like to ask, if you could write the Extractor more flexible. I
need a transformer like the FragmentExtractorTransformer for my
project(http://sourceforge.net/projects/jeuclid/). I had also ask
the Author of this class, but got no answer.
I suggestion is like this:
sitemap.xmap:
<map:transformer name="extractor"
src="org.apache.cocoon.transformation.FragmentExtractorTransformer"/>
<extract-uri>http://www.w3.org/2000/svg</extract-uri>
<extract-element>svg</extract-element>
</map:transformer>
<map:transformer name="mml-extractor"
src="org.apache.cocoon.transformation.FragmentExtractorTransformer">
<extract-uri>http://www.w3.org/1998/Math/MathML</extract-uri>
<extract-element>math</extract-element>
</map:transformer>
I have attached a patch file for this.
Thank you, Stephan Michels.
--- FragmentExtractorTransformer.java Fri Jan 25 11:20:47 2002
+++ FragmentExtractorTransformer2.java Fri Jan 25 11:25:22 2002
@@ -13,6 +13,9 @@
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.caching.CacheValidity;
@@ -35,13 +38,13 @@
/** The transformation half of the FragmentExtractor.
- * This transformer sieves an incoming stream of xml with embedded SVG images
- * and replaces the images with an xlink locator pointing to the image.
+ * This transformer sieves an incoming stream of xml
+ * and replaces fragments with an xlink locator pointing to the fragments.
* Ultimately this could be much more general, but at the moment, I think it's
- * mainly SVG extraction that's likely to go on, and afterall,
+ * mainly fragment extraction that's likely to go on, and afterall,
* <a href="http://c2.com/cgi/wiki?YouArentGonnaNeedIt">you aren't gonna need it</a>,
* so I've just used very simple extraction based on a URI and local name.
- * <p>
+ * <p>
* <b><em>Warning</em> : since fragments are stored locally in the class, this
transformer
* and the associated generator are very likely to fail on a clustered server.</b>
*
@@ -49,9 +52,12 @@
* @version CVS $Revision: 1.4 $ $Date: 2002/01/25 03:58:30 $
*/
public class FragmentExtractorTransformer extends AbstractTransformer
- implements Composable, Disposable, Cacheable, Poolable {
- private static String EXTRACT_URI="http://www.w3.org/2000/svg";
- private static String EXTRACT_ELEMENT="svg";
+ implements Composable, Disposable, Cacheable, Poolable, Configurable {
+ private String EXTRACT_URI="http://www.w3.org/2000/svg";
+ private String EXTRACT_ELEMENT="svg";
+
+ private final static String EXTRACT_URI_NAME="extract-uri";
+ private final static String EXTRACT_ELEMENT_NAME="extract-element";
private static String FE_URI="http://apache.org/cocoon/fragmentextractor/2.0";
private static String XLINK_URI="http://www.w3c.org/1999/xlink";
@@ -70,14 +76,32 @@
private DOMFactory documentFactory;
- public void compose(ComponentManager manager) throws ComponentException {
+ public void compose(ComponentManager manager)
+ throws ComponentException{
this.manager = manager;
this.documentFactory = (DOMFactory) this.manager.lookup(Parser.ROLE);
}
+ /**
+ * Configure this transformer.
+ */
+ public void configure( Configuration conf )
+ throws ConfigurationException {
+ if ( conf != null ) {
+
+ Configuration child = conf.getChild( EXTRACT_URI_NAME );
+ EXTRACT_URI = child.getValue( "http://www.w3.org/2000/svg" );
+ getLogger().debug( "Extraction URI is " + EXTRACT_URI );
+
+ child = conf.getChild( EXTRACT_ELEMENT_NAME );
+ EXTRACT_ELEMENT = child.getValue( "svg" );
+ getLogger().debug( "Extraction element is " + EXTRACT_ELEMENT );
+ }
+ }
+
/** Setup the transformer.
*/
- public void setup(SourceResolver resolver, Map objectModel, String src,
Parameters par)
+ public void setup(SourceResolver resolver, Map objectModel, String src,
+Parameters parameters)
throws ProcessingException, SAXException, IOException {
extractLevel = 0;
imageID = 0;
@@ -318,7 +342,7 @@
super.startDTD(name,publicId,systemId);
} else {
throw new SAXException(
- "Recieved startDTD after beginning SVG extraction process."
+ "Recieved startDTD after beginning fragment extraction process."
);
}
}
@@ -332,7 +356,7 @@
super.endDTD();
} else {
throw new SAXException(
- "Recieved endDTD after beginning SVG extraction process."
+ "Recieved endDTD after beginning fragment extraction process."
);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]