Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 18th, 2008, 09:06 PM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Post a parameter to XSL in Safari

Hi all,
Are you familiar with Safari? I have a site that works perfectly in
IE6 IE7 FF2 FF3 but not in the
latest Safari. When I test xsltProcessor, there is a error as
following, I have dealt with this issue for several days, but there is
no result. Could someone help me?
[Code]
<html>
<head>
    <title>Enter the title of your HTML document here</title>
    <script type="text/javascript">
      var xmlDoc;
      var xsltDoc;
      var xmlFile="Test_xsltProcessor.xml";
      var xsltFile="Test_xsltProcessor.xsl";

      function show_xml()
      {
        // Firefox, Opera 8.0+, Safari
        if(document.implementation &&
document.implementation.createDocument)
        {
           //load xml file
           XMLDocument.prototype.load = function(filePath)
           {
              var xmlhttp = new XMLHttpRequest();
              xmlhttp.open("GET", filePath, false);
              xmlhttp.setRequestHeader("Content-Type","text/xml");
              xmlhttp.send(null);
              var newDOM = xmlhttp.respon****ML;
              if( newDOM )
             {
               var newElt = this.importNode(newDOM.documentElement,
true);
               this.appendChild(newElt);
               return true;
            }
         }
         xmlDoc = document.implementation.createDocument("", "",
null);
         xmlDoc.async = false;
         xmlDoc.load(xmlFile);


         //load xsl file
         var xsltDoc = document.implementation.createDocument("",
"", null);
         xsltDoc.async = false;
         xsltDoc.load(xsltFile);


         //build the relationship between xml file and xsl file
         var xslt = new XSLTProcessor();
         xslt.importStylesheet(xsltDoc);


         //set parameters
        xslt.setParameter( null, 'testDom', xmlDoc);


        //transform
        var doc = xslt.transformToFragment(xmlDoc, document);
        //append the xml result to the main html file
        var target=document.getElementById("divContent");
        while (target.hasChildNodes())
        {
            target.removeChild(target.lastChild);
        }
        target.appendChild(doc);
      }
      else if(typeof window.ActiveXObject != 'undefined')
      {
         //load xml file
         xmlDoc = new ActiveXObject( "MSXML2.FreeThreadedDomDocument.
3.0" );
        xmlDoc.async = false;
        xmlDoc.load(xmlFile);


        //load xsl file
        xsltDoc = new ActiveXObject( "MSXML2.FreeThreadedDomDocument.
3.0" );
        xsltDoc.async = false;
        xsltDoc.load(xsltFile);


        var template = new ActiveXObject( "MSXML2.XSLTemplate.
3.0" );
        template.stylesheet = xsltDoc;
        var processor = template.createProcessor();
        processor.input = xmlDoc;
        processor.addParameter("testDom",xmlDoc);
        processor.transform();


        //append the xml result to the main html file
        var target=document.getElementById("divContent");
        target.innerHTML = processor.output;;
       }
    }
    </script>
</head>
<body onload="show_xml();">
    <p>Enter the body text of your HTML document here</p>
    <div id="divContent"></div>
</body>
</html>


The xsl file is as following:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
  <xsl:param name="testDom"/>
  <xsl:template match="/">
    <div>
      <xsl:value-of select="$testDom"/>
    </div>
  </xsl:template>
</xsl:stylesheet>


The xml file is as following:
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <test>aaa</test>
</root>


In Safari, the output is [object Document] --It changes to
string£¬but in IE and
Firefox, the output is aaa.


Could someone help me? Any help will be much appreciated.



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
How to increment/decrement a parameter in XSL tclotworthy XSLT 2 February 9th, 2007 04:24 PM
passing parameter to xsl file anandjun XSLT 3 March 24th, 2006 02:46 PM
XSL - Parameter query. Neal XSLT 4 January 24th, 2006 01:27 PM
XSL Parameter xsl:param Harinath Chikoti XSLT 1 May 6th, 2005 03:15 AM



All times are GMT -4. The time now is 04:53 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.