cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sonney <>
Subject Re: How to do logic in stylesheets?
Date Mon, 03 Jul 2000 16:20:27 GMT
On Mon, 3 Jul 2000, Ulrich Mayring wrote:
> Basically, I want something like:
> <?cocoon-process type="xslt"?>
> <?cocoon-process type="xsp"?>
> But I think this is not possible, is it?

Sure it is. I do it a lot. But you have to do something like the
examples. below. Note : All server names & special queries have been
changed or removed to protect the innocent. Props to Donald Ball for doing
this first. Cacheing *CAN* be a problem, but there are hacks to make
Cocoon re-gen the xsp page nearly every time.

<!-- Begin test.xml file -->
<?xml version="1.0"?>
<?xml-stylesheet href="wZ.xsl" type="text/xsl"?>

<?cocoon-process type="xslt"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>


<!-- Specify the final xsl file -->
<wZ:stylesheet href="test.xsl" />

  <ldap-server name="unc-cas">

 <ldap-query server="unc-cas" ldap-searchbase="o=webslingerZ,c=US" doc-element="wZ:user"
<!-- End test.xml -->

<!--Begin wZ.xsl -->
<?xml version="1.0"?>


<!-- Remember that xsl file? This is where we build the pi for it. -->
<xsl:template match="/">
	<xsl:if test="//wZ:stylesheet">
		<xsl:processing-instruction name="xml-stylesheet">type=&quot;text/xsl&quot;
href=&quot;<xsl:value-of select="//wZ:stylesheet/@href"/>&quot;</xsl:processing-instruction>

<!-- settings to copy the unaffected tags --> 
<xsl:template match="@*|node()" priority="-1">
    <xsl:apply-templates select="@*|node()"/>

<!-- get the user data -->
<xsl:template match="wZ:user">
	<xsl:for-each select="wZ:ldapResult">
	<!-- some query here dependant on ldap data -->

<xsl:template match="wZ:stylesheet"></xsl:template>

<!-- rebuild remaining PIs -->
<xsl:template match="processing-instruction()">
	<xsl:if test="not(name(.)='xml-stylesheet')">
    <xsl:apply-templates select="@*|node()"/>
<!-- End wZ.xsl -->

<!-- begin test.xsl -->
<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="">

<xsl:template match="/">

<xsl:template match="page">
  <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/>
  <title>Test Page</title>
		<xsl:apply-templates />

<xsl:template match="rowset">
		<xsl:for-each select="row">
			<xsl:sort select="name"/>
				<tr><td><xsl:value-of select="name"/></td>
				<td><xsl:value-of select="address"/></td></tr>

<!-- End test.xsl -->
- Kevin Sonney

View raw message