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
[CODE=xml]<?xml version="1.0"?>
<?xml-stylesheet type='text/xsl' href='emp.xsl'? >
<employee>
<employee1>
<first>Abhimany u</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>
[/CODE]
---------------------------------------------------------------------------------------------------------------------
emp.xsl
[CODE=xml]<?
xml version=" 1.0"?>
<
xsl:stylesheet version=" 1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"
xmlns:PC="urn:P ointCross-GenericFunction s" >
<
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:valu e-of select ="PC:ColumnTitl e(3)"/>
</
th>
<
th align=" left"><xsl:valu e-of select ="PC:ColumnTitl e(4)"/>
</
th>
<
th align=" left"><xsl:valu e-of select ="PC:ColumnTitl e(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>
[/CODE]--------------------------------------------------------------------------------------------------------------------------
emp.html
[CODE=html]<html>
<head >
<script type="text/javascript"> [/code]
[code=javascript]function OrchGeneric(){
this.ColumnTitl e=_ColumnTitle;
}
function _ColumnTitle(Co l){
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.Activ eXObject)
{
try{
var ClientXML = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument ")
ClientXML.async = false
ClientXML.load( "emp.xml")
var ClientXSL = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument ")
ClientXSL.async = false
ClientXSL.load( "emp.xsl")
var xslTemplate=new ActiveXObject(" Msxml2.XSLTempl ate")
xslTemplate.sty lesheet=ClientX SL
var xslProcessor=xs lTemplate.creat eProcessor
xslProcessor.in put=ClientXML ;
xslProcessor.ad dObject(Orch, "urn:PointC ross-GenericFunction s" );
xslProcessor.ad dParameter ("Title", "Employee Record");
xslProcessor.tr ansform();
document.write( xslProcessor.ou tput);
//alert(xslProces sor.output);
}catch(e){alert (e)}
}
// code for Mozilla, etc.
else if(document.imp lementation && document.implem entation.create Document)
{
try{
var xslStylesheet;
var myDOM;
var xmlDoc;
var xsltProcessor = new XSLTProcessor() ;
// load the xslt file, example1.xsl
var myXMLHTTPReques t = new XMLHttpRequest( );
myXMLHTTPReques t.open("GET","e mp.xsl", false);
myXMLHTTPReques t.send(null);
xslStylesheet = myXMLHTTPReques t.responseXML;
xsltProcessor.i mportStylesheet (xslStylesheet) ;
// load the xml file, example1.xml
myXMLHTTPReques t = new XMLHttpRequest( );
myXMLHTTPReques t.open("GET","e mp.xml", false);
myXMLHTTPReques t.send(null);
xmlDoc = myXMLHTTPReques t.responseXML;
xsltProcessor.s etParameter("ur n:PointCross-GenericFunction s","Title"," ");
var ownerDocument=d ocument.impleme ntation.createD ocument("", "test", null);
var newFragment=xsl tProcessor.tran sformToFragment (xmlDoc,documen t);
document.body.a ppendChild( newFragment);
}catch(e){alert (e)}
}
else
{
alert("your browser cannot handle this script");
}
}[/code]
[code=html]</script>
</head>
<body onload="loadXML ()" >
</body>
</html>[/CODE]
----------------------------------------------------------------------------------------------------------------------------
please let me know if u encoumnter any issue.......... ..........
thanx and regards,
Abhimanyu Singh
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
[CODE=xml]<?xml version="1.0"?>
<?xml-stylesheet type='text/xsl' href='emp.xsl'? >
<employee>
<employee1>
<first>Abhimany u</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>
[/CODE]
---------------------------------------------------------------------------------------------------------------------
emp.xsl
[CODE=xml]<?
xml version=" 1.0"?>
<
xsl:stylesheet version=" 1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"
xmlns:PC="urn:P ointCross-GenericFunction s" >
<
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:valu e-of select ="PC:ColumnTitl e(3)"/>
</
th>
<
th align=" left"><xsl:valu e-of select ="PC:ColumnTitl e(4)"/>
</
th>
<
th align=" left"><xsl:valu e-of select ="PC:ColumnTitl e(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>
[/CODE]--------------------------------------------------------------------------------------------------------------------------
emp.html
[CODE=html]<html>
<head >
<script type="text/javascript"> [/code]
[code=javascript]function OrchGeneric(){
this.ColumnTitl e=_ColumnTitle;
}
function _ColumnTitle(Co l){
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.Activ eXObject)
{
try{
var ClientXML = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument ")
ClientXML.async = false
ClientXML.load( "emp.xml")
var ClientXSL = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument ")
ClientXSL.async = false
ClientXSL.load( "emp.xsl")
var xslTemplate=new ActiveXObject(" Msxml2.XSLTempl ate")
xslTemplate.sty lesheet=ClientX SL
var xslProcessor=xs lTemplate.creat eProcessor
xslProcessor.in put=ClientXML ;
xslProcessor.ad dObject(Orch, "urn:PointC ross-GenericFunction s" );
xslProcessor.ad dParameter ("Title", "Employee Record");
xslProcessor.tr ansform();
document.write( xslProcessor.ou tput);
//alert(xslProces sor.output);
}catch(e){alert (e)}
}
// code for Mozilla, etc.
else if(document.imp lementation && document.implem entation.create Document)
{
try{
var xslStylesheet;
var myDOM;
var xmlDoc;
var xsltProcessor = new XSLTProcessor() ;
// load the xslt file, example1.xsl
var myXMLHTTPReques t = new XMLHttpRequest( );
myXMLHTTPReques t.open("GET","e mp.xsl", false);
myXMLHTTPReques t.send(null);
xslStylesheet = myXMLHTTPReques t.responseXML;
xsltProcessor.i mportStylesheet (xslStylesheet) ;
// load the xml file, example1.xml
myXMLHTTPReques t = new XMLHttpRequest( );
myXMLHTTPReques t.open("GET","e mp.xml", false);
myXMLHTTPReques t.send(null);
xmlDoc = myXMLHTTPReques t.responseXML;
xsltProcessor.s etParameter("ur n:PointCross-GenericFunction s","Title"," ");
var ownerDocument=d ocument.impleme ntation.createD ocument("", "test", null);
var newFragment=xsl tProcessor.tran sformToFragment (xmlDoc,documen t);
document.body.a ppendChild( newFragment);
}catch(e){alert (e)}
}
else
{
alert("your browser cannot handle this script");
}
}[/code]
[code=html]</script>
</head>
<body onload="loadXML ()" >
</body>
</html>[/CODE]
----------------------------------------------------------------------------------------------------------------------------
please let me know if u encoumnter any issue.......... ..........
thanx and regards,
Abhimanyu Singh
Comment