You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jörn Heid <he...@agentsinaction.de> on 2001/07/25 10:42:53 UTC

[C2b2] Workaround for XInclude-Bug

For those who do have problems with the XInclude-Transformer, here's a
workaround (not a patch!):

1. Copy src/org/apache/transformation/XIncludeTransformer.java to a
directory of your choice for compiling it.

2. Replace the setup method with this one:

   public void setup(SourceResolver resolver, Map objectModel,
                      String source, Parameters parameters)
            throws ProcessingException, SAXException, IOException {
            if (manager != null && current_xmlbase_uri == null) {
               try {
                   source = parameters.getParameter("src", "");
                   source = source.substring (0, source.lastIndexOf ('/'));
                   this.urlFactory =
(URLFactory)this.manager.lookup(URLFactory.ROLE);
                   base_xmlbase_uri = urlFactory.getURL(source);
                   this.current_xmlbase_uri = base_xmlbase_uri;
                   } catch (Exception e) {
                           getLogger().debug("XincludeTransformer", e);
                           throw new ProcessingException(e.getMessage(), e);
                           }
              }
    }

3. Add the following lines to the source-File (don't know if it's
nessesary):
    /**
     * Recycle the component
     */
    public void recycle() {
        super.recycle();
        this.current_xmlbase_uri = null;
        this.base_xmlbase_uri = null;
        this.xmlbase_element_name_stack.clear();
        this.xmlbase_element_uri_stack.clear();
        this.last_xmlbase_element_name = "";
    }

4. Change the packagename and compile it.

5. In the sitemap change the definition of the XIncludeTransformer regarding
your package:
			<map:transformer name="xinclude"
src="de.agentsinaction.ses.cocoon.XIncludeTransformer"/>

6. The last thing is that each time you are using the transformer you must
set the src-Parameter:

			<map:match pattern="**.xml">
				<map:generate src="{1}.xml"/>
				<map:transform type="xinclude">
					<map:parameter name="src" value="{1}.xml"/>
				</map:transform>
				<map:transform src="xsl/page.xsl"/>
				<map:serialize/>
			</map:match>



For the developers: The problem is that the setDocumentLocator method is not
called enough times. If there are two instances of the transformer the
method is only called on one transformer.
When stopping the engine (Resin), then the method isn't called one time! -
but the setup-method. So I used it for this workaround.

JOERN_HEID


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