?
Solved

XSLT and Javascript

Posted on 2004-11-04
11
Medium Priority
?
382 Views
Last Modified: 2013-12-16
I have an XSL template that includes a javascript file in it. When it was just a plain old HTML file the script worked great, now that its been transferred to XSL my table alignment is a little messed up and none of my javascript works. Heres how I declared my script:

<script language="text/javascript" src="WebNoteScript.js" type="text/javascript"></script>

It's in the <head> and everything, I just can't figure out the problem. Thanks in advance,

<3 gf3
0
Comment
Question by:gf3
11 Comments
 
LVL 15

Expert Comment

by:dualsoul
ID: 12502138
hm..post complete xslt source, and xml sample to work with.

if you have all your JavaScript in external file, it's very strange you have a problem.

0
 
LVL 35

Expert Comment

by:YZlat
ID: 12507329
you will need something like this at the beginning of your cslt file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                    xmlns:mypref="urn:rdcpro-com:mypref">
   <xsl:output method="html" encoding="UTF-8"/>
     <msxsl:script language="JScript" implements-prefix="mypref">
          <![CDATA[
                 
....
your javascript code goes here
..........

          ]]>
     </msxsl:script>  
0
 
LVL 1

Author Comment

by:gf3
ID: 12513311
Sorry, but this can't be msxml at all because it is going to be built on a linux host, specifically for linux clients. I'll post relevant code below:

+XSL+
=====
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
      <title>WebNoteOne v0.1 [BETA]</title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <link href="WebNoteStyle.css" rel="stylesheet" type="text/css" />
      <script language="text/javascript" src="WebNoteScript.js" type="text/javascript"></script>
</head>
<body bgcolor="#FFFFFF">
. . .
. . .



+XML+
=====
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "http://logik.bm3.org/WebNote/note.dtd">
<?xml-stylesheet type="text/xsl" href="WebNoteOne.xsl"?>

<note id="note0001" binder="TestSubject">

<header>
      <title>Test Note</title>
      <subTitle>For Testing WebNoteOne Software</subTitle>
</header>
. . .
. . .

Thats the top of my code. I've had it all validated, and I get no errors on anything. It's all correctly declared and the xHTML/dHTML is correct. I have no idea what the problem is?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:JonathanJonas
ID: 12519523
gf3,

Quick question for you - is your stylesheet being picked up?

If neither your stylesheet nor your javascript is getting picked up, I'd suspect the link to include them.

Is your XSL/XML getting transformed by a server-side language? If it is, does it have a different document root to the folder that these XML and XSL are in? You might have to put the realtive path from the document root to the .js and .css if that is the case.

Cheers,

Jonathan
0
 
LVL 1

Author Comment

by:gf3
ID: 12520507
Yes they stylesheet is being picked up. Same with the css. But it looks like an extra space was added before the main table or something, it isn't aligned right. But the stylesheet *is* being picked up, and displayed.
0
 
LVL 2

Expert Comment

by:JonathanJonas
ID: 12528179
If you put a tag like this in your <head> section:

<SCRIPT language="JavaScript"><xsl:comment>
<![CDATA[

//<!-- Include the javascript here -->

//]]></xsl:comment>
</SCRIPT>

and include the javascript from the external file in it, does that work for you?

I know it's not really answering your question but it might give you more information.

Cheers,

Jonathan
0
 
LVL 1

Author Comment

by:gf3
ID: 12529454
Still no good. I can e-mail someone the full source if they would like to see, I think it may be a little too long to post here.
0
 
LVL 1

Author Comment

by:gf3
ID: 12529502
The <![CDATA[ ... ]]> works for commenting out the Javascript (the same way that <!-- ... --> works) but for some reason it still wont give me functionality.
0
 
LVL 2

Accepted Solution

by:
JonathanJonas earned 1000 total points
ID: 12539133
You can email it to me if you like:

jjjonas_23 at y a h o o . com

Cheers,

Jonathan
0
 
LVL 2

Expert Comment

by:JonathanJonas
ID: 12580610
So the XSL I sent you looked okay and the javascript ran alright apart from that whitespace problem?

I had a look to try to spot what that could be without any luck.

Cheers,

JJ
0
 
LVL 1

Author Comment

by:gf3
ID: 12583534
Well thank-you *very* much for your help, it was greatly appreciated!

<3 gf3
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question