|
List Info
Thread: xslt problem in FF
|
|
| xslt problem in FF |

|
2007-11-05 07:26:23 |
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.....
//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=&q
uot; 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("&
quot;,
"test", null);
var
newFragment=xsltProcessor.transformToFragment(xmlDoc,documen
t);
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: xslt problem in FF |

|
2007-11-05 08:31:16 |
I'm copying and pasting replies to this post which were put
in the
wrong thread.
____________________________________________________________
______
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;
process.setParameter("urn:PointCross-
GenericFunctions",
"ColumnTitle" , Orch );
process.setParameter("urn:PointCross-
GenericFunctions","Title","Employee
Record");
var newFragment =
process.transformToFragment(xmlDoc,
document);
document.body.appendChild( newFragment);
}catch(e){alert(e)}
}
-- emp.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns sl=&q
uot;http://www.w3.org/1999/XS
L/
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>
Regards,
Torsten Walter
__________________________________________________
3d-M | Online and Offline Media
Zum Piepenkerl 2 | 49090 Osnabrück | Germany
__________________________________________________
website: http://legacy.3d-m.de
tech-lab: http://playground.3d-m.de/
__________________________________________________
email: ttwalte... gmail.com
____________________________________________________________
________________
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
____________________________________________________________
________________
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
____________________________________________________________
________________
Hello Abhimanyu,
before today I haven't even seen an xsl file or even used
Javacript
to use it.
I have built XML data parsers though
replacing the xsl call from the header cells and replacing
it with
plain text everything works in Firefox.
Safari gives an object error on the xsl.load call.
Therefore I changed the code back to your original provided
Javascript code and this works now in Safari3.03 beta,
Firefox2 and
Opera 9.23.
-- javascript code (dom compliant part)
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",
"ColumnTitle" , Orch );
xsltProcessor.setParameter("urn:PointCross-
GenericFunctions","Title","Employee
Record");
var newFragment =
xsltProcessor.transformToFragment(xmlDoc, document);
document.body.appendChild( newFragment);
}catch(e){alert(e)}
}
-- xsl header part
<tr bgcolor="#cccccc">
<th align="left">1</th>
<th align="left">2</th>
<th align="left">3</th>
<th align="left">4</th>
<th align="left">5</th>
</tr>
Make sure that your quoted argument contain no spaces or
firefox may
fail.
Example:
<?xml version=" 1.0"?> // will fail
<?xml version="1.0"?> // will work
I hope that helps,
Torsten Walter
On Nov 5, 8:26 am, abhi <er.abhima... 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.....
>
> //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=&q
uot;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("&
quot;,
> "test", null);
> var
>
newFragment=xsltProcessor.transformToFragment(xmlDoc,documen
t);
>
> 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
____________________________________________________________
________________
hello
i have kept the column name static but its giving no error
...
in IE also it is throwing error....................
hello *Torsten *
*thanx,*
* i m trying the sample which u sended to me mean while u
can see
the
xslt and xml transformtion from below links..............*
*this is very useful link ...may be u will come to know
better idea
mean
while i m also trying.....*
http://deve
loper.mozilla.org/en/docs/XSLT
http://developer.mozilla.org/en/docs/Usi
ng_the_Mozilla_JavaScript_int...
thanx
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: xslt problem in FF |

|
2007-11-05 10:33:10 |
|
All,
i have also check a lot that but didnt get how to use addobject function for FF.since the main advantage for using the same is u can process a table header so u can make a differnent call of other function.....
for example...
in xslt,
<script>
var a= new Array()
a.length=10;
a.color="red";
</script>
<xsl:value-of select="PC:functionname($a) />
and u can give the definition of this function in js show u can do more better useful stuff.
i believe there should be a similar way to do this........if addobject() method is not there then some alternative should be there...............
this is the helpful link where u will find all the method for xsltprocessor.....
this is really very hot issue.....because smthing is working in IE but not other browser....
regards,
Abhimanyu Singh
On 11/5/07, Israel Schulman < israel.schulman gmail.com">israel.schulman gmail.com> wrote:
I'm copying and pasting replies to this post which were put in the wrong thread. __________________________________________________________________
Hi,
I9;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; process.setParameter("urn:PointCross- GenericFunctions",
"ColumnTitle" , Orch ); process.setParameter("urn:PointCross- GenericFunctions","Title","Employee Record"); var newFragment = process.transformToFragment
(xmlDoc,
| |