You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by George Singer <gs...@lincoln.ac.uk> on 2004/07/29 10:08:11 UTC

Problem using an External Javascript file: SOLVED !

The xsl below never managed to get to the external script add.js
 
The reason why .. a sitemap error.
 
The pattern following the <!--some more redirections --> comment was the problem, as it came BEFORE the css / js stuff. 
 
The wildcard forced cocoon to load index no matter what! So it was an order issue
many thanks to matthias in particular, Volkmar and Jan for the help
 
regards
 
georges (apologies if this is a resend))

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform <http://www.w3.org/1999/XSL/Transform> ">
 <xsl:param name="contextPath"/>
 <!-- passed from the sitemap-->
 <xsl:template match="page">
  <html>
   <head>
    <title>
     <xsl:value-of select="title"/>
    </title>
    <!--<script type="text/javascript">
    
// a function uses the DOM to bring focus to the Shirt_Number textbox:
function start(){
document.forms['form1'].elements['Shirt_Number'].focus()
}
// a function uses the DOM to highlight the form text boxes:
function highlight(set){
set.style.backgroundColor="yellow";
}
// a function uses the DOM to remove highlight from the form text boxes:
function dehighlight(set){
set.style.backgroundColor="white";
}
    </script>-->
    <link rel="stylesheet" href="{$contextPath}/styles/main.css" title="Default Style"/>
    <!-- add your own styles here as using link as above not as below ! -->
    <style type="text/css">body {background-color: #ffffcc; color: navy;} b.red {color:red;}</style>
    <script language="JavaScript" type="text/javascript" src="{$contextPath}/scripts/add.js"></script>
   </head>
   <body onload="start()">
 
 
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0 <http://apache.org/cocoon/sitemap/1.0> ">
 <map:resources>
  <map:resource name="dynamic-page">
   <map:generate src="{target}.xsp" type="serverpages"/>
   <map:transform src="simple-page2html.xsl">
    <map:parameter name="contextPath" value="{request:contextPath}"/>
   </map:transform>
   <map:serialize/>
  </map:resource>
 </map:resources>
 <!-- Pipelines-->
 <map:pipelines>
  <map:pipeline>
   <!--some redirections -->
   <map:match pattern="">
    <map:redirect-to uri="index"/>
   </map:match>
   <map:match pattern="index">
    <map:act type="form-validator">
     <map:parameter name="descriptor" value="val.xml"/>
     <map:parameter name="constraint-set" value="player"/>
     <!--This is the success case-->
     <map:call resource="dynamic-page">
      <map:parameter name="target" value="add_player"/>
      <!-- swap "add_player" for "OK" to see player added details alone -->
     </map:call>
    </map:act>
    <!--This branch contains the failed validation-->
    <!--Since the "success" pipeline ends with a serializer, the following is only applied if validation unsuccessful-->
    <map:call resource="dynamic-page">
     <map:parameter name="target" value="INVALID"/>
    </map:call>
   </map:match>
   <!--some more redirections -->
   <map:match pattern="*">
    <map:redirect-to uri="index"/>
   </map:match>
   <map:match pattern="**.css">
    <map:read src="{1}.css" mime-type="text/css"/>
   </map:match>
   <map:match pattern="*.js">
    <map:read src="{1}.js" mime-type="text/javascript"/>
   </map:match>
  </map:pipeline>
 </map:pipelines>
</map:sitemap>