|
List Info
Thread: Checking events in time intervals
|
|
| Checking events in time intervals |
  United States |
2007-10-24 06:54:06 |
Hello,
I am experimenting with events. I am trying to start a
discussion
about concepts here, maybe someone has better or more
elegant ways of
doing what I want.
I am trying to execute a piece of code that checks for the
mouse
position and uses these values for a calculation.
However, calculating each time the moseMove event is fired
eats up a
lot of processing power (about 30% on a MBP 2.16GHz).
I am looking for a more or less elegant way to check for the
mouse
position 10 to 50 times a second, based on the users
settings on the
page.
I tried firing events manually but those didn't include the
correct
mouse information (only 0,0 as coordinates).
The solution I have so far is to either add/remove the mouse
event
with a timeout which just feels wrong to do or to set a
variable at
the end of the calculation that is unset on the end of a
timeout.
I hope to hear ideas from you.
Thanks,
Torsten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "JavaScript Forum" group.
To post to this group, send email to
JavaScript-Information googlegroups.com
To unsubscribe from this group, send email to
JavaScript-Information-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/JavaScript-Information
?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Checking events in time intervals |

|
2007-10-24 10:32:41 |
|
hello Torsten
this is the easy way to use mouse positioning in all the browser..........long before when i m using the mouse poitioning problem then i came across the this solution it will met ur requirements........any other issue so let me know with some sample which u have tried then i will try to solve
<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <TITLE></TITLE> </HEAD> <BODY> <script> if (document.layers
) { // Netscape document.captureEvents(Event.MOUSEMOVE); document.onmousemove = captureMousePosition; } else if (document.all) { // Internet Explorer document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6 document.onmousemove = captureMousePosition; }
// Global variables xMousePos = 0; // Horizontal position of the mouse on the screen yMousePos = 0; // Vertical position of the mouse on the screen xMousePosMax = 0; // Width of the page yMousePosMax = 0; // Height of the page
function captureMousePosition(e) { if (document.layers) { xMousePos = e.pageX; yMousePos = e.pageY; xMousePosMax = window.innerWidth+window.pageXOffset; yMousePosMax =
window.innerHeight+window.pageYOffset; } else if (document.all) { xMousePos = window.event.x+document.body.scrollLeft; yMousePos = window.event.y+document.body.scrollTop; xMousePosMax =
document.body.clientWidth+document.body.scrollLeft; yMousePosMax = document.body.clientHeight+document.body.scrollTop; } else if (document.getElementById) { // Netscape 6 behaves the same as Netscape 4 in this regard
xMousePos = e.pageX; yMousePos = e.pageY; xMousePosMax = window.innerWidth+window.pageXOffset; yMousePosMax = window.innerHeight+window.pageYOffset; } window.status
= "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax; } </script> </BODY> </HTML>
On 10/24/07, Torsten M. Walter < twalter80 googlemail.com">twalter80 googlemail.com> wrote:
Hello,
I am experimenting with events. I am trying to start a discussion about concepts here, maybe someone has better or more elegant ways of
doing what I want.
I am trying to execute a piece of code that checks for the mouse position and uses these values for a calculation. However, calculating each time the moseMove event is fired eats up a
lot of processing power (about 30% on a MBP 2.16GHz). I am looking for a more or less elegant way to check for the mouse position 10 to 50 times a second, based on the users settings on the page.
I tried firing events manually but those didn't include the correct
mouse information (only 0,0 as coordinates).
The solution I have so far is to either add/remove the mouse event with a timeout which just feels wrong to do or to set a variable at the end of the calculation that is unset on the end of a timeout.
I hope to hear ideas from you.
Thanks,
Torsten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group. To post to this group, send email to JavaScript-Information googlegroups.com To unsubscribe from this group, send email to JavaScript-Information-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/JavaScript-Information?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: Checking events in time intervals |
  United States |
2007-10-24 12:58:27 |
Hi Abhimanyu,
thanks for trying to help but you might have misread my
post.
I know perfectly well how to register and capture events.
I have a custom library for browser agnostic event
handling.
My mouse position function works perfectly:
var getMousePos = function(evt) {
/**
* params: event evt
* returns: position object {left:n, top:n, x:n, y:n}
* x equals absolute screen position from the left of the
document
* y equals absolute screen position from the top of the
document
* note that the position is calculated RELATIVE TO THE
DOCUMENT,
* rather than relative to the window
*/
var e = (!evt) ? window.event : evt;
var pos = {left:0, top:0,x:0, y:0};
if (e.pageX || e.pageY) {
pos.x = e.pageX;
pos.y = e.pageY;
}
else if (e.clientX || e.clientY) {
pos.x = e.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
pos.y = e.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;
}
pos.left = pos.x;
pos.top = pos.y;
return pos;
}
My script looks similar to this:
function shadeIt (pos) {
// do lots of stuff here
}
function getMousePosition (e) {
var pos = getMousePos(e);
shadeIt(pos);
}
window.onload = function() {
addEvent("mousemove", getMousePosition);
// register more events
}
The addEvent() function is a custom helper function that
adds events
based on number of parameters and browser type and version.
var addEvent = function(a) {
/**
* params: event, callback function
* params: event, callback function, element
* params: event, callback function, execute while
Active
* params: event, callback function, element, execute
while Active
* returns: void
* function can be called with different arguments.
* function automatically checks for browser and attaches
* the event appropriately
* events need to be passed by name without the
"on" part
* example "onMouseOver" is passed as
"mouseover"
*/
var evt; // the event
var cb; // callback function
var el; // element to receive the listener
var wa; // execute while active?
switch(arguments.length) {
/*
...
*/
default:
alert("addEventnnNot enough arguments
provided!")
}
var client = checkBrowser();
if (client) {
el.addEventListener(evt, cb, wa);
}
else if (!client) {
el.attachEvent("on"+evt, cb);
}
}
var removeEvent = function(evt, cb, el, uc) {
var client = checkBrowser();
if (client) {
el.removeEventListener(evt, cb, uc);
}
else if (!client) {
el.detachEvent("on"+evt, cb);
}
}
The point I was thinking about is the number of event
captures in a
given time.
You see that anytime I move the mouse lots of calculations
have to be
carried out.
My tought was to somehow limit the capturing of the mouse
position to
a limited number within a certain time (i.e. 25 times per
minute) so
the processor is free for other calculations that I want to
add to
this script as well.
Thanks,
Torsten
On Oct 24, 5:32 pm, "abhimanyu singh"
<er.abhima... gmail.com> wrote:
> hello *Torsten*
> *this is the easy way to use mouse positioning in all
the
> browser..........long before when i m using the mouse
poitioning problem
> then i came across the this solution it will met ur
requirements........any
> other issue so let me know with some sample which u
have tried then i will
> try to solve *
> **
>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR"
Content="Microsoft Visual Studio 6.0">
> <TITLE></TITLE>
> </HEAD>
> <BODY>
> <script>
> if (document.layers) { // Netscape
> document.captureEvents(Event.MOUSEMOVE);
> document.onmousemove = captureMousePosition;} else
if (document.all) { // Internet Explorer
>
> document.onmousemove = captureMousePosition;} else
if (document.getElementById) { // Netcsape 6
>
> document.onmousemove = captureMousePosition;
>
> }
>
> // Global variables
> xMousePos = 0; // Horizontal position of the mouse on
the screen
> yMousePos = 0; // Vertical position of the mouse on the
screen
> xMousePosMax = 0; // Width of the page
> yMousePosMax = 0; // Height of the page
>
> function captureMousePosition(e) {
> if (document.layers) {
> xMousePos = e.pageX;
> yMousePos = e.pageY;
> xMousePosMax =
window.innerWidth+window.pageXOffset;
> yMousePosMax =
window.innerHeight+window.pageYOffset;
> } else if (document.all) {
> xMousePos =
window.event.x+document.body.scrollLeft;
> yMousePos =
window.event.y+document.body.scrollTop;
> xMousePosMax =
document.body.clientWidth+document.body.scrollLeft;
> yMousePosMax =
document.body.clientHeight+document.body.scrollTop;
> } else if (document.getElementById) {
> // Netscape 6 behaves the same as Netscape 4 in
this regard
> xMousePos = e.pageX;
> yMousePos = e.pageY;
> xMousePosMax =
window.innerWidth+window.pageXOffset;
> yMousePosMax =
window.innerHeight+window.pageYOffset;
> }
> window.status = "xMousePos=" + xMousePos
+ ", yMousePos=" + yMousePos +
> ", xMousePosMax=" + xMousePosMax + ",
yMousePosMax=" + yMousePosMax;}
>
> </script>
> </BODY>
> </HTML>
> **
>
> On 10/24/07, Torsten M. Walter <twalte... googlemail.com> wrote:
>
>
>
> > Hello,
>
> > I am experimenting with events. I am trying to
start a discussion
> > about concepts here, maybe someone has better or
more elegant ways of
> > doing what I want.
>
> > I am trying to execute a piece of code that checks
for the mouse
> > position and uses these values for a calculation.
> > However, calculating each time the moseMove event
is fired eats up a
> > lot of processing power (about 30% on a MBP
2.16GHz).
> > I am looking for a more or less elegant way to
check for the mouse
> > position 10 to 50 times a second, based on the
users settings on the
> > page.
>
> > I tried firing events manually but those didn't
include the correct
> > mouse information (only 0,0 as coordinates).
>
> > The solution I have so far is to either add/remove
the mouse event
> > with a timeout which just feels wrong to do or to
set a variable at
> > the end of the calculation that is unset on the
end of a timeout.
>
> > I hope to hear ideas from you.
>
> > Thanks,
>
> > Torsten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "JavaScript Forum" group.
To post to this group, send email to
JavaScript-Information googlegroups.com
To unsubscribe from this group, send email to
JavaScript-Information-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/JavaScript-Information
?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Checking events in time intervals |

|
2007-11-02 08:44:50 |
|
hello all,
i m facing a serious probs now a days............
its seems easy but for me i found it difficult.........
i want to do transformation usig xsl and xml(adding parameter).
for IE its working fine but for other browser like-firefox,opera its not working.........
i m giving u my complete xml,xsl and transformation code....u only paste and check why it is not working for other browser.....and correct it and let me know......this is really a big challenege for us.....
what my openion:- the way we are adding parameter is going wrong..........
//emp.xml
<?xml version="1.0"?> <?xml-stylesheet type='text/xsl9; href='emp.xsl';?> <employee>
<employee1> <first>Abhimanyu</first> <last>Singh</last> <sex>male</sex> <dob>5Aug1983</dob> <lang>Hindi</lang>
</employee1>
<employee1> <first>Abhishek</first> <last>Tyagi</last> <sex>male</sex> <dob>1Sep1983</dob> <lang>English</lang>
</employee1> <employee1> <first>Ajay</first> <last>Gupta</last> <sex>male</sex> <dob>4Nov1983</dob> <lang>marathi</lang>
</employee1> <employee1> <first>Mukund</first> <last>Gupta</last> <sex>male</sex> <dob>3Mar1981</dob> <lang>english</lang>
</employee1>
</employee>
---------------------------------------------------------------------------------------------------------------------
emp.xsl
<? xml version="
1.0"?>
< xsl:stylesheet version="
1.0" xmlns sl="
http://www.w3.org/1999/XSL/Transform"
xmlns:PC="urn:PointCross-GenericFunctions"
>
< xsl:output method="
html"/>
< xsl:param name="
Title" />
< xsl:template match="
/">
< html>
< body>
< h1>
< xsl:value-of select="
$Title"/>
</ h1>
< table border="
1">
< tr bgcolor="
#cccccc">
< th align="
left">
< xsl:value-of select="
PC:ColumnTitle(1)"/>
</ th>
< th align="
left">
< xsl:value-of select="
PC:ColumnTitle(2)"/>
</ th>
< th align="
left"><xsl:value-of select
="PC:ColumnTitle(3)"/>
</ th>
< th align="
left"><xsl:value-of select
="PC:ColumnTitle(4)"/>
</ th>
< th align="
left"><xsl:value-of select
="PC:ColumnTitle(5)"/>
</ th>
</ tr>
< xsl:for-each select="
employee/employee1">
< tr>
< td><xsl:value-of
select="first"/></
td>
< td><xsl:value-of
select="last"/></
td>
< td><xsl:value-of
select="sex"/></
td>
< td><xsl:value-of
select="dob"/></
td>
< td><xsl:value-of
select="lang"/></
td>
</ tr>
</ xsl:for-each>
</ table>
</ body>
</ html>
</ xsl:template>
</ xsl:stylesheet>
--------------------------------------------------------------------------------------------------------------------------
emp.html
<html> <head > <script type="text/javascript"> function OrchGeneric(){ this.ColumnTitle=_ColumnTitle; }
function _ColumnTitle(Col){ var rtn=""; switch (Col){ case 1: rtn="First Name"; break; case 2: rtn="Last name";
break; case 3: rtn="Sex"; break; case 4: rtn="DOB" break; default: rtn="Lang";
} return rtn; }
var Orch=new OrchGeneric();
function loadXML() { // code for IE
if(window.ActiveXObject) {
try{ var ClientXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument") ClientXML.async = false ClientXML.load("emp.xml") var ClientXSL = new ActiveXObject("
Msxml2.FreeThreadedDOMDocument") ClientXSL.async = false ClientXSL.load("emp.xsl") var xslTemplate=new ActiveXObject("Msxml2.XSLTemplate") xslTemplate.stylesheet=ClientXSL
var xslProcessor=xslTemplate.createProcessor xslProcessor.input=ClientXML ; xslProcessor.addObject(Orch, "urn:PointCross-GenericFunctions" ); xslProcessor.addParameter
("Title", "Employee Record"); xslProcessor.transform(); document.write(xslProcessor.output); //alert(xslProcessor.output);
}catch(e){alert(e)}
}
// code for Mozilla, etc. else if(document.implementation && document.implementation.createDocument)
{ try{ var xslStylesheet; var myDOM; var xmlDoc; var xsltProcessor = new XSLTProcessor(); // load the xslt file, example1.xsl var myXMLHTTPRequest = new XMLHttpRequest();
myXMLHTTPRequest.open("GET","emp.xsl", false); myXMLHTTPRequest.send(null); xslStylesheet = myXMLHTTPRequest.responseXML; xsltProcessor.importStylesheet(xslStylesheet);
// load the xml file, example1.xml myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET","emp.xml", false); myXMLHTTPRequest.send(null); xmlDoc =
myXMLHTTPRequest.responseXML; xsltProcessor.setParameter("urn:PointCross-GenericFunctions","Title",""); var ownerDocument=document.implementation.createDocument("", "test", null);
var newFragment=xsltProcessor.transformToFragment(xmlDoc,document); document.body.appendChild( newFragment); }catch(e){alert(e)}
}
else
{ alert("your browser cannot handle this script"); } } </script> </head> <body onload="loadXML()" > </body> </html>
----------------------------------------------------------------------------------------------------------------------------
please let me know if u encoumnter any issue....................
thanx and regards,
Abhimanyu Singh
--------------------------------------------------------------------------------------------------------------------
On 10/29/07, Torsten M. Walter < twalter80 googlemail.com">twalter80 googlemail.com> wrote:
Hey thanks for this tip.
I have considered all kinds of possibilities but haven't even thought
about using the date object.
Frankly I haven't used it a lot ever, it seems I should give it some more attention.
Thanks a bunch.
On Oct 27, 2:00 am, Jambalaya < chris.ak... gmail.com">
chris.ak... gmail.com> wrote: > On Oct 26, 5:20 am, "Torsten M. Walter" < twalte... googlemail.com">twalte... googlemail.com> > wrote: > > > Thanks Jeff,
> > > I need to try this one out. I don't know how much overhead the > > constant event adding and removing will cause. > > I still need to capture events fairly often, but not on such small
> > increments as the browsers do by default. > > Removing and adding event handlers often sounds processor intensive. > Why not try something like: > > function getMousePosition (e) {
> var thisRun = new Date(); > if (thisRun - getMousePosition.lastRun > 30){ > var pos = getMousePos(e); > shadeIt(pos); > getMousePosition.lastRun = thisRun; > }}
> > getMousePosition.lastRun = new Date(); > > Now your processor intensive code won't fire until the first mousemove > event 30 milliseconds ( 30fps) after the last execution.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group. To post to this group, send email to JavaScript-Information googlegroups.com To unsubscribe from this group, send email to JavaScript-Information-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/JavaScript-Information?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: Checking events in time intervals |
  Germany |
2007-11-05 04:17:04 |
|
|
Hi,
I'd say a reason for nobody answering might be that you posted your query in the wrong topic. Namely in a topic about event handling.
I looked at the group and your messages aren't posted there. I'd suggest opening a new thread with your query.
On topic:
I have no big experience with XSLT, but after a couple of quick tests I have the following results.
- your syntax is odd: It looks as if you are using a generator - which is fine - but the xslt document is not valid and fails therefor in Firefox. removing all the leading spaces in quoted arguments gets rig of most of the problem.
- you are using XMLHTTPRequest to retrieve the XSLT. I think this is okay, but using document.implementation is shorter var process = new XSLTProcessor(); var xslStylesheet = document.implementation.createDocument("", "", null); xslStylesheet.async = false; process.importStylesheet(xslStylesheet);
- the addObject function in IE you are using to process the Table header isn't present in the FF version. I searched the web for something similar but couldn't find anything suitable.
I suggest putting the table header straight into the XSLT will solve the problem
Maybe that helps.
-- mozilla code from emp.html try{ var myDOM; var xmlDoc; var process = new XSLTProcessor(); var xslStylesheet = document.implementation.createDocument("", "", null); xslStylesheet.async = false; xslStylesheet.load("emp.xsl"); process.importStylesheet(xslStylesheet);
myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET","emp.xml", false); myXMLHTTPRequest.send(null);
xmlDoc = myXMLHTTPRequest.responseXML; var newFragment = process.transformToFragment(xmlDoc, document);
document.body.appendChild( newFragment);
}catch(e){alert(e)}
}
-- emp.xslt <?xml version="1.0"?> <xsl:output method="html"/> <xsl:param name="Title" /> <xsl:template match="/"> <html> <body> <h1> <xsl:value-of select="$Title"/> </h1> <table border="1">
<tr bgcolor="#cccccc"> <th align="left"><xsl:value-of select="PC:ColumnTitle(1)"/></th> <th align="left"><xsl:value-of select="PC:ColumnTitle(2)"/></th> <th align="left"><xsl:value-of select="PC:ColumnTitle(3)"/></th> <th align="left"><xsl:value-of select="PC:ColumnTitle(4)"/></th> <th align="left"><xsl:value-of select="PC:ColumnTitle(5)"/></th> </tr>
<xsl:for-each select="employee/employee1"> <tr> <td><xsl:value-of select="first"/></td> <td><xsl:value-of select="last"/></td> <td><xsl:value-of select="sex"/></td> <td><xsl:value-of select="dob"/></td> <td><xsl:value-of select="lang"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Regards,
Torsten Walter __________________________________________________ 3d-M | Online and Offline Media Zum Piepenkerl 2 | 49090 Osnabrück | Germany __________________________________________________ __________________________________________________ email: ttwalter80 gmail.com">ttwalter80 gmail.com
On Nov 5, 2007, at 6:53 AM, abhimanyu singh wrote: hello all, can u help me with my pervious problem......................no comment on this probs
On 11/2/07, abhimanyu singh < er.abhimanyu gmail.com">er.abhimanyu gmail.com> wrote: hello all, i m facing a serious probs now a days............ its seems easy but for me i found it difficult......... i want to do transformation usig xsl and xml(adding parameter). for IE its working fine but for other browser like-firefox,opera its not working......... i m giving u my complete xml,xsl and transformation code....u only paste and check why it is not working for other browser.....and correct it and let me know......this is really a big challenege for us..... what my openion:- the way we are adding parameter is going wrong.......... //emp.xml <?xml version="1.0"?> <?xml-stylesheet type='text/xsl' href='emp.xsl'?> <employee> <employee1> <first>Abhimanyu</first> <last>Singh</last> <sex>male</sex> <dob>5Aug1983</dob> <lang>Hindi</lang> </employee1> <employee1> <first>Abhishek</first> <last>Tyagi</last> <sex>male</sex> <dob>1Sep1983</dob> <lang>English</lang> </employee1> <employee1> <first>Ajay</first> <last>Gupta</last> <sex>male</sex> <dob>4Nov1983</dob> <lang>marathi</lang> </employee1> <employee1> <first>Mukund</first> <last>Gupta</last> <sex>male</sex> <dob>3Mar1981</dob> <lang>english</lang> </employee1> </employee>
--------------------------------------------------------------------------------------------------------------------- emp.xsl
<? xml version=" 1.0"?> < xsl:stylesheet version=" 1.0" xmlns sl=" http://www.w3.org/1999/XSL/Transform"
xmlns:PC="urn:PointCross-GenericFunctions" >
< xsl:output method=" html"/> < xsl:param name=" Title" />
< xsl:template match=" /"> < html> < body> < h1> < xsl:value-of select=" $Title"/> </ h1>
< table border=" 1"> < tr bgcolor=" #cccccc"> < th align=" left"> < xsl:value-of select=" PC:ColumnTitle(1)"/> </ th> < th align=" left"> < xsl:value-of select=" PC:ColumnTitle(2)"/> </ th> < th align=" left"><xsl:value-of select ="PC:ColumnTitle(3)"/> </ th> < th align=" left"><xsl:value-of select ="PC:ColumnTitle(4)"/> </ th> < th align=" left"><xsl:value-of select ="PC:ColumnTitle(5)"/> </ th> </ tr>
< xsl:for-each select=" employee/employee1"> < tr> < td><xsl:value-of select="first"/></ td> < td><xsl:value-of select="last"/></ td> < td><xsl:value-of select="sex"/></ td> < td><xsl:value-of select="dob"/></ td> < td><xsl:value-of select="lang"/></ td> </ tr> </ xsl:for-each> </ table> </ body> </ html> </ xsl:template> </ xsl:stylesheet> -------------------------------------------------------------------------------------------------------------------------- emp.html <html> <head > <script type="text/javascript"> function OrchGeneric(){ this.ColumnTitle=_ColumnTitle; } function _ColumnTitle(Col){ var rtn=""; switch (Col){ case 1: rtn="First Name"; break; case 2: rtn="Last name"; break; case 3: rtn="Sex"; break; case 4: rtn="DOB" break; default: rtn="Lang"; } return rtn; } var Orch=new OrchGeneric(); function loadXML() { // code for IE if(window.ActiveXObject) { try{ var ClientXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument") ClientXML.async = false ClientXML.load("emp.xml") var ClientXSL = new ActiveXObject(" Msxml2.FreeThreadedDOMDocument") ClientXSL.async = false ClientXSL.load("emp.xsl") var xslTemplate=new ActiveXObject("Msxml2.XSLTemplate") xslTemplate.stylesheet=ClientXSL var xslProcessor=xslTemplate.createProcessor xslProcessor.input=ClientXML ; xslProcessor.addObject(Orch, "urn:PointCross-GenericFunctions" ); xslProcessor.addParameter ("Title", "Employee Record"); xslProcessor.transform(); document.write(xslProcessor.output); //alert(xslProcessor.output); }catch(e){alert(e)} }
// code for Mozilla, etc. else if(document.implementation && document.implementation.createDocument) { try{ var xslStylesheet; var myDOM; var xmlDoc; var xsltProcessor = new XSLTProcessor(); // load the xslt file, example1.xsl var myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET","emp.xsl", false); myXMLHTTPRequest.send(null); xslStylesheet = myXMLHTTPRequest.responseXML; xsltProcessor.importStylesheet(xslStylesheet); // load the xml file, example1.xml myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET","emp.xml", false); myXMLHTTPRequest.send(null); xmlDoc = myXMLHTTPRequest.responseXML; xsltProcessor.setParameter("urn:PointCross-GenericFunctions","Title",""); var ownerDocument=document.implementation.createDocument("", "test", null); var newFragment=xsltProcessor.transformToFragment(xmlDoc,document); document.body.appendChild( newFragment); }catch(e){alert(e)} } else { alert("your browser cannot handle this script"); } } </script> </head> <body onload="loadXML()" > </body> </html> ---------------------------------------------------------------------------------------------------------------------------- please let me know if u encoumnter any issue.................... thanx and regards, Abhimanyu Singh --------------------------------------------------------------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group. To post to this group, send email to JavaScript-Information googlegroups.com To unsubscribe from this group, send email to JavaScript-Information-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/JavaScript-Information?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: Checking events in time intervals |
  Germany |
2007-11-05 05:39:46 |
|
|
I was just giving you a starting point.
Try to remove the header row completely from your xsl file and you'll see that it works.
The problem is obviously associatedwith the function to set the value of your columns names. As I wrote earlier, try making the column names static and it works.
Regards,
Torsten Walter __________________________________________________ 3d-M | Online and Offline Media Zum Piepenkerl 2 | 49090 Osnabrück | Germany __________________________________________________ __________________________________________________ email: ttwalter80 gmail.com">ttwalter80 gmail.com
On Nov 5, 2007, at 12:03 PM, abhimanyu singh wrote: thanx Torsten ya i thats right i have submitted this query in wrong thread.... the solution which u have sended , giving no output plz check and let me know... thanx Abhimanyu singh
On 11/5/07, Torsten M. Walter < twalter80 googlemail.com">twalter80 googlemail.com> wrote: Hi, I'd say a reason for nobody answering might be that you posted your query in the wrong topic. Namely in a topic about event handling. I looked at the group and your messages aren't posted there. I'd suggest opening a new thread with your query. On topic: I have no big experience with XSLT, but after a couple of quick tests I have the following results. - your syntax is odd: It looks as if you are using a generator - which is fine - but the xslt document is not valid and fails therefor in Firefox. removing all the leading spaces in quoted arguments gets rig of most of the problem. - you are using XMLHTTPRequest to retrieve the XSLT. I think this is okay, but using document.implementation is shorter var process = new XSLTProcessor(); var xslStylesheet = document.implementation.createDocument("", "", null); xslStylesheet.async = false; process.importStylesheet(xslStylesheet); - the addObject function in IE you are using to process the Table header isn't present in the FF version. I searched the web for something similar but couldn't find anything suitable. I suggest putting the table header straight into the XSLT will solve the problem Maybe that helps. -- mozilla code from emp.html try{ var myDOM; var xmlDoc; var process = new XSLTProcessor(); var xslStylesheet = document.implementation.createDocument("", "", null); xslStylesheet.async = false; xslStylesheet.load("emp.xsl"); process.importStylesheet(xslStylesheet); myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET","emp.xml", false); myXMLHTTPRequest.send(null); xmlDoc = myXMLHTTPRequest.responseXML; var newFragment = process.transformToFragment(xmlDoc, document); document.body.appendChild( newFragment); }catch(e){alert(e)} } -- emp.xslt <?xml version="1.0"?> <xsl:output method="html"/> <xsl:param name="Title" /> <xsl:template match="/"> <html> <body> <h1> <xsl:value-of select="$Title"/> </h1> <table border="1"> <tr bgcolor="#cccccc"> <th align="left"><xsl:value-of select="PC:ColumnTitle(1)"/></th> <th align="left"><xsl:value-of select="PC:ColumnTitle(2)"/></th> <th align="left"><xsl:value-of select="PC:ColumnTitle(3)"/></th> <th align="left"><xsl:value-of select="PC:ColumnTitle(4)"/></th> <th align="left"><xsl:value-of select="PC:ColumnTitle(5)"/></th> </tr> <xsl:for-each select="employee/employee1"> <tr> <td><xsl:value-of select="first"/></td> <td><xsl:value-of select="last"/></td> <td><xsl:value-of select="sex"/></td> <td><xsl:value-of select="dob"/></td> <td><xsl:value-of select="lang"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> Regards, Torsten Walter __________________________________________________ 3d-M | Online and Offline Media Zum Piepenkerl 2 | 49090 Osnabrück | Germany __________________________________________________ __________________________________________________ On Nov 5, 2007, at 6:53 AM, abhimanyu singh wrote: hello all, can u help me with my pervious problem......................no comment on this probs
On 11/2/07, abhimanyu singh <gmail.com" target="_blank">er.abhimanyu gmail.com > wrote: hello all, i m facing a serious probs now a days............ its seems easy but for me i found it difficult......... i want to do transformation usig xsl and xml(adding parameter). for IE its working fine but for other browser like-firefox,opera its not working......... i m giving u my complete xml,xsl and transformation code....u only paste and check why it is not working for other browser.....and correct it and let me know......this is really a big challenege for us..... what my openion:- the way we are adding parameter is going wrong.......... //emp.xml <?xml version="1.0"?> <?xml-stylesheet type='text/xsl' href='emp.xsl'?> <employee> <employee1> <first>Abhimanyu</first> <last>Singh</last> <sex>male</sex> <dob>5Aug1983</dob> <lang>Hindi</lang> </employee1> <employee1> <first>Abhishek</first> <last>Tyagi</last> <sex>male</sex> <dob>1Sep1983</dob> <lang>English</lang> </employee1> <employee1> <first>Ajay</first> <last>Gupta</last> <sex>male</sex> <dob>4Nov1983</dob> <lang>marathi</lang> </employee1> <employee1> <first>Mukund</first> <last>Gupta</last> <sex>male</sex> <dob>3Mar1981</dob> <lang>english</lang> </employee1> </employee>
--------------------------------------------------------------------------------------------------------------------- emp.xsl
<? xml version=" 1.0"?> < xsl:stylesheet version=" 1.0" xmlns sl=" http://www.w3.org/1999/XSL/Transform" xmlns:PC="urn:PointCross-GenericFunctions " >
< xsl:output method=" html"/> < xsl:param name=" Title" /> < xsl:template match=" /"> < html> < body> < h1> < xsl:value-of select=" $Title"/> </ h1>
< table border=" 1"> < tr bgcolor=" #cccccc"> < th align=" left"> < xsl:value-of select=" PC:ColumnTitle(1)"/> </ th> < th align=" left"> < xsl:value-of select=" PC:ColumnTitle(2)"/> </ th> < th align=" left"><xsl:value-of select ="PC:ColumnTitle(3)"/> </ th> < th align=" left"><xsl:value-of select ="PC:ColumnTitle(4)"/> </ th> < th align=" left"><xsl:value-of select ="PC:ColumnTitle(5)"/> </ th> </ tr> < xsl:for-each select=" employee/employee1"> < tr> < td><xsl:value-of select="first"/></ td> < td><xsl:value-of select="last"/></ td> < td><xsl:value-of select="sex"/></ td> < td><xsl:value-of select="dob"/></ td> < td><xsl:value-of select="lang"/></ td> </ tr> </ xsl:for-each> </ table> </ body> </ html> </ xsl:template> </ xsl:stylesheet> -------------------------------------------------------------------------------------------------------------------------- emp.html <html> <head > <script type="text/javascript"> function OrchGeneric(){ this.ColumnTitle=_ColumnTitle; } function _ColumnTitle(Col){ var rtn=""; switch (Col){ case 1: rtn="First Name"; break; case 2: rtn="Last name"; break; case 3: rtn="Sex"; break; case 4: rtn="DOB" break; default: rtn="Lang"; } return rtn; } var Orch=new OrchGeneric(); function loadXML() { // code for IE if(window.ActiveXObject) { try{ var ClientXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument") ClientXML.async = false ClientXML.load("emp.xml") var ClientXSL = new ActiveXObject(" Msxml2.FreeThreadedDOMDocument") ClientXSL.async = false ClientXSL.load("emp.xsl") var xslTemplate=new ActiveXObject("Msxml2.XSLTemplate") xslTemplate.stylesheet=ClientXSL var xslProcessor=xslTemplate.createProcessor xslProcessor.input=ClientXML ; xslProcessor.addObject(Orch, "urn:PointCross-GenericFunctions" ); xslProcessor.addParameter ("Title", "Employee Record"); xslProcessor.transform(); document.write(xslProcessor.output); //alert(xslProcessor.output); }catch(e){alert(e)} }
// code for Mozilla, etc. else if(document.implementation && document.implementation.createDocument) { try{ var xslStylesheet; var myDOM; var xmlDoc; var xsltProcessor = new XSLTProcessor(); // load the xslt file, example1.xsl var myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET","emp.xsl", false); myXMLHTTPRequest.send(null); xslStylesheet = myXMLHTTPRequest.responseXML; xsltProcessor.importStylesheet(xslStylesheet); // load the xml file, example1.xml myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET","emp.xml", false); myXMLHTTPRequest.send(null); xmlDoc = myXMLHTTPRequest.responseXML; xsltProcessor.setParameter("urn:PointCross-GenericFunctions","Title",""); var ownerDocument=document.implementation.createDocument("", "test", null); var newFragment=xsltProcessor.transformToFragment(xmlDoc,document); document.body.appendChild( newFragment); }catch(e){alert(e)} } else { alert("your browser cannot handle this script"); } } </script> </head> <body onload="loadXML()" > </body> </html> ---------------------------------------------------------------------------------------------------------------------------- please let me know if u encoumnter any issue.................... thanx and regards, Abhimanyu Singh --------------------------------------------------------------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group. To post to this group, send email to JavaScript-Information googlegroups.com To unsubscribe from this group, send email to JavaScript-Information-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/JavaScript-Information?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: Checking events in time intervals |

|
2007-11-05 07:22:26 |
|
hello Torsten
i have done what u said means remove the column name from the xslt but in IE its giving object error and in FF its not displaying any thing....
plz help me i m also not good in xslt.....but i need this stuff.....
regards
Abhimanyu Singh
On 11/5/07, abhimanyu singh < er.abhimanyu gmail.com">er.abhimanyu gmail.com> wrote:
hello
i have kept the column name static but its giving no error ...
in IE also it is throwing error....................
thanx
abhimanyu singh
On 11/5/07, Torsten M. Walter <googlemail.com" target="_blank">twalter80 googlemail.com
> wrote:
I was just giving you a starting point.
Try to remove the header row completely from your xsl file and you'll see that it works.
The problem is obviously associatedwith the function to set the value of your columns names.
As I wrote earlier, try making the column names static and it works.
Regards,
Torsten Walter
__________________________________________________
3d-M | Online and Offline Media
Zum Piepenkerl 2 | 49090 Osnabrück | Germany
__________________________________________________
__________________________________________________
On Nov 5, 2007, at 12:03 PM, abhimanyu singh wrote:
thanx Torsten
ya i thats right i have submitted this query in wrong thread....
the solution which u have sended , giving no output plz check and let me know...
thanx
Abhimanyu singh
On 11/5/07, Torsten M. Walter <googlemail.com" target="_blank">twalter80 googlemail.com
> wrote:
Hi,
I'd say a reason for nobody answering might be that you posted your query in the wrong topic. Namely in a topic about event handling.
I looked at the group and your messages aren't posted there. I'd suggest opening a new thread with your query.
On topic:
I have no big experience with XSLT, but after a couple of quick tests I have the following results.
- your syntax is odd:
It looks as if you are using a generator - which is fine - but the xslt document is not valid and fails therefor in Firefox.
removing all the leading spaces in quoted arguments gets rig of most of the problem.
- you are using XMLHTTPRequest to retrieve the XSLT. I think this is okay, but using document.implementation is shorter
var process = new XSLTProcessor();
var xslStylesheet = document.implementation.createDocument("", "", null);
xslStylesheet.async = false;
process.importStylesheet(xslStylesheet);
- the addObject function in IE you are using to process the Table header isn't present in the FF version.
I searched the web for something similar but couldn';t find anything suitable.
I suggest putting the table header straight into the XSLT will solve the problem
Maybe that helps.
-- mozilla code from emp.html
try{
var myDOM;
var xmlDoc;
var process = new XSLTProcessor();
var xslStylesheet = document.implementation.createDocument("", "", null);
xslStylesheet.async = false;
xslStylesheet.load("emp.xsl");
process.importStylesheet(xslStylesheet);
myXMLHTTPRequest = new XMLHttpRequest();
myXMLHTTPRequest.open("GET","emp.xml", false);
myXMLHTTPRequest.send(null);
xmlDoc = myXMLHTTPRequest.responseXML;
var newFragment = process.transformToFragment(xmlDoc, document);
document.body.appendChild( newFragment);
}catch(e){alert(e)}
} &nbs p;
-- emp.xslt
<?xml version="1.0"?>
<xsl:output method="html"/>
<xsl:param name="Title" />
<xsl:template match="/">
<html>
<body>
<h1>
<xsl:value-of select="$Title"/>
</h1>
<table border="1">
<tr bgcolor="#cccccc">
<th align="left"><xsl:value-of select="PC:ColumnTitle(1)"/></th>
<th align="left"><xsl:value-of select="PC:ColumnTitle(2)"/></th>
<th align="left"><xsl:value-of select="PC:ColumnTitle(3)"/></th>
<th align="left"><xsl:value-of select="PC:ColumnTitle(4)"/></th>
<th align="left"><xsl:value-of select="PC:ColumnTitle(5)"/></th>
</tr>
<xsl:for-each select="employee/employee1">
<tr>
<td><xsl:value-of select="first"/></td>
<td><xsl:value-of select="last"/></td>
<td><xsl:value-of select="sex"/></td> | |