If you want javascript libraries within your page the following should work:
<script type="text/javascript" language="JavaScript" src="resources/AnchorPosition.js">; </script>


( ";" because empty element may cause some problems)

If you still get the error ProcessingException, I suggest you leave your javascript tags out and see if you still get that error. The javascript tag should not give any problems except maybe for a "resource not found" when trying to load the .js file.

When such an error occurs, do check your logs, especially the sitemap.log (you've got your logs configured properly I guess?). That should give you more details about when and where that error pops up.

(try leaving the session transformer out, maybe that's the problem, or your stylesheet maybe, when passing variables/parameters to it?)

Kind Regards,
Jan


Siaw Ling Lo wrote:

hi,

the sitemap is:

<map:match pattern="tree">              
<map:generate src="resources_bkup/tree.xml"/>
<map:transform type="session"/>
<map:transform src="stylesheets_bkup/tree.xsl"/>
<map:transform type="encodeURL"/>
<map:serialize/>
</map:match>

<map:match pattern="*.js">
<map:read mime-type="text/javascript"
src="resources/{1}.js"/>
</map:match>

tree.js is in resources directory.


By the way, I always tried <script type="text/javascript" language="JavaScript"
src="tree.js">var
thisGetsIgnoredButdoNotRemove;</script>


but still get the same error :
org.apache.cocoon.ProcessingException: Failed
to execute pipeline.: java.lang.RuntimeException:
java.lang.NullPointerException .

Thanks again,
Siaw Ling

==================================================
From: KOZLOV Roman Subject: Re: javascript in XSL Date: Mon, 16 Aug 2004 04:35:45 -0700


Hi,

What is your pipeline for this? Check it.

Siaw Ling Lo wrote:



hi,

I am using cocoon2 and trying to build a tree that


can


collapse and expand when click.

I tried various methods in getting the javascript to
work with XSL to display an XML but it just can't


work


- error: org.apache.cocoon.ProcessingException:


Failed


to execute pipeline.: java.lang.RuntimeException:
java.lang.NullPointerException .

The methods I tried including
1. <script type="text/javascript" src="tree.js" />


in


html-head

2. embedding :
<script type="text/javascript">
       <xsl:comment>
               <![CDATA[
                   xxxxx
                   ]]>
       </xsl:comment>
</script>

below are the XSL file with the 2nd approach and
corresponding XML file.
=================================================
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform>

<xsl:template match="tree">
<html>
<head>
<script type="text/javascript">
       <xsl:comment>
               <![CDATA[
function clickOnEntity(entity) {
 if(entity.open == "false") {
   expand(entity, true)
 }
 else {
   collapse(entity)
 }
 window.event.cancelBubble = true
}

function expand(entity) {
 var oImage

 oImage = entity.childNodes(0).all["image"]
 oImage.src = entity.imageOpen

 for(i=0; i < entity.childNodes.length; i++) {
   if(entity.childNodes(i).tagName == "DIV") {
     entity.childNodes(i).style.display = "block"
   }
 }
 entity.open = "true"
}

function collapse(entity) {
 var oImage
 var i

 oImage = entity.childNodes(0).all["image"]
 oImage.src = entity.image

 // collapse and hide children
 for(i=0; i < entity.childNodes.length; i++) {
     if(entity.childNodes(i).tagName == "DIV") {
       if(entity.id != "folderTree")
entity.childNodes(i).style.display = "none"
       collapse(entity.childNodes(i))
     }
   }
 entity.open = "false"
}

function expandAll(entity) {
 var oImage
 var i

 expand(entity, false)

 // expand children
 for(i=0; i < entity.childNodes.length; i++) {
   if(entity.childNodes(i).tagName == "DIV") {
     expandAll(entity.childNodes(i))
   }
 }
}
                   ]]>
       </xsl:comment>
</script>
</head>
<body>
 <xsl:apply-templates select="entity"/>
</body>
</html>
</xsl:template>

<xsl:template match="entity">
<div onclick="window.event.cancelBubble =
true;clickOnEntity(this);" onselectstart="return
false" ondragstart="return false">
<xsl:attribute name="image"><xsl:value-of
select="image"/></xsl:attribute>
<xsl:attribute name="imageOpen"><xsl:value-of
select="imageOpen"/></xsl:attribute>
<xsl:attribute name="open">false</xsl:attribute>
<xsl:attribute name="id">f<xsl:value-of
select="@id"/></xsl:attribute>
<xsl:attribute name="open">false</xsl:attribute>
<xsl:attribute name="STYLE">
padding-left: 20px;
cursor: hand;
<xsl:if expr="depth(this) > 2">
display: none;
</xsl:if>
</xsl:attribute>
<table border="0" cellspacing="0"


cellpadding="0">


     <tr>
       <td valign="middle">
         <img border="0" id="image">
           <xsl:attribute name="SRC">
             <xsl:value-of select="image"/>
           </xsl:attribute>
         </img>
       </td>
       <td valign="middle" nowrap="true">
       <xsl:attribute name="STYLE">
         padding-left: 7px;
         font-family: Verdana;
         font-size: 11px;
         font-color: black;
       </xsl:attribute>
       <xsl:value-of select="description"/></td>
     </tr>
   </table>
 <xsl:apply-templates select="contents/entity"/>
 </div>
</xsl:template>

</xsl:stylesheet>

and the corresponding XML file:
=================================
<?xml version="1.0"?>
<tree>
 <entity id="e12">
   <description>Reports</description>
   <oncontextmenu></oncontextmenu>
   <image>images/book.gif</image>
   <imageOpen>images/bookOpen.gif</imageOpen>
   <contents>
     <entity id="e13">
       <description>Income</description>
       <oncontextmenu></oncontextmenu>
       <image>images/paper.gif</image>
       <imageOpen>images/paper.gif</imageOpen>
       <contents>
       </contents>
     </entity>
     <entity id="e14">
       <description>Expenses</description>
       <oncontextmenu></oncontextmenu>
       <image>images/paper.gif</image>
       <imageOpen>images/paper.gif</imageOpen>
       <contents>
       </contents>
     </entity>
   </contents>
 </entity>
</tree>

Thank you very much for any guidance and advice.

SiawLing






__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to