473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

post a parameter dom to xsl for 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.responseXML;
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('Microsoft.XMLDOM');
xmlDoc.async = false;
xmlDoc.load(xmlFile);

//load xsl file
xsltDoc = new ActiveXObject('Microsoft.XMLDOM');
xsltDoc.async = false;
xsltDoc.load(xsltFile);

//append the xml result to the main html file
var target=document.getElementById("divContent");
target.innerHTML = xmlDoc.documentElement.transformNode(xsltDoc);
}
}
</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>ccc</test>
</root>

In Safari, the output is [object Document] --It changes to
string$B!$(Bbut in IE and
Firefox, the output is aaa.

Could someone help me? Thanks!
Aug 15 '08 #1
5 3473
Jason wrote:
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>ccc</test>
</root>

In Safari, the output is [object Document] --It changes to
string$B!$(Bbut in IE and
Firefox, the output is aaa.
For you IE you do not even set the parameter testDom before the
transformation so why should IE output something for <xsl:value-of
select="$testDom"/>? That does not make sense.
And why should Firefox output 'aaa' if the 'test' element in the
document contains 'ccc'? That does not make sense either.

What exactly is it that you want to achieve? If you have a primary input
document for your XSLT transformation then why do you want to pass the
same document as a parameter? That does not make much sense either,
unless you want to test whether the XSLT implementation supports passing
in a DOM document as the parameter.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 15 '08 #2
On 8ÔÂ15ÈÕ, ÏÂÎç7ʱ00·Ö, Martin Honnen <mahotr...@yahoo.dewrote:
Jason wrote:
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>ccc</test>
</root>
In Safari, the output is [object Document] --It changes to
string£¬but in IE and
Firefox, the output is aaa.

For you IE you do not even set the parameter testDom before the
transformation so why should IE output something for <xsl:value-of
select="$testDom"/>? That does not make sense.
And why should Firefox output 'aaa' if the 'test' element in the
document contains 'ccc'? That does not make sense either.

What exactly is it that you want to achieve? If you have a primary input
document for your XSLT transformation then why do you want to pass the
same document as a parameter? That does not make much sense either,
unless you want to test whether the XSLT implementation supports passing
in a DOM document as the parameter.

--

Martin Honnen
http://JavaScript.FAQTs.com/- Òþ²Ø±»ÒýÓÃÎÄ×Ö -

- ÏÔʾÒýÓõÄÎÄ×Ö -
Hi,
I'm sorry,the xml file should be as following:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<test>aaa</test>
</root>

You are right. I want to test whether the XSLT implementation supports
passing
in a DOM document as the parameter.
Could you help me have a look at the issue? Any help will be much
appreciated.
Aug 17 '08 #3
On 8ÔÂ17ÈÕ, ÏÂÎç5ʱ58·Ö, Jason <ydsh...@gmail.comwrote:
On 8ÔÂ15ÈÕ, ÏÂÎç7ʱ00·Ö, Martin Honnen <mahotr...@yahoo.dewrote:


Jason wrote:
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>ccc</test>
</root>
In Safari, the output is [object Document] --It changes to
string£¬but in IE and
Firefox, the output is aaa.
For you IE you do not even set the parameter testDom before the
transformation so why should IE output something for <xsl:value-of
select="$testDom"/>? That does not make sense.
And why should Firefox output 'aaa' if the 'test' element in the
document contains 'ccc'? That does not make sense either.
What exactly is it that you want to achieve? If you have a primary input
document for your XSLT transformation then why do you want to pass the
same document as a parameter? That does not make much sense either,
unless you want to test whether the XSLT implementation supports passing
in a DOM document as the parameter.
--
Martin Honnen
http://JavaScript.FAQTs.com/-Òþ²Ø±»ÒýÓÃÎÄ×Ö -
- ÏÔʾÒýÓõÄÎÄ×Ö -

Hi,
I'm sorry,the xml file should be as following:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<test>aaa</test>
</root>

You are right. I want to test whether the XSLT implementation supports
passing
in a DOM document as the parameter.
Could you help me have a look at the issue? Any help will be much
appreciated.- Òþ²Ø±»ÒýÓÃÎÄ×Ö -

- ÏÔʾÒýÓõÄÎÄ×Ö -
And the html should be like as following:
[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.responseXML;
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>
Aug 17 '08 #4
Jason wrote:
You are right. I want to test whether the XSLT implementation supports
passing
in a DOM document as the parameter.
Could you help me have a look at the issue? Any help will be much
appreciated.
Based on your test result it sounds as if Safari converts the DOM
document node to a string and passes that string in.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 17 '08 #5
On 8ÔÂ17ÈÕ, ÏÂÎç6ʱ50·Ö, Martin Honnen <mahotr...@yahoo.dewrote:
Jason wrote:
You are right. I want to test whether the XSLT implementation supports
passing
in a DOM document as the parameter.
Could you help me have a look at the issue? Any help will be much
appreciated.

Based on your test result it sounds as if Safari converts the DOM
document node to a string and passes that string in.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Hi Martin,
Yes, Safari converts the DOM document node to a string and passes the
string in. I can use the following code to test it.
[code]
var testDom = xslt.getParameter(null,'testDom')
alert(typeof(testDom))

It ouputs string.
Aug 18 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bernard | last post by:
Hi, I am suddenly getting Safari script errors with the following user agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML, like Gecko) Safari/125.8 In a...
8
by: Giuseppe Chielli | last post by:
Hi to everyone? Can someone tell me if there is a way to identify Safari...I found out that navigator.appName returns "Netscape" and I didn't found any option to change the browser's definition......
4
by: Paul W | last post by:
Hi - can someone point me to info on the issues/resolutions of supporting the safari browser? To help me understand, if I was developing pages in say FrontPage, what attributes would I set for...
1
by: gerry | last post by:
Hi, although this is not strictly asp.net related, I was hoping that someone could confirm or debunk what appears to be a major problem with safari POSTs. with the following html : <!DOCTYPE...
5
by: Bill Cohagan | last post by:
I'm having some serious difficulties with my ASP.Net 2.0 app rendering in Safari 2.0.3. The most immediate problem is that the menu control doesn't seem to work at all, particularly the use of...
34
by: Simon Wigzell | last post by:
document...focus() will scroll the form to move the specified text field into view on everything I have tried it with except Safari on the MAC. The form doesn't move. Any work around? Thanks.
21
by: Edward | last post by:
Hi All, I feel frustrated with one of my Customers who wants me to ensure that a dotnet web site I am building for them must be compatible to Apple's Safari browser! Safari is buggy and it...
1
by: rynato | last post by:
I ran into an interesting problem while working on a form: I have a drop down list (think <form><select><option>...) of 'open sessions' which a user can choose from to continue entering data....
3
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
In the page_load event i need to see which event fired the post back. what here allows this. I specificly want to know if the enter key was pressed. but i need to check for others. -- (i''ll be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.