cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <DUDG...@britbio.co.uk>
Subject RE: One XML -> 2 XSLs
Date Wed, 22 Mar 2000 17:48:05 GMT
One way is to look at the problem from the other angle. Have an xml file for
each stylesheet. This xml file is basically a template that is set up to do
the XSL processing. The parameter you pass is the actual xml file you want
to process. You write a pointer to this file as a generated element in the
xml, and then in the stylesheet, include that document with the document()
function. 

In simplest terms, the xml:

<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="myxsl.xsl" type="text/xsl"?>
<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
  <page>
  <request-params>
    <xsp:attribute
name="file"><xsp:expr>request.getParameter("file")</xsp:expr></xsp:attribute
>
  </request-params>
 </page>
</xsp:page>


and the xsl:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="file" select="/page/request-params/@file"/>

<xsl:template match = "page">
  <xsl:apply-templates select="request-params"/>
</xsl:template>

<xsl:template match="request-params">
  <xsl:variable name="xmlfile">path/to/xml/file/<xsl:value-of
select="$file"/>.xml</xsl:variable>
  <xsl:apply-templates select="document($xmlfile)/document"/>
</xsl:template>



Slightly inelegant, but it works.

I believe that the SiteMap functionality coming in Cocoon2 will provide a
better way of achieving this.

Tim 

--------------------------------------------
Dr. Tim Dudgeon, Bioinformatics group leader
British Biotech Pharmaceuticals
Watlington Road, Oxford, OX4 5LY, UK
Tel: (44) 1865 748747
Fax: (44) 1865 781034
email: dudgeon@britbio.co.uk

> -----Original Message-----
> From: Sven Kuenzler [mailto:svenk@tzi.de]
> Sent: 22 March 2000 3:04 PM
> To: cocoon-users@xml.apache.org
> Subject: One XML -> 2 XSLs
> 
> 
> Hello,
> 
> is it possible to attach a XSL file "loosely" to a XML 
> document in order
> to create different views of that XML source? It would be nice if I
> could specify the XSL viva url, e.g. http:foo.com/todo.xml?xsl=...
> 
>    Sven.....
> 
> ---------------------------------------------------------------------
> 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