cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Painter-Wakefield <paint...@mc.duke.edu>
Subject Re: Including Fragments
Date Wed, 14 Apr 2004 17:15:29 GMT




In general, all the XML tools require well-formed XML, even for fragments.
The only way around it is to work in java, concatenating strings, and then
running the whole string through the XML parser, which is silly to do
without a pretty specific need.

It would be a lot easier to use XSLT for this, and keep your headers &
footers together for well-formedness.  There are a zillion different
approaches.  Here's one:

file:/static/test.body.xml
<body>
      <b>The Body</b>
</body>

file:/static/test.layout.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:template match="/body">
      <html>
            <body>
                  <table>
                        <tr>
                              <td>
                                    <xsl:copy-of select="node()"/>
                              </td>
                        </tr>
                  </table>
            </body>
      </html>
</xsl:template>

</xsl:stylesheet>


-Christopher




|---------+---------------------------->
|         |           Garrick Dasbach  |
|         |           <Garrick@musicreb|
|         |           ellion.com>      |
|         |                            |
|         |           04/14/2004 12:08 |
|         |           PM               |
|         |           Please respond to|
|         |           users            |
|         |                            |
|---------+---------------------------->
  >--------------------------------------------------------------------------------------------------------------|
  |                                                                                      
                       |
  |       To:       users@cocoon.apache.org                                              
                       |
  |       cc:                                                                            
                       |
  |       Subject:  Including Fragments                                                  
                       |
  >--------------------------------------------------------------------------------------------------------------|




Hi,

We are currently migrating our website from a pure JSP environment to
Cocoon and have run into a problem.

The majority of our webpages have a header and footer, both of which are
fragments of xhtml documents, that we would like to include on each page.
We have tried using the CInclude transformer to include these elements, but
cocoon seems to be upset that the files are not well formed (see error
message below).

org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
file:/static/headerTest.html:6:1:org.xml.sax.SAXParseException: XML
document structures must start and end within the same entity.

We have also tried the XInclude transformer without success.  Is there a
way to include fragments of XHTML/XML documents in larger documents to
create one well-formed document?

I have included some sample code below.

------------------------------------------------------------------------

file:/static/test.html

<html xmlns:c="http://apache.org/cocoon/include/1.0">
   <c:include src="static/headerTest.html"/>
   <b>The Body</b>
   <c:include src="static/footerTest.html"/>
</html>

file:/static/headerTest.html

<body>
  <table>
     <tr>
        <td>

file:/static/footerTest.html

         </td>
      </tr>
   </table>
</body>



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


Mime
View raw message