SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using java with xsl

    Hello,
    I'm trying to use this script with my xsl but i get parse errors.

    <script type="text/javascript">
    <!--
    function radio_player() {
    props=window.open('radioplayer.php?lang=&z=wmp&con fig=config', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=320, height=142 left = 100, top = 100');
    }
    // -->
    </script>
    <xsl:stylesheet xmlnssl = "w3.org/1999/XSL/Transform" version = "1.0" >
    <xslutput omit-xml-declaration="no" method="html" doctype-public="-//W3C//DTD XHTML 1.0 Strict encoding="UTF-8" />
    <xsl:template match = "/myfolder" >
    <html>
    <head>
    <title>welcome here</title>
    <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    I added javascript inside <head></head> but i got the parse error becuase i had to remove <!-- before function as xsl content between it.
    Thanks for your help

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is that the javascript code interfers with the XML entities.
    You have to put the javascript into a CDATA section
    Code:
    <!CDATA[
    <script type="text/javascript">
    <!--
    function radio_player() {
    props=window.open('radioplayer.php?lang=&z=wmp&con fig=config', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=320, height=142 left = 100, top = 100');
    }
    // -->
    </script> 
    ]]>
    This will tell the XSL parser to ignore everything between the CDATA tags.
    But, it has the inconvenient that you cannot do any <xsl:value-of> inside the javascript.

  3. #3
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your reply,
    i found out that and tried your code, and got this error
    <head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <!CDATA[
    <script type="text/javascript">
    <!--
    function radio_player() {
    props=window.open('radioplayer.php?lang=&z=wmp&con fig=config', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=320, height=142 left = 100, top = 100');
    }
    // -->
    </script>
    ]]>
    </head>
    <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
    <a href="javascript:radio_player()">player</a>
    and got this error
    Could not parse XSLT file
    I've another question, if someone disable apache on a host/ip and run an application on port 80 can we still execute the php scripts?

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I should have both the full XML and the full XSL to help you.
    What I see here, is that you have the <body> element that is opened, but not close.
    You cannot do that in xsl.
    A template must have both the opening and the closing of each element.
    You cannot open the ody in 1 template, and close it in another template.

    As for your 2nd question: no.
    Apache is the application that run the PHP script, so if you shutdown apache, you cannot interpret PHP script anymore through your web browser. Except if you setup another web server to replace apache.

    Or, apache is still running, but on another port, and you have to access it via
    Code:
    http://the.host.com:1234/script.php
    1234 being the port number.

  5. #5
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    by the way
    i thought below is the rightous way to ignore it i tried that but i didn't work either
    <script type="text/javascript">
    <![CDATA[<!--
    function radio_player() {
    props=window.open('myip:newportforapache/radioplayer.php?lang=&z=wmp&con fig=config', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=320, height=142 left = 100, top = 100');
    }
    //-->]]>
    </script>
    xsl was parsed properly and i see the web up but when i checked the sourcecode for web it gave me this
    <script type="text/javascript">
    &lt;!--
    function radio_player() {
    props=window.open('myip:port/radioplayer.php?lang=&amp;z=wmp&amp;con fig=config', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=320, height=142 left = 100, top = 100');
    }
    //--&gt;
    </script>
    probably the highlighted part wast he main reason for javascript not wroking properly.

    P.S i have removed the h t t p part because your forums can't let me submit it and i'm still waiting for my previous post to be answered.

    Thanks for your great help guys appreciated.
    Last edited by maddyy; Oct 11, 2008 at 20:55. Reason: removing smiles

  6. #6
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Those have often caused me headaches, but there is a really simple way to solve it: put the js function into an external .js file, and reference it with
    HTML Code:
    <script type="text/javascript" src="/fx.js"/>
    into your xsl.
    The xsl parser won't go in the .js file, and it will not create errors anymore.

  7. #7
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yea thanks thats what i thought of.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •