You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jeanine Meyer <vz...@verizon.net> on 2002/07/25 21:05:36 UTC

XML/XSLT to html including JavaScript question

Hello,
(Forgive any redundancy with previous messages.)
I'm having problems with what I think is a simple task: recreating the 
standard image swap in on mouse over.
I have other examples of xml citing xsl working using IE6 and also NS6.2.
However, in this example, the javascript function doesn't seem to be called.
Also, when I use saxon, a file is produced that works in NS6.2 but not 
in IE6.
Here is the xml file:
<?xml version="1.0" ?>
<?xml-stylesheet href="mouseover2.xsl" type="text/xsl"?>

<pictures>
  <oimage>Liz-book.jpg</oimage>
  <nimage>Darcy3.jpg</nimage>
</pictures>
***************mouseover2.xsl
<?xml version="1.0" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0">
<xsl:output method="html" />
<xsl:template match="/pictures">
<html>
<head>
<title> Rollover test </title>
<script language="JavaScript" type="text/javascript" src="movein.js">
</script>
</head>
<body>
<xsl:element name="a">
  <xsl:attribute name="href"></xsl:attribute>
  <xsl:attribute name="onMouseOver">movein('<xsl:value-of 
select="nimage"/>');</xsl:attribute>
  <xsl:attribute name="onMouseOut">movein('<xsl:value-of 
select="oimage"/>');</xsl:attribute>
  <xsl:attribute name="onClick">return false;</xsl:attribute>
  <xsl:element name="img">
    <xsl:attribute name="src"><xsl:value-of 
select="oimage"/></xsl:attribute>
    <xsl:attribute name="id">picture1</xsl:attribute>
  </xsl:element>
</xsl:element>
</body>
</html>
</xsl:template>
</xsl:transform>
*************the result of using saxon
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  
      <title> Rollover test </title><script language="JavaScript" 
type="text/javascript" src="movein.js"></script></head>
   <body><a href="" onMouseOver="movein('Darcy3.jpg');" 
onMouseOut="movein('Liz-book.jpg');" onClick="return false;"><img 
src="Liz-book.jpg" id="picture1"></a></body>
</html>
************movein.js
function movein(image)
{
window.document.picture1.src=image;
}


I get the same results when I put in the function movein.js directly in 
the mouseover.xsl (that is, when the resulting html doesn't use an external
javascript, but a local one).

HELP.
thanks,
Jeanine Meyer


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

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: XML/XSLT to html including JavaScript question

Posted by Joerg Heinicke <jo...@gmx.de>.
Hello Jeanine,

either change the name of the attribute of the image from 'id' to 'name' 
or change the javascript to 
"window.document.getElementById('picture1').src=image;".

Regards,

Joerg


Jeanine Meyer wrote:
> Hello,
> (Forgive any redundancy with previous messages.)
> I'm having problems with what I think is a simple task: recreating the 
> standard image swap in on mouse over.
> I have other examples of xml citing xsl working using IE6 and also NS6.2.
> However, in this example, the javascript function doesn't seem to be 
> called.
> Also, when I use saxon, a file is produced that works in NS6.2 but not 
> in IE6.
> Here is the xml file:
> <?xml version="1.0" ?>
> <?xml-stylesheet href="mouseover2.xsl" type="text/xsl"?>
> 
> <pictures>
>  <oimage>Liz-book.jpg</oimage>
>  <nimage>Darcy3.jpg</nimage>
> </pictures>
> ***************mouseover2.xsl
> <?xml version="1.0" ?>
> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version="1.0">
> <xsl:output method="html" />
> <xsl:template match="/pictures">
> <html>
> <head>
> <title> Rollover test </title>
> <script language="JavaScript" type="text/javascript" src="movein.js">
> </script>
> </head>
> <body>
> <xsl:element name="a">
>  <xsl:attribute name="href"></xsl:attribute>
>  <xsl:attribute name="onMouseOver">movein('<xsl:value-of 
> select="nimage"/>');</xsl:attribute>
>  <xsl:attribute name="onMouseOut">movein('<xsl:value-of 
> select="oimage"/>');</xsl:attribute>
>  <xsl:attribute name="onClick">return false;</xsl:attribute>
>  <xsl:element name="img">
>    <xsl:attribute name="src"><xsl:value-of 
> select="oimage"/></xsl:attribute>
>    <xsl:attribute name="id">picture1</xsl:attribute>
>  </xsl:element>
> </xsl:element>
> </body>
> </html>
> </xsl:template>
> </xsl:transform>
> *************the result of using saxon
> <html>
>   <head>
>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
>  
>      <title> Rollover test </title><script language="JavaScript" 
> type="text/javascript" src="movein.js"></script></head>
>   <body><a href="" onMouseOver="movein('Darcy3.jpg');" 
> onMouseOut="movein('Liz-book.jpg');" onClick="return false;"><img 
> src="Liz-book.jpg" id="picture1"></a></body>
> </html>
> ************movein.js
> function movein(image)
> {
> window.document.picture1.src=image;
> }
> 
> 
> I get the same results when I put in the function movein.js directly in 
> the mouseover.xsl (that is, when the resulting html doesn't use an external
> javascript, but a local one).
> 
> HELP.
> thanks,
> Jeanine Meyer


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

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


RE: newbie: xsl - xsp - transformation

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: daniel meier [mailto:krams@krims.ch]
> 
> hi there
> 
> 
> 
> 
> 
> I'm using the stream-generator, which produces this document:
> the sitemap looks like this:
> 
> <map:match pattern="**.req">
> <map:generate type="stream"/>
> <map:transform src="stylesheets/req2xml.xsl"/>
> <map:serialize type="xml"/>
> </map:match>
> 
> 
> the stream gives sends this to the stylesheet:
> 
>
<login><username>daniel</username><password>thepassword</password></logi
n>
> 
> then I'm doing some xsl-transformation:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <xsl:template match="login">
>   <xsp:page create-session="yes" language="java"
> xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-session="http://apache.org/xsp/session/2.0">
>     <loginreply>
>       <xsp-session:set-attribute
> name="username">krams@krims.ch</xsp-session:set-attribute>
>       <xsp-session:set-max-inactive-interval interval="500"/>
>       <status>ok</status>
>       <sessionid><xsp-session:get-id /></sessionid>
>       <username><xsp-session:get-attribute
name="username"/></username>
>     </loginreply>
>   </xsp:page>
> </xsl:template>
> 
> <xsl:template match="@*|*|text()|processing-instruction()">
>   <xsl:copy>
>     <xsl:apply-templates select="@*|*|text()|processing-instruction()"
/>
>   </xsl:copy>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> 
> I get the following back:
> 
> <xsp:page xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-session="http://apache.org/xsp/session/2.0" language="java"
> create-session="yes">
> <loginreply>
>   <xsp-session:set-attribute
> name="username">krams@krims.ch</xsp-session:set-attribute>
>   <xsp-session:set-max-inactive-interval interval="500" />
>   <status>ok</status>
>   <sessionid><xsp-session:get-id /></sessionid>
>   <username><xsp-session:get-attribute name="username" /></username>
> </loginreply>
> </xsp:page>
> 
> which is perfectly ok.
> 
> but now how do I tell cocoon that it processes the xsp and the
xsp-session
> stuff? as I understood I cannot use a second generator.
> do I have to create some kind of logicsheet? if yes, how should it
look
> like?

See http://localhost:8080/cocoon/sub/xsp-dynamic, and its sitemap.

You must also realize that this approach you chose is slow, or *very*
slow (depends on your pockets, of course). Two-line action will do the
same in almost no time.


Vadim



> kind regards
> 
> daniel



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

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


newbie: xsl - xsp - transformation

Posted by daniel meier <kr...@krims.ch>.
hi there





I'm using the stream-generator, which produces this document:
the sitemap looks like this:

<map:match pattern="**.req">
<map:generate type="stream"/>
<map:transform src="stylesheets/req2xml.xsl"/>
<map:serialize type="xml"/>
</map:match>


the stream gives sends this to the stylesheet:

<login><username>daniel</username><password>thepassword</password></login>

then I'm doing some xsl-transformation:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="login">
  <xsp:page create-session="yes" language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-session="http://apache.org/xsp/session/2.0">
    <loginreply>
      <xsp-session:set-attribute
name="username">krams@krims.ch</xsp-session:set-attribute>
      <xsp-session:set-max-inactive-interval interval="500"/>
      <status>ok</status>
      <sessionid><xsp-session:get-id /></sessionid>
      <username><xsp-session:get-attribute name="username"/></username>
    </loginreply>
  </xsp:page>
</xsl:template>

<xsl:template match="@*|*|text()|processing-instruction()">
  <xsl:copy>
    <xsl:apply-templates select="@*|*|text()|processing-instruction()" />
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>



I get the following back:

<xsp:page xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-session="http://apache.org/xsp/session/2.0" language="java"
create-session="yes">
<loginreply>
  <xsp-session:set-attribute
name="username">krams@krims.ch</xsp-session:set-attribute>
  <xsp-session:set-max-inactive-interval interval="500" />
  <status>ok</status>
  <sessionid><xsp-session:get-id /></sessionid>
  <username><xsp-session:get-attribute name="username" /></username>
</loginreply>
</xsp:page>

which is perfectly ok.

but now how do I tell cocoon that it processes the xsp and the xsp-session
stuff? as I understood I cannot use a second generator.
do I have to create some kind of logicsheet? if yes, how should it look
like?

kind regards

daniel





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

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


RE: XML/XSLT to html including JavaScript question

Posted by George Pieri <ge...@wcom.com>.




Is your javascript function being called at all ?
If you hardcode a simple javascript helloworld function
with an alert('Hello') in it within the same xsl file will
you see the popup ?

I have gotten this to work using external files below is
a sample of my xls which will call a javascript function on
events for a table cell....

   <script language="javascript" src="resources/wcomView.js"></script>
   <TD>
             <xsl:attribute name="onmouseover"><xsl:value-of
select="//VIEW/EVENTS/@cellMouseOver"/></xsl:attribute>
             <xsl:attribute name="onmouseout"><xsl:value-of
select="//VIEW/EVENTS/@cellMouseOut"/></xsl:attribute>
             <xsl:attribute name="onclick"><xsl:value-of
select="//VIEW/EVENTS/@cellClick"/></xsl:attribute>


Good luck :>


-----Original Message-----
From: Jeanine Meyer [mailto:vze2s839@verizon.net]
Sent: Thursday, July 25, 2002 3:06 PM
To: george.pieri@wcom.com
Subject: XML/XSLT to html including JavaScript question


Hello,
(Forgive any redundancy with previous messages.)
I'm having problems with what I think is a simple task: recreating the
standard image swap in on mouse over.
I have other examples of xml citing xsl working using IE6 and also NS6.2.
However, in this example, the javascript function doesn't seem to be called.
Also, when I use saxon, a file is produced that works in NS6.2 but not
in IE6.
Here is the xml file:
<?xml version="1.0" ?>
<?xml-stylesheet href="mouseover2.xsl" type="text/xsl"?>

<pictures>
  <oimage>Liz-book.jpg</oimage>
  <nimage>Darcy3.jpg</nimage>
</pictures>
***************mouseover2.xsl
<?xml version="1.0" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" />
<xsl:template match="/pictures">
<html>
<head>
<title> Rollover test </title>
<script language="JavaScript" type="text/javascript" src="movein.js">
</script>
</head>
<body>
<xsl:element name="a">
  <xsl:attribute name="href"></xsl:attribute>
  <xsl:attribute name="onMouseOver">movein('<xsl:value-of
select="nimage"/>');</xsl:attribute>
  <xsl:attribute name="onMouseOut">movein('<xsl:value-of
select="oimage"/>');</xsl:attribute>
  <xsl:attribute name="onClick">return false;</xsl:attribute>
  <xsl:element name="img">
    <xsl:attribute name="src"><xsl:value-of
select="oimage"/></xsl:attribute>
    <xsl:attribute name="id">picture1</xsl:attribute>
  </xsl:element>
</xsl:element>
</body>
</html>
</xsl:template>
</xsl:transform>
*************the result of using saxon
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <title> Rollover test </title><script language="JavaScript"
type="text/javascript" src="movein.js"></script></head>
   <body><a href="" onMouseOver="movein('Darcy3.jpg');"
onMouseOut="movein('Liz-book.jpg');" onClick="return false;"><img
src="Liz-book.jpg" id="picture1"></a></body>
</html>
************movein.js
function movein(image)
{
window.document.picture1.src=image;
}


I get the same results when I put in the function movein.js directly in
the mouseover.xsl (that is, when the resulting html doesn't use an external
javascript, but a local one).

HELP.
thanks,
Jeanine Meyer


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

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


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

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>