cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pbink...@library.ualberta.ca
Subject RE: Choosing an XSL dynamically
Date Wed, 24 May 2000 18:03:28 GMT
Newbie problem: I can't get this to work, and I think it's because my
installation of Cocoon isn't passing parameters to stylesheets. If I make a
stylesheet like this:

<?xsl:stylesheet ...>
<xsl:param name="portal"/>
<xsl:template match="page">
<html><head>
<title>Using portal <xsl:value-of match="$portal"/></title>
...

... and I call that stylesheet from an xml file that has been accessed using
a command-line parameter, e.g. "test.xml?portal=foo", I get a blank where
the <xsl:value-of...> should have put the value "foo".

Probable cause: I haven't upgraded from Cocoon 1.6.1. Before I embark on the
rigors of upgrading, though, I'd be grateful for any warnings about other
likely causes.

Peter

Peter Binkley
Interface Development Coordinator, Alberta Library Interface
email: pbinkley.tal@telusplanet.net
phone: (780) 492-5282 x242
fax: (780) 492-9243
post: Cameron Library 4-40
      University of Alberta
      Edmonton Alberta 
      T6G 2J8

 
-----Original Message-----
From: Ken Beyer [mailto:kab@metatec.com]
Sent: May 23, 2000 07:23 PM
To: cocoon-users@xml.apache.org
Subject: Re: Choosing an XSL dynamically


Thanks Ulrich - that works!  A couple of minor errors in
yours so for clarity (in case others wish to see,
here's the sample files that worked on my machine).

I apologize if this is common knowledge to others -
just I went through mail archives and didn't see any
solutions on prior "similar" threads.

-------------------
<?xml version="1.0"?>

<!-- test.xml (i.e. test.xml?portal=foo) -->

<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="test.broker.xsl" type="text/xsl"?>

<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">

<xsp:logic>
 String someXspString = "foobar";
</xsp:logic>

<page>
  SOME XML DATA <xsp:expr>someXspString</xsp:expr>
</page>

</xsp:page>

-------------------------
<?xml version="1.0"?>

<!-- test.broker.xsl -->

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

  <xsl:param name="portal"/>

  <xsl:template match="page">
   <xsl:processing-instruction
name="cocoon-process">type="xslt"</xsl:processing-instruction>
   <xsl:processing-instruction name="xml-stylesheet">
   href="test.<xsl:value-of select="$portal"/>.xsl"
   type="text/xsl"
   </xsl:processing-instruction>
   <xsl:comment>Using portal = <xsl:value-of
select="$portal"/></xsl:comment>
   <xsl:copy>
    <xsl:apply-templates select="@*"/>
    <xsl:apply-templates select="node()"/>
   </xsl:copy>
  </xsl:template>

  <xsl:template match="@*|*">
   <xsl:copy>
    <xsl:apply-templates select="*|@*"/>
   </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

------------------------
<?xml version="1.0"?>

<!-- test.foo.xsl -->

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

  <xsl:template match="page">
    <xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
   <html>
    <head>
     <title>
      Hello from foo
     </title>
    </head>
     Hello from foo!
     <P>Here's your data ... </P>
     <xsl:apply-templates/>
    </html>
  </xsl:template>

</xsl:stylesheet>

---------------------
<?xml version="1.0"?>

<!-- test.bar.xsl -->

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

  <xsl:template match="page">
    <xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
   <html>
    <head>
     <title>
      Hello from bar
     </title>
    </head>
     Hello from bar!
     <P>Here's your data ... </P>
     <xsl:apply-templates/>
    </html>
  </xsl:template>

</xsl:stylesheet>

Ken



---------------------------------------------------------------------
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