XSLT and Javascript

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
LVL 1
gf3Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dualsoulCommented:
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
YZlatCommented:
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
gf3Author Commented:
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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

JonathanJonasCommented:
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
gf3Author Commented:
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
JonathanJonasCommented:
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
gf3Author Commented:
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
gf3Author Commented:
The <![CDATA[ ... ]]> works for commenting out the Javascript (the same way that <!-- ... --> works) but for some reason it still wont give me functionality.
0
JonathanJonasCommented:
You can email it to me if you like:

jjjonas_23 at y a h o o . com

Cheers,

Jonathan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JonathanJonasCommented:
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
gf3Author Commented:
Well thank-you *very* much for your help, it was greatly appreciated!

<3 gf3
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.