cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paint...@mc.duke.edu
Subject Re: Calling Stylesheet using Parameter
Date Thu, 12 Apr 2001 14:43:22 GMT

David,

what you have is basically correct, except that the <xsp:pi> element needs
to be nested inside the single element inside the <xsp:page> element,
instead of directly inside the <xsp:page> itself.  Also,
request.getQueryString() doesn't want any parameters, I think.  It returns
the entire query string, so you just put ?style.xsl at the end of your URL
and getQueryString() returns "style.xsl".  A better way, if I mag suggest
it, is to use the request taglib to get named parameters, e.g., if your
request URL looks like ...?stylesheet=style.xsl then you can use
<request:get-parameter name="stylesheet"/> to get back the value
"style.xsl".

try this code with a URL like "http://.../test.xml?stylesheet=style.xsl":
<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<xsp:page
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  xmlns:request="http://www.apache.org/1999/XSP/Request"
>

<page>
  <xsp:pi target="xml-stylesheet">
    type="text/xsl"
    href="<xsp:expr><request:get-parameter name="stylesheet"/></xsp:expr>"
  </xsp:pi>

</page>
</xsp:page>

Also, I've found it easier in some ways to do the stylesheet redirection in
a stylesheet.  That is, hardcode the xml file to go to some standard
stylesheet that then directs the processing on to another stylesheet as per
your query parameters, or to a default stylesheet or whatever.  The FAQ
shows both ways.

-Christopher




Please respond to cocoon-users@xml.apache.org

To:   "Users, Cocoon" <cocoon-users@xml.apache.org>
cc:

Subject:  Calling Stylesheet using Parameter


I apologize if this question is covered elsewhere but I cannot get it to
work. The faq example appears to be incomplete.
I am trying to open a stylesheet by passing a parameter as follows:

<A HREF="http://.../page.xml?stylesheet=http://.../style.xsl">
and then using xsp as follows in the file page.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:request="http://www.apache.org/1999/XSP/Request">
     <xsp:pi target="xml-stylesheet">
  href="<xsp:expr>request.getQueryString("stylesheet")</xsp:expr>"
  type="text/xsl" media="explorer"</xsp:pi>
....
</xsp:page>
I have tried many variations on this theme without success. Can anyone
help with syntax that works?
David Allen







---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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