Hi Mansour, I just wrote a little unit test which has no issues with includes. I did not commit the test but I suggest you try tackling your issue in small steps like below and continue from there.
Robby ********************************************************************************************** package org.apache.cocoon.sax; import junit.framework.TestCase; import org.custommonkey.xmlunit.Diff; import java.io.ByteArrayOutputStream; import static org.apache.cocoon.sax.builder.SAXPipelineBuilder.newNonCachingPipeline; public class XSLTIncludeTest extends TestCase { public void testTransformerWithInclude() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); newNonCachingPipeline() .setStringGenerator("<food><fruit>apple</fruit><vegetable>tomato</vegetable></food>") .addXSLTTransformer(this.getClass().getResource("/food.xslt")) .addSerializer() .withEmptyConfiguration() .setup(baos) .execute(); Diff diff = new Diff("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ul><li class=\"fruit\">apple</li><li class=\"vegetable\">tomato</li></ul>", new String(baos.toByteArray())); assertTrue("XSL transformation didn't work as expected " + diff, diff.identical()); } } **********************************food.xslt ********************************************* <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <!-- we will process the <fruit> tags in this stylesheet but leave the processing of <vegetable> tags to the included vegetables.xslt --> <xsl:include href="vegetables.xslt"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="food"> <ul> <xsl:apply-templates/> </ul> </xsl:template> <xsl:template match="fruit"> <li class="fruit"><xsl:apply-templates/></li> </xsl:template> </xsl:stylesheet> ************************************vegetables.xslt********************************************** <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="vegetable"> <li class="vegetable"><xsl:apply-templates/></li> </xsl:template> </xsl:stylesheet> ********************************************************************************************** -----Original Message----- From: Robby Pelssers [mailto:robby.pelss...@nxp.com] Sent: Thursday, November 08, 2012 9:31 AM To: users@cocoon.apache.org Subject: RE: Unable to transform to docbook Hi Mansour, To be able to confirm this one would need to setup a small test case with a very simple XSLT importing another one. Which is exactly what I am planning to do. Too bad you can't send me a very simplistic project showing the problem. Robby -----Original Message----- From: Mansour Al Akeel [mailto:mansour.alak...@gmail.com] Sent: Thursday, November 08, 2012 2:46 AM To: users@cocoon.apache.org Subject: Re: Unable to transform to docbook Robby, I think I know where the issue is, but I don't have eclipse set up. I am just browsing the source through VI. I am working with the latest from SVN: In the file: cocoon-sax/src/main/java/org/apache/cocoon/sax/component/XSLTTransformer.java try { 160 this.templates = transformerFactory.newTemplates(new StreamSource(this.source.toExternalForm())); 161 162 // store the XSLT into the cache for future reuse 163 LOG.debug("{} local cache put: {}", getClass().getSimpleName(), this.source.toExternalForm()); 164 165 ValidityValue<Templates> cacheEntry = new ValidityValue<Templates>(this.templates, lastModified); 166 XSLT_CACHE.put(this.source.toExternalForm(), cacheEntry); 167 } catch (TransformerConfigurationException e) { 168 throw new SetupException("Impossible to read XSLT from '" + this.source.toExternalForm() 169 + "', see nested exception", e); 170 } If I am not wrong, it's building the transformation from a stream, and a SourceStream has no idea about the location of the loaded XSTL, so the resolver can not load the imported or included, xslts. The only way I know of, is to set the systemId so something like this should do the trick: StreamSource tmpSource = new StreamSource(this.source.toExternalForm()); URL fullPath = ..... tmpSource.setSystemId(fullPath); this.templates = transformerFactory.newTemplates(tmpSource); if you have eclipse and your IDE setup, it will be easier to test and fix. On Mon, Nov 5, 2012 at 7:23 PM, Mansour Al Akeel <mansour.alak...@gmail.com> wrote: > Sure I will. I will organize a project that is easy to play with. > > I will send it directly to your email (I think the list doesn't allow > attachment). > > > On Mon, Nov 5, 2012 at 6:21 PM, Robby Pelssers <robby.pelss...@nxp.com> wrote: >> You know what... >> >> It might be a problem with the includes but to be honest I would have >> expected another exception in that case. Is there any way you can share the >> sources for the project so I can adjust the dev.properties file for my >> situation and crack the problem? I'm sure I will find out quickly but >> helping out by mail is a bit more tedious to be honest. >> >> So if you can provide me with a zip file containing the project and the >> docbook xslt's zipped and perhaps also that ex.xml file I can debug your >> issue. >> >> Robby >> >> -----Original Message----- >> From: Mansour Al Akeel [mailto:mansour.alak...@gmail.com] >> Sent: Monday, November 05, 2012 6:59 PM >> To: users@cocoon.apache.org >> Subject: Re: Unable to transform to docbook >> >> On Mon, Nov 5, 2012 at 7:51 AM, Robby Pelssers <robby.pelss...@nxp.com> >> wrote: >>> Hi Mansour, >>> >>> First of all I assume you don't have the same match patterns in the same >>> sitemap..right? I guess you altered the implementation just to test and the >>> first one (docbook.xsl) failed and the second one (myCustomSheet.xsl) >>> worked. >> >> Yes, exactly ! The first one is failing, the second one is working. So the >> issue is only with docbook.xsl being processed from cocoon. >> >>> >>> The most obvious way to debug is to try what following matchers will do: >>> >>> <map:match pattern="article/{id}"> >>> <map:generate >>> src="/home/mansour/workspace/pipelines/repo/articles/{map:id}.xml" /> >>> <map:serialize /> >>> </map:match> >>> >>> Also try to generate that xsl: >>> >>> <map:match pattern="transform/docbook.xsl"> >>> <map:generate >>> src="/home/mansour/workspace/pipelines/docbook-xsl-snapshot/html/docbook.xsl >>> " /> >>> <map:serialize /> >>> </map:match> >>> >>> But my hunch is that the docbook.xsl has other xsl imports or includes >>> which might be the problem. >>> >>> Let me know what happens if you try above matchers and also check if the >>> docbookx.xsl has imports/includes or if it has declared xsl parameters. >> >> >> I tried both matchers and they seem to be working fine. I can do >> http://localhost:8888/transform/docbook.xsl and I get the expected output. >> The docbook.xsl has a lot of <xsl:include> : >> >> <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >> xmlns:ng="http://docbook.org/docbook-ng" >> xmlns:db="http://docbook.org/ns/docbook" >> xmlns:exsl="http://exslt.org/common" >> xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="db ng >> exsl exslt" version="1.0"> >> >> <xsl:output method="html" encoding="ISO-8859-1" indent="no"/> >> >> <!-- ******************************************************************** >> $Id: docbook.xsl 9605 2012-09-18 10:48:54Z tom_schr $ >> >> ******************************************************************** >> >> This file is part of the XSL DocBook Stylesheet distribution. >> See ../README or http://docbook.sf.net/release/xsl/current/ for >> copyright and other information. >> >> >> ******************************************************************** >> --> >> >> <!-- >> ==================================================================== >> --> >> >> <xsl:include href="../VERSION.xsl"/> >> <xsl:include href="param.xsl"/> >> <xsl:include href="../lib/lib.xsl"/> >> <xsl:include href="../common/l10n.xsl"/> <xsl:include >> href="../common/common.xsl"/> <xsl:include >> href="../common/utility.xsl"/> <xsl:include >> href="../common/labels.xsl"/> <xsl:include >> href="../common/titles.xsl"/> <xsl:include >> href="../common/subtitles.xsl"/> >> >> <xsl:include href="../common/gentext.xsl"/> <xsl:include >> href="../common/targets.xsl"/> <xsl:include >> href="../common/olink.xsl"/> <xsl:include href="../common/pi.xsl"/> >> <xsl:include href="autotoc.xsl"/> <xsl:include href="autoidx.xsl"/> >> >> .... >> >> Thank you for helping in this. >> >> >> >>> >>> Kind regards, >>> Robby Pelssers >>> >>> -----Original Message----- >>> From: Mansour Al Akeel [mailto:mansour.alak...@gmail.com] >>> Sent: Sunday, November 04, 2012 11:14 PM >>> To: users >>> Subject: Unable to transform to docbook >>> >>> I have worked with C2.1 and 2.2 before. I am trying to play with C3 for a >>> coming project. >>> I need to generate HTML from docbook file. >>> >>> INFO RequestProcessor - Sitemap execution for /article/ex took 6470.727 ms. >>> ERROR XMLSitemapServlet - Cocoon can't process the request. >>> org.apache.cocoon.sitemap.InvocationException: >>> org.apache.cocoon.pipeline.ProcessingException: Can't parse url connection >>> file:/home/mansour/workspace/pipelines/repo/articles/ex.xml >>> at >>> org.apache.cocoon.sitemap.util.ExceptionHandler.getInvocationException(ExceptionHandler.java:39) >>> at >>> org.apache.cocoon.sitemap.node.PipelineNode.handleException(PipelineNode.java:101) >>> at >>> org.apache.cocoon.sitemap.node.PipelineNode.invoke(PipelineNode.java:71) >>> at >>> org.apache.cocoon.sitemap.node.AbstractSitemapNode.invoke(AbstractSitemapNode.java:96) >>> at >>> org.apache.cocoon.sitemap.node.PipelinesNode.invoke(PipelinesNode.java:49) >>> at >>> org.apache.cocoon.sitemap.node.AbstractSitemapNode.invoke(AbstractSitemapNode.java:96) >>> at org.apache.cocoon.sitemap.node.Sitemap.invoke(Sitemap.java:42) >>> at >>> org.apache.cocoon.servlet.RequestProcessor.invoke(RequestProcessor.java:233) >>> at >>> org.apache.cocoon.servlet.RequestProcessor.sendSitemapResponse(RequestProcessor.java:290) >>> at >>> org.apache.cocoon.servlet.RequestProcessor.service(RequestProcessor.java:90) >>> at >>> org.apache.cocoon.servlet.XMLSitemapServlet.service(XMLSitemapServlet.java:47) >>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) >>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>> at >>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >>> at >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce >>> ss >>> orImpl.java:43) >>> >>> ..... >>> >>> Caused by: org.apache.cocoon.pipeline.ProcessingException: Can't parse url >>> connection file:/home/mansour/workspace/pipelines/repo/articles/ex.xml >>> at org.apache.cocoon.sax.util.XMLUtils.toSax(XMLUtils.java:117) >>> at >>> org.apache.cocoon.sax.component.XMLGenerator$URLGenerator.execute(XMLGenerator.java:385) >>> at >>> org.apache.cocoon.sax.component.XMLGenerator.execute(XMLGenerator.java:104) >>> at >>> org.apache.cocoon.pipeline.AbstractPipeline.invokeStarter(AbstractPipeline.java:146) >>> at >>> org.apache.cocoon.pipeline.CachingPipeline.execute(CachingPipeline.java:143) >>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>> at >>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >>> at >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >>> at java.lang.reflect.Method.invoke(Method.java:601) >>> at >>> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) >>> at >>> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) >>> at >>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) >>> at >>> org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80) >>> at >>> org.apache.cocoon.servlet.collector.ResponseHeaderCollector.interceptInvoke(ResponseHeaderCollector.java:94) >>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>> at >>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >>> at >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >>> at java.lang.reflect.Method.invoke(Method.java:601) >>> at >>> org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621) >>> at >>> org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610) >>> at >>> org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65) >>> at >>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) >>> at >>> org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) >>> at >>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) >>> at >>> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) >>> at $Proxy27.execute(Unknown Source) >>> at >>> org.apache.cocoon.sitemap.InvocationImpl.execute(InvocationImpl.java:141) >>> at >>> org.apache.cocoon.sitemap.node.PipelineNode.invoke(PipelineNode.java:66) >>> ... 60 more >>> Caused by: org.xml.sax.SAXException: java.lang.NullPointerException >>> javax.xml.transform.TransformerException: java.lang.NullPointerException >>> at >>> com.sun.org.apache.xalan.internal.xsltc.trax.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:245) >>> at >>> org.apache.cocoon.xml.sax.AbstractSAXPipe.endDocument(AbstractSAXPipe.java:58) >>> at >>> org.apache.cocoon.sax.AbstractSAXTransformer.endDocument(AbstractSAXTransformer.java:47) >>> at >>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocu >>> me >>> nt(AbstractSAXParser.java:742) >>> >>> ...... >>> >>> Here's my pipeline: >>> >>> <map:pipelines> >>> <map:pipeline> >>> >>> <map:match pattern="article/{id}"> >>> <map:generate >>> src="/home/mansour/workspace/pipelines/repo/articles/{map:id}.xml" /> >>> <map:transform >>> src="/home/mansour/workspace/pipelines/docbook-xsl-snapshot/html/docbook.xsl" >>> /> >>> <map:serialize /> >>> </map:match> >>> >>> >>> This matcher is working with another transformation. >>> For example the following pipeline: >>> >>> <map:pipeline> >>> >>> <map:match pattern="article/{id}"> >>> <map:generate >>> src="/home/mansour/workspace/pipelines/repo/articles/{map:id}.xml" /> >>> <map:transform src="sheets/myCustomSheet.xsl" /> >>> <map:serialize /> >>> </map:match> >>> >>> Would work fine. >>> >>> The same file "ex.xml" can be processed with xalan from the command line >>> and produce the correct output ! >>> >>> any idea ?? >>> >>> -------------------------------------------------------------------- >>> - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org >>> For additional commands, e-mail: users-h...@cocoon.apache.org >>> >>> >>> -------------------------------------------------------------------- >>> - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org >>> For additional commands, e-mail: users-h...@cocoon.apache.org >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org >> For additional commands, e-mail: users-h...@cocoon.apache.org >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org >> For additional commands, e-mail: users-h...@cocoon.apache.org >> --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org