Javascript in xslt Firefox-problem
bonespirit
- xsl
Hallo,
also ich will mit hilfe einer xsl-datei welche ein script-tag enthält eine xml-datei transformieren. Das funktioniert im IE6 und IE7 soweit ganz gut, nur der FF bleibt dabei hängen. Er zeigt ne weiße seite an und hört nicht mehr auf zu laden, sieht aus als hängt er in ner endlosschleife. Wär sehr dankbar wenn mir da jemand helfen könnte.
Hier die xml-datei:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="../xsl_style.xsl"?>
<root>
<build Link="/xmlchangelogs/4.1/builds/V4_1_1_0253.xml" getaggte_version="V4_1_1_0253"></build>
<build Link="/xmlchangelogs/4.1/builds/V4_1_1_0252.xml" getaggte_version="V4_1_1_0252"></build>
</root>
Hier die xsl-datei:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<head>
<script src="calendar.js" type="text/javascript"></script>
<style type="text/css">
a:link { text-decoration:none; color:#000000; font-size:8pt; }
a:visited { text-decoration:none; color:#000000; font-size:8pt;}
a:hover { text-decoration:underline; color:#000000; font-size:8pt;}
a:active { text-decoration:none; color:#000000; font-size:8pt;}
a:focus { text-decoration:none; color:#000000; font-size:8pt;}
</style>
</head>
<body bgcolor="#E0E0E0" text="#000000" style="font-family:verdana; font-size:8pt; margin-top:20px;">
<form action="http://localhost/cgi-bin/cgi.cgi" name="Formular" method="post" target="">
<table border="0" cellpadding="5" bgcolor="#E0E0E0">
<tr>
<td align="right">getaggte Version:</td>
<td><select name="getaggte_version"><xsl:apply-templates /></select></td>
<td align="right">Datum:</td>
<td><input name="DatumFeld" type="text" value="" onfocus="this.select(); lcs(this,true,'397px','30px')" onclick="event.cancelBubble=true; this.select(); lcs(this,true,'397px','30px')"/>
</td>
<td align="right">Kuerzel:</td>
<td><input name="Kuerzel" type="text" value = "" size="3" maxlength="3" />
</td>
</tr>
<tr>
<td align="right">
<td><input type="submit" value=" Absenden " /><input type="reset" value=" Abbrechen" /></td>
</td>
</tr>
</table>
</form>
</body>
</html>
</xsl:template>
<xsl:template match="root">
<xsl:for-each select="build">
<xsl:variable name="linkText">
<xsl:value-of select= "@getaggte_version" />
<xsl:value-of select= "' '" />
<xsl:value-of select= " @Kuerzel" />
<xsl:value-of select= "' '" />
<xsl:value-of select= " @Datum" />
</xsl:variable>
<xsl:variable name="titel">
<xsl:value-of select= "@Kuerzel" />
<xsl:value-of select= "' '" />
<xsl:value-of select= " @Datum" />
</xsl:variable>
<xsl:element name="option">
<xsl:value-of select="$linkText" />
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Hier die javascript-datei :
//var dateformat = 'mdy'; // date-month-year
//var dateformat = 'dmy'; // date-month-year (default)
var datesplitter = '.'; // in between date, month, year... typically '/' or '-'
var disablepast = false; // disable date selection in the past
/* position:fixed;top:30px;left:397px; */
document.write('<table id="fc" style="position:absolute;border-collapse:collapse;background:#FFFFFF;border:1px solid #ABABAB;display:none" cellpadding=2>');
document.write('<tr><td style="cursor:pointer" onclick="csubm()"><img src="arrowleftmonth.gif"></td><td colspan=5 id="mns" align="center" style="font:bold 13px Arial"></td><td align="right" style="cursor:pointer" onclick="caddm()"><img src="arrowrightmonth.gif"></td></tr>');
document.write('<tr><td align=center style="background:#ABABAB;font:12px Arial">S</td><td align=center style="background:#ABABAB;font:12px Arial">M</td><td align=center style="background:#ABABAB;font:12px Arial">D</td><td align=center style="background:#ABABAB;font:12px Arial">M</td><td align=center style="background:#ABABAB;font:12px Arial">D</td><td align=center style="background:#ABABAB;font:12px Arial">F</td><td align=center style="background:#ABABAB;font:12px Arial">S</td></tr>');
for(var kk=1;kk<=6;kk++) {
document.write('<tr>');
for(var tt=1;tt<=7;tt++) {
num=7 * (kk-1) - (-tt);
document.write('<td id="v' + num + '" style="width:18px;height:18px"> </td>');
}
document.write('</tr>');
}
document.write('</table>');
document.all?document.attachEvent('onclick',checkClick):document.addEventListener('click',checkClick,false);
// Calendar script
var now = new Date;
var sccm=now.getMonth();
var sccy=now.getFullYear();
var scfd=now.getDate();
var ccm=sccm;
var ccy=sccy;
var cfd=scfd;
var updobj;
var mn=new Array('JAN','FEB','MAR','APR','MAI','JUN','JUL','AUG','SEP','OKT','NOV','DEZ');
var mnn=new Array('31','28','31','30','31','30','31','31','30','31','30','31');
var mnl=new Array('31','29','31','30','31','30','31','31','30','31','30','31');
var calvalarr=new Array(42);
prepcalendar('',ccm,ccy);
//getObj('fc'+cc).style.visibility='hidden';
function getObj(objID)
{
if (document.getElementById) {return document.getElementById(objID);}
else if (document.all) {return document.all[objID];}
else if (document.layers) {return document.layers[objID];}
}
function checkClick(e) {
e?evt=e:evt=event;
CSE=evt.target?evt.target:evt.srcElement;
if (getObj('fc'))
if (!isChild(CSE,getObj('fc')))
getObj('fc').style.display='none';
}
function isChild(s,d) {
while(s) {
if (s==d)
return true;
s=s.parentNode;
}
return false;
}
function Left(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
function Top(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
function lcs(ielem, draw, xpos, ypos) {
updobj=ielem;
// individual position:
if( draw == true )
{
getObj('fc').style.left=xpos;
getObj('fc').style.top=ypos;
getObj('fc').style.display='';
getObj('fc').style.position='absolute';
}
else
{
getObj('fc').style.left=Left(ielem);
getObj('fc').style.top=Top(ielem)+ielem.offsetHeight;
getObj('fc').style.display='';
getObj('fc').style.position='';
}
// First check date is valid
curdt=ielem.value;
curdtarr=curdt.split('/');
isdt=true;
for(var k=0;k<curdtarr.length;k++) {
if (isNaN(curdtarr[k]))
isdt=false;
}
if (isdt&(curdtarr.length==3)) {
ccm=curdtarr[1]-1;
ccy=curdtarr[2];
ccd= curdtarr[0];
prepcalendar(ccd,ccm,ccy);
}
}
function evtTgt(e)
{
var el;
if(e.target)el=e.target;
else if(e.srcElement)el=e.srcElement;
if(el.nodeType==3)el=el.parentNode; // defeat Safari bug
return el;
}
function EvtObj(e){if(!e)e=window.event;return e;}
function cs_over(e) {
evtTgt(EvtObj(e)).style.background='#FFCC66';
}
function cs_out(e) {
evtTgt(EvtObj(e)).style.background='#FFF0F5';
}
function cs_click(e) {
updobj.value=calvalarr[evtTgt(EvtObj(e)).id.substring(1,evtTgt(EvtObj(e)).id.length)];
getObj('fc').style.display='none';
}
function f_cps(obj) {
obj.style.background='#FFF0F5';
obj.style.font='10px Arial';
obj.style.color='#333333';
obj.style.textAlign='center';
obj.style.textDecoration='none';
obj.style.border='1px solid #FFE4E1';
obj.style.cursor='pointer';
}
function f_cpps(obj) {
obj.style.background='#FFF0F5';
obj.style.font='10px Arial';
obj.style.color='#ABABAB';
obj.style.textAlign='center';
obj.style.textDecoration='line-through';
obj.style.border='1px solid #FAF0E6';
obj.style.cursor='default';
}
function f_hds(obj) {
obj.style.background='#E36087';
obj.style.font='bold 10px Arial';
obj.style.color='#000000';
obj.style.textAlign='center';
obj.style.border='1px solid #250709';
obj.style.cursor='pointer';
}
// day selected
function prepcalendar(hd,cm,cy) {
now=new Date();
sd=now.getDate();
td=new Date();
td.setDate(1);
td.setFullYear(cy);
td.setMonth(cm);
cd=td.getDay();
getObj('mns').innerHTML=mn[cm]+ ' ' + cy;
marr=((cy%4)==0)?mnl:mnn;
for(var d=1;d<=42;d++) {
f_cps(getObj('v'+parseInt(d)));
if ((d >= (cd -(-1))) && (d<=cd-(-marr[cm]))) {
dip=(disablepast&&(d-cd < sd)&&(cm==sccm)&&(cy==sccy));
htd=((hd!='')&&(d-cd==hd));
if (dip)
f_cpps(getObj('v'+parseInt(d)));
else if (htd)
f_hds(getObj('v'+parseInt(d)));
else
f_cps(getObj('v'+parseInt(d)));
getObj('v'+parseInt(d)).onmouseover=(dip)?null:cs_over;
getObj('v'+parseInt(d)).onmouseout=(dip)?null:cs_out;
getObj('v'+parseInt(d)).onclick=(dip)?null:cs_click;
getObj('v'+parseInt(d)).innerHTML=d-cd;
cmx = parseInt(cm)+1;
if (cmx < 10 ) {
cmx = '0'+cmx;
}
dx = d-cd;
if (dx < 10 ) {
dx = '0'+dx;
}
calvalarr[d]=''+dx+datesplitter+cmx+datesplitter+cy;
}
else {
getObj('v'+d).innerHTML=' ';
getObj('v'+parseInt(d)).onmouseover=null;
getObj('v'+parseInt(d)).onmouseout=null;
getObj('v'+parseInt(d)).style.cursor='default';
}
}
}
function caddm() {
marr=((ccy%4)==0)?mnl:mnn;
ccm+=1;
if (ccm>=12) {
ccm=0;
ccy++;
}
cdayf();
prepcalendar('',ccm,ccy);
}
function csubm() {
marr=((ccy%4)==0)?mnl:mnn;
ccm-=1;
if (ccm<0) {
ccm=11;
ccy--;
}
cdayf();
prepcalendar('',ccm,ccy);
}
function cdayf() {
if (!disablepast||((ccy>sccy)||((ccy==sccy)&&(ccm>=sccm))))
return;
else {
ccy=sccy;
ccm=sccm;
cfd=scfd;
}
}