cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Curro, Joseph" <Joseph.Cu...@time0.com>
Subject RE: Best way to include ouitput of one page into another?
Date Wed, 22 Mar 2000 17:37:27 GMT
Doesn't this approach result in copying subelements of foo1.xml and foo2.xml
into the result tree, rather than the source tree?

Joe

-----Original Message-----
From: Michael French [mailto:mfrench@zycor.lgc.com]
Sent: Wednesday, March 22, 2000 11:57 AM
To: 'cocoon-users@xml.apache.org'
Subject: RE: Best way to include ouitput of one page into another?



> -----Original Message-----
> From: Rob Parker [mailto:robert@webcybernetics.com]
> Sent: Tuesday, March 21, 2000 3:03 PM
> To: cocoon-users@xml.apache.org
> Subject: Best way to include ouitput of one page into another?
>
> Hi I'm trying to include the output of one page into another. I've
> seen and tried a few ways with different levels of success.
> 
> I've seen something like inclusion via DTD type declarations 
> (What is the syntax?)

This is a literal include, not an XML Include.
In fact it's a terrible hack !
For example, you cannot have an <?xml ..?> declaration 
in the target file, and to get the correct element
nesting, you even need to leave out the root element too.

<!DOCTYPE foo SYSTEM "foo.dtd" [  
   <!ENTITY include SYSTEM "foo.xml">
]> 

<foo>
  &include;  
</foo>

Note you have to have a root element in the including doc,
so you can't just do:

<!DOCTYPE foo SYSTEM "foo.dtd" [  
   <!ENTITY include SYSTEM "foo.xml">
]> 
&include;  

There's also a neater way of doing this with XSLT document(),
which is a formal XML inclusion mechanism, and gives you 
flexibility over how the root elements are nested, 
e.g. for concatenating two similar documents:

  <xsl:template match="/">
    <foo>
      <xsl:copy-of select="document('foo1.xml')/foo/*"/>
      <xsl:copy-of select="document('foo2.xml')/foo/*"/>        
    </foo>
  </xsl:template>

Of course you can make this more generic, but you quickly get into
technicalities with XPath, namespaces, <xsl:copy> of a root, etc. etc.


Mike

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

Mime
View raw message