#1
  1. I fail at spelling
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Sep 2003
    Location
    NDAuNjIxMTExLC03OS4xNTU=
    Posts
    3,232
    Rep Power
    1775

    XSL inline Javascript with the > being used


    I know that I must be missing something basic here. Assume that I have my XML right and it's all happy.

    Here's what I got for my XSL and I can't for the life of me figure out what it's complaining about.

    Code:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:template match="/">
      <script text="text/javascript">
        <![CDATA[
        var test = 1;
        if(test < 2){
          alert("it is less than 2");
        }
        ]]>
      </script>
    </xsl:template>
    Now this is a demo (obviously) just to illustrate what I'm trying to do. Can anyone give me some help on why the following error is happening?

    Code:
    missing ) after condition
    if(test & lt; 2){
    The & and lt; have been separated because devshed keeps putting it as <

    I thought that CDATA would just ignore the < and not convert it. Is that what javascript is complaining about?

    Thanks,
    Chad
    I am working now with Symfony2, Twig, Doctrine, Composer, Assetic, and HTML5. Enjoying doing what I do everyday!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    191
    Rep Power
    49
    you will create html code
    so must set xsl:output to
    Code:
    <xsl:output indent="yes" method="html"/>
    default is xml output

    Code:
    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes" method="html"/>
    <xsl:template match="/">
    	<script text="text/javascript">
        <![CDATA[
        var test = 1;
        if(test < 2){
          alert("it is less than 2");
        }
        ]]>
    </script>
    </xsl:template>
    
    </xsl:stylesheet>
    Code:
    <script text="text/javascript">
        
        var test = 1;
        if(test < 2){
          alert("it is less than 2");
        }
        
    
    </script>
    xml output become to &amp;lt;
    html output to <
    Last edited by xml-profi; February 20th, 2011 at 08:34 AM.
    Helmut Hagemann Germany

    fallen to the bottom of the facts?
    I reach my hand and we go together


    wer lesen und google kann ist klar im Vorteil
    who read and google is able is clear in the advantage
  4. #3
  5. I fail at spelling
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Sep 2003
    Location
    NDAuNjIxMTExLC03OS4xNTU=
    Posts
    3,232
    Rep Power
    1775
    Hmm, still not working it's still converting it.

    I'm using a jQuery add-on to do the xslt conversion. I wonder if that's what's causing this issue.
    I am working now with Symfony2, Twig, Doctrine, Composer, Assetic, and HTML5. Enjoying doing what I do everyday!

IMN logo majestic logo threadwatch logo seochat tools logo