> XInclude is only for including some XML snippets as you have used it. > It's not for recursive use and there is no need for it I think. Use a > technology like XSLT which can do what you want.
OK - sounds like an ideal solution, except the transformer is looking for the DTD in the same directory as the XML file. My doctype line is: <!DOCTYPE document PUBLIC "-//APACHE/DTD Documentation V1.1//EN" "document-v11.dtd"> I expect replacing "document-v11.dtd" with the path to the dtd would work but this means I can;t move any files without breaking the doctype. I don't know much about catalogs but I suspect what is happening is that cocoon works fine as it is aware of my DTD catalog, but the XSL transformer fails on the <xsl:apply-templates select="document(@href)/document/header"/> as it is not aware of the DTD catalog. Any ideas how to solve this? (if indeed this is the problem). Ross > An example: > > Instead of an XInclude ref in the file you can write: > > <document> > <header> > ... > </header> > <body> > <chapter href="introduction.xml"/> > <chapter href="background.xml"/> > ... > </body> > </document> > > The stylesheet would look like the following: > > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Tranform"> > > <xsl:template match="@*|node()"> > <xsl:copy> > <xsl:apply-templates select="@*|node()"/> > </xsl:copy> > </xsl:template> > > <xsl:template match="chapter[@href]"> > <xsl:apply-templates select="document(@href)/document/header"/> > <xsl:apply-templates select="document(@href)/document/body"/> > </xsl:template> > > </xsl:stylesheet> > This would work recursively too. > > Regards, > > Joerg Ross Gardler wrote: > I have a problem with XInclude, however, I may be using the wrong > solution in the first place, that is perhaps I should be using some > other mechanism for achieving what I want. So solutions that use a > technique other than XInclude are welcome. > > I have a book written in XML and divided into a number of chapters > > introduction.xml > background.xml > casestudies.xml > etc. > > Within each chapter I use XInclude to bring some content from other > files available on a web site, for example, glossary and program code, > so my pipeline matcher (for pdf output) is: > > <map:match pattern="**.pdf"> > <map:generate src="content/xdocs/{1}.xml"/> > <map:transform type="xinclude"/> > <map:transform src="skins/saafe/xslt/fo/document2fo.xsl"/> > <map:serialize type="fo2pdf"/> > </map:match> > > This all works fine for individual chapters, but... > > To produce the full book, that is a single document with all chapters > included, I have another xml file (called full.xml) that includes the > relative portions of the chapter xml files, for example: > > <document> > <header> > ... > </header> > <body> > <chapter> > <xi:include href="introduction.xml#xpointer(/document/header)"/> > <xi:include href="introduction.xml#xpointer(/document/body)"/> > </chapter> > <chapter> > <xi:include href="background.xml#xpointer(/document/header)"/> > <xi:include href="background.xml#xpointer(/document/body)"/> > </chapter> > ... > </body> > </document> > > Predictably, what I get is a document including most of the information > >> from the chapter files, but not the included information within each of > > the chapter files. That is, assume background.xml has an xinclude within > it, this is not translated by the pipeline. > > I have tried adding a second xinclude transform the the pipeline: > > <map:match pattern="**.pdf"> > <map:generate src="content/xdocs/{1}.xml"/> > <map:transform type="xinclude"/> > <map:transform type="xinclude"/> <!-- second transformation becasue > included files may have includes --> > <map:transform src="skins/saafe/xslt/fo/document2fo.xsl"/> > <map:serialize type="fo2pdf"/> > </map:match> > > This generates an error stating that full.xml cannot be found in the > build directory. I have verified that it is there, and of course it is. > I don;t think it is a path problem becasue full.xml and all the chapter > xml files are all in the same directory and all chapters generate OK > when there is only a single include transformation in the pipeline. > > Even if this were to work there would be a problem. What if we needed > three transformations, or four, or five etc. It is perfectly possible > for includes to include includes and so on. > > Note, I am a relatively competant programmer, so if this is a limitation > of the XInclude transformer and it is within the specs of XInclude to > have such recursion I will gladly add it to the transformer. > > Thanks for any input, > Ross --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]> --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>