Email lists > JavaScript Information > Re: xslt problem in FF > Re: xslt problem in FF

Re: xslt problem in FF




This post if a part of  this thread

2007-11-06 06:29:57
Re: xslt problem in FF

hello All,
      ;    i m thinking can we do in this way that  can we call PC:ColumnTitle() for javacript stuff....
 
 


 
On 11/6/07, abhimanyu singh < er.abhimanyugmail.com">er.abhimanyugmail.com> wrote:
hello all,
&nbsp;  any body got any new issue in this post..........if yes let us also know what?
thanx
Abhimanyu singh


 ;
On 11/5/07, abhimanyu singh <gmail.com" target="_blank">er.abhimanyugmail.com > wrote:
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.....
&nbsp;
for example...
in xslt,
&lt;script&gt;
var a= new Array()
a.length=10;
a.color="red";
</script>
&lt;xsl:value-of select=&quot;PC:functionname($a) />
&nbsp;
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.....
 
 
&nbsp;
this is really very hot issue.....because smthing is working in IE but not other browser....
 
 
regards,
Abhimanyu Singh
 
 
 

&nbsp;
On 11/5/07, Israel Schulman <gmail.com" target="_blank">israel.schulmangmail.com > wrote:

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:
 ; &nbsp; &nbsp;  It looks as if you are using a generator - which is fine - but
the
xslt document is not valid and fails therefor in Firefox.
&nbsp;   ; &nbsp; 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

&nbsp;   ; &nbsp; var process = new XSLTProcessor();
&nbsp; &nbsp; &nbsp;  var xslStylesheet = document.implementation.createDocument(&quot;",
&quot;",
null);

 &nbsp; &nbsp; &nbsp; xslStylesheet.async = false;
&nbsp; &nbsp; &nbsp;  process.importStylesheet(xslStylesheet);

- the addObject function in IE you are using to process the Table
header isn't present in the FF version.
&nbsp;   ; &nbsp; I searched the web for something similar but couldn';t find
anything
suitable.
 &nbsp; &nbsp; &nbsp; I suggest putting the table header straight into the XSLT will
solve
the problem

Maybe that helps.

-- mozilla code from emp.html
&nbsp;   ; &nbsp; try{
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; var myDOM;
 &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  var xmlDoc;
&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; var process = new XSLTProcessor();
&nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; var xslStylesheet =
document.implementation.createDocument(&quot;", "&quot;,
null);
  ; &nbsp; &nbsp; &nbsp; &nbsp;   ;  xslStylesheet.async = false;
&nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; xslStylesheet.load(&quot;emp.xsl");
&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; process.importStylesheet(xslStylesheet);

&nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   myXMLHTTPRequest = new XMLHttpRequest();
&nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; myXMLHTTPRequest.open ("GET",&quot;emp.xml&quot;, false);
&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; myXMLHTTPRequest.send(null);

&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; xmlDoc = myXMLHTTPRequest.responseXML;
&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; process.setParameter("urn:PointCross-
GenericFunctions",
"ColumnTitle&quot; , Orch );
 &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  process.setParameter("urn:PointCross-
GenericFunctions","Title",&quot;Employee Record&quot;);
   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; var newFragment = process.transformToFragment (xmlDoc,
document);

  ; &nbsp; &nbsp; &nbsp; &nbsp;   ;  document.body.appendChild( newFragment);

   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; }catch(e){alert(e)}

  ; &nbsp; &nbsp; }

-- emp.xslt
&lt;?xml version=&quot;1.0&quot;?>
<;xsl:stylesheet version=&quot; 1.0"; xmlnssl="http://www.w3.org/1999/XSL/
Transform"; xmlns:PC=&quot;urn:PointCross-GenericFunctions"&gt;
<xsl:output method=&quot;html&quot;/>
<;xsl:param name=";Title"; />
<xsl:template match=&quot;/"&gt;
<html>
<body>
<h1>
<xsl:value-of select=&quot;$Title&quot;/>
</h1>
<table border=&quot;1"&gt;

 &nbsp; &nbsp;   <tr bgcolor=&quot;#cccccc">
  ; &nbsp; &nbsp; <th align=&quot;left";><xsl:value-of select=&quot;PC:ColumnTitle(1)&quot;/>&lt;/
th>
 &nbsp;   ;  <th align=&quot;left";><xsl:value-of select=&quot;PC:ColumnTitle(2)&quot;/>&lt;/
th>
&nbsp; &nbsp;   ; <th align=&quot;left";><xsl:value-of select=&quot;PC:ColumnTitle(3)&quot;/>&lt;/
th>
  ; &nbsp; &nbsp; <th align=&quot;left";><xsl:value-of select=&quot;PC:ColumnTitle(4)&quot;/>&lt;/
th>
&nbsp; &nbsp;   ; <th align=&quot;left";><xsl:value-of select=&quot;PC:ColumnTitle(5)&quot;/>&lt;/
th>
  ; &nbsp; &nbsp; </tr>;

 &nbsp; &nbsp;   <xsl:for-each select=&quot;employee/employee1&quot;>
 &nbsp; &nbsp; &nbsp; <tr>
 &nbsp; &nbsp; &nbsp; <td><xsl:value-of select=&quot;first&quot;/><;/td>
&nbsp; &nbsp;   ; <td><xsl:value-of select=&quot;last&quot;/></td>
 &nbsp;   ;  <td><xsl:value-of select=&quot;sex";/></td>
 &nbsp; &nbsp; &nbsp; <td><xsl:value-of select=&quot;dob";/></td>
&nbsp; &nbsp; &nbsp;  <td><xsl:value-of select=&quot;lang&quot;/></td>
 &nbsp;   ;  </tr>;
 &nbsp; &nbsp; &nbsp; </xsl:for-each>
</table>
</body>
</html>
<;/xsl:template>
<;/xsl:stylesheet>

Regards,

Torsten Walter
__________________________________________________
3d-M | &nbsp;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: gmail.com" target="_blank">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 *
* &nbsp; *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)

{

 &nbsp; &nbsp; &nbsp; try{
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; var xslStylesheet;
   ; &nbsp; &nbsp; &nbsp;  var myDOM;
&nbsp; &nbsp; &nbsp;   ; &nbsp; var xmlDoc;
&nbsp; &nbsp;   ; &nbsp; &nbsp; var xsltProcessor = new XSLTProcessor();
 &nbsp;   ; &nbsp; &nbsp;  // load the xslt file, example1.xsl
 &nbsp; &nbsp;   ; &nbsp;  var myXMLHTTPRequest = new XMLHttpRequest();
&nbsp; &nbsp; &nbsp;   ; &nbsp; myXMLHTTPRequest.open("GET&quot;,";emp.xsl&quot;, false);
&nbsp; &nbsp;   ; &nbsp; &nbsp; myXMLHTTPRequest.send (null);

&nbsp;   ; &nbsp; &nbsp; &nbsp; xslStylesheet = myXMLHTTPRequest.responseXML;

&nbsp;   ; &nbsp; &nbsp; &nbsp; xsltProcessor.importStylesheet (xslStylesheet);

&nbsp; &nbsp; &nbsp;   ; &nbsp; // load the xml file, example1.xml
 &nbsp; &nbsp;   ; &nbsp;  myXMLHTTPRequest = new XMLHttpRequest();
 &nbsp;   ; &nbsp; &nbsp;  myXMLHTTPRequest.open("GET&quot;,";emp.xml&quot;, false);
&nbsp; &nbsp;   ; &nbsp; &nbsp; myXMLHTTPRequest.send (null);

&nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   xmlDoc = myXMLHTTPRequest.responseXML;
&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; xsltProcessor.setParameter ("urn:PointCross-
GenericFunctions&quot;,
"ColumnTitle&quot; , Orch );
 &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  xsltProcessor.setParameter ("urn:PointCross-
GenericFunctions&quot;,"Title",&quot;Employee Record&quot;);
 &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  var newFragment =
xsltProcessor.transformToFragment(xmlDoc, document);

 &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp;  document.body.appendChild ( newFragment);

   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; }catch(e){alert(e)}

  ; &nbsp; &nbsp; }

-- xsl header part

<tr bgcolor=&quot;#cccccc">
  ; &nbsp; &nbsp; <th align=&quot;left";>1</th>
&nbsp; &nbsp; &nbsp;  <th align=&quot;left";>2</th>
 &nbsp; &nbsp; &nbsp; <th align=&quot;left";>3</th>
 &nbsp;   ;  <th align=&quot;left";>4</th>
&nbsp; &nbsp; &nbsp;  <th align=&quot;left";>5</th>
</tr>

Make sure that your quoted argument contain no spaces or firefox may
fail.

Example:
&lt;?xml version=&quot; 1.0"?> // will fail
<?xml version=&quot;1.0&quot;?>&nbsp; // will work

I hope that helps,

Torsten Walter


On Nov 5, 8:26 am, abhi < gmail.com" target="_blank"> 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.....
&gt;
> //emp.xml
> <?xml version=&quot; 1.0"?>
> <?xml-stylesheet type='text/xsl9; href=' emp.xsl&#39;?>
&gt; <employee>
>  ; &nbsp; <employee1>
>; &nbsp; &nbsp; <first&gt;Abhimanyu</first>
>&nbsp; &nbsp;  <last&gt;Singh</last>
; &nbsp;  <sex>;male</sex>
>  ; &nbsp; <dob>;5Aug1983&lt;/dob>
>&nbsp; &nbsp;  <lang&gt;Hindi</lang>
&gt; &nbsp; &nbsp; </employee1>
&gt;
>&nbsp; &nbsp;  <employee1>
>; &nbsp; &nbsp; <first&gt;Abhishek</first&gt;
; &nbsp;  <last&gt;Tyagi</last>
&gt; &nbsp; &nbsp; <sex>;male</sex>
>&nbsp; &nbsp;  <dob>;1Sep1983&lt;/dob>
> &nbsp;   <lang&gt;English&lt;/lang>
  ;  </employee1>
&gt;
>&nbsp; &nbsp;  <employee1>
; &nbsp;  <first&gt;Ajay</first>
> &nbsp;   <last&gt;Gupta</last>
>&nbsp; &nbsp;  <sex>;male</sex>
>  ; &nbsp; <dob>;4Nov1983&lt;/dob>
> &nbsp;   <lang&gt;marathi&lt;/lang>
  ;  </employee1>
>
>  ; &nbsp; <employee1>
>; &nbsp; &nbsp; <first&gt;Mukund&lt;/first>;
>&nbsp; &nbsp;  <last&gt;Gupta</last>
&gt; &nbsp; &nbsp; <sex>;male</sex>
>  ; &nbsp; <dob>;3Mar1981&lt;/dob>
> &nbsp;   <lang&gt;english&lt;/lang>
; &nbsp;  </employee1>
&gt;
> </employee>
>
&gt; emp.xsl
&gt;
> <?
>
> xml version=&quot; 1.0"?>
> <
>
> xsl:stylesheet version=&quot; 1.0" xmlnssl=" http://www.w3.org/1999/XSL/Transform"
>
> xmlns:PC=&quot;urn:PointCross-GenericFunctions" >
>
> <
>
> xsl:output method=&quot; html"/>
> <
>
> xsl:param name="; Title"; />
>
> <
>
> xsl:template match=&quot; /">;
> <
>
> html>
> <
>
> body>
&gt; <
>
> h1>
>; <
>
> xsl:value-of select=&quot; $Title&quot;/>
>; </
>
> h1>
>;
> <
>
> table border=&quot; 1">;
> <
>
> tr bgcolor=&quot; #cccccc&quot;>
> <
>
> th align=&quot; left">
> <
>
> xsl:value-of select=&quot; PC:ColumnTitle(1)&quot;/>
>; </
>
> th>
&gt; <
>
> th align=&quot; left">
> <
>
> xsl:value-of select=&quot; PC:ColumnTitle(2)&quot;/>
>; </
>
> th>
>; <
>
> th align=&quot; left"><xsl:value-of select ="PC:ColumnTitle(3)"/&gt;
> </
>
> th>
>; <
>
> th align=&quot; left"><xsl:value-of select ="PC:ColumnTitle(4)"/&gt;
> </
>
> th>
>; <
>
> th align=&quot; left"><xsl:value-of select ="PC:ColumnTitle(5)"/&gt;
> </
>
> th>
>; </
>
> tr>
>
> <
>
> xsl:for-each select=&quot; employee/employee1&quot;>
>; <
>
> tr>
>; <
>;
> td><xsl:value-of select=&quot;first&quot;/><;/ td>
> <
>
> td><xsl:value-of select=&quot;last&quot;/></ td>
>; <
>
> td><xsl:value-of select=&quot;sex";/></ td>
> <
>
> td><xsl:value-of select=&quot;dob";/></ td>
> <
>
> td><xsl:value-of select=&quot;lang&quot;/></ td>
>; </
>
> tr>
> </
>
> xsl:for-each>
> </
>
> table>
> </
>
> body>
&gt; </
>
> html>
&gt; </
>
> xsl:template>
> </
>
&gt; xsl:stylesheet>
&gt; --------------------------------------------------------------------------------------------------------------------------
>
> emp.html
&gt;
> <html&gt;
> <head >
> <script type=";text/javascript">
> function OrchGeneric(){
>&nbsp; &nbsp;  this.ColumnTitle=_ColumnTitle;
&gt;
> }
>
> function _ColumnTitle(Col){
&gt; &nbsp; &nbsp; var rtn="";
>&nbsp; &nbsp;  switch (Col){
>; &nbsp; &nbsp; &nbsp; &nbsp; case 1:
>&nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; rtn="First Name";
; &nbsp; &nbsp; &nbsp; &nbsp;   ; break;
>; &nbsp; &nbsp; &nbsp; &nbsp; case 2:
; &nbsp; &nbsp; &nbsp; &nbsp;   ; rtn="Last name";
; &nbsp; &nbsp; &nbsp; &nbsp;   ; break;
>&nbsp; &nbsp; &nbsp;   ; case 3:
>&nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; rtn="Sex";
> &nbsp;   ; &nbsp; &nbsp; &nbsp;  break;
>; &nbsp; &nbsp; &nbsp; &nbsp; case 4:
>&nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; rtn="DOB"
; &nbsp; &nbsp; &nbsp; &nbsp;   ; break;
>; &nbsp; &nbsp; &nbsp; &nbsp; default:
&gt; &nbsp; &nbsp;   ; &nbsp; &nbsp;  rtn="Lang";
>&nbsp; &nbsp;  }
>&nbsp; &nbsp;  return rtn;
>
> }
>
>; var Orch=new OrchGeneric();
>
&gt; function loadXML()
> {
>&nbsp; &nbsp; &nbsp; // code for IE
>
&gt; &nbsp; &nbsp; &nbsp;if(window.ActiveXObject)
&gt;
>&nbsp; &nbsp; &nbsp;  {
>
>; &nbsp; &nbsp; &nbsp; &nbsp;try{
&gt; &nbsp; &nbsp;   ; var ClientXML = new
> ActiveXObject("Msxml2.FreeThreadedDOMDocument ")
&gt; &nbsp; &nbsp; &nbsp;  ClientXML.async = false
>  ; &nbsp; &nbsp; &nbsp;ClientXML.load(&quot; emp.xml&quot;)
>
  ; &nbsp; &nbsp; var ClientXSL = new ActiveXObject("
> Msxml2.FreeThreadedDOMDocument&quot;)
>&nbsp;   ; &nbsp; &nbsp; ClientXSL.async = false
>  ; &nbsp; &nbsp; &nbsp;ClientXSL.load(&quot;emp.xsl&quot;)
>
>&nbsp; &nbsp; &nbsp;   ;var xslTemplate=new ActiveXObject("Msxml2.XSLTemplate";)
>&nbsp; &nbsp; &nbsp; &nbsp; xslTemplate.stylesheet=ClientXSL
> &nbsp;   ; &nbsp; var xslProcessor= xslTemplate.createProcessor
>
  ; &nbsp; &nbsp; xslProcessor.input=ClientXML ;
>&nbsp; &nbsp; &nbsp; &nbsp; xslProcessor.addObject(Orch, "urn:PointCross-
> GenericFunctions"; );
>&nbsp; &nbsp; &nbsp;   ;xslProcessor.addParameter ("Title", "Employee Record&quot;);
>
&gt; &nbsp; &nbsp;   ; xslProcessor.transform ();
>&nbsp; &nbsp;   ; &nbsp;document.write(xslProcessor.output);
>&nbsp;   ; &nbsp; &nbsp; //alert(xslProcessor.output);
&gt;
>&nbsp; &nbsp; &nbsp; &nbsp; }catch(e){alert(e)}
>
>  ; &nbsp; &nbsp;}
>
&gt; &nbsp; &nbsp;// code for Mozilla, etc.
>
>&nbsp; &nbsp; else if(document.implementation &&
> document.implementation.createDocument)
>;
; &nbsp;  {
>
>; &nbsp; &nbsp; try{
; &nbsp;  var xslStylesheet;
>&nbsp; &nbsp;  var myDOM;
>; &nbsp; &nbsp; var xmlDoc;
>&nbsp; &nbsp;  var xsltProcessor = new XSLTProcessor();
>  ; &nbsp; // load the xslt file, example1.xsl
>&nbsp; &nbsp;  var myXMLHTTPRequest = new XMLHttpRequest();
; &nbsp;  myXMLHTTPRequest.open("GET&quot;,";emp.xsl ", false);
&gt; &nbsp; &nbsp; myXMLHTTPRequest.send(null);
>;
; &nbsp;  xslStylesheet = myXMLHTTPRequest.responseXML;
&gt;
>&nbsp; &nbsp;  xsltProcessor.importStylesheet (xslStylesheet);
>
  ;  // load the xml file, example1.xml
>&nbsp; &nbsp;  myXMLHTTPRequest = new XMLHttpRequest();
>; &nbsp; &nbsp; myXMLHTTPRequest.open("GET&quot;,";emp.xml&quot;, false);
&gt; &nbsp; &nbsp; myXMLHTTPRequest.send (null);
&gt;
>&nbsp; &nbsp;  xmlDoc = myXMLHTTPRequest.responseXML ;
>&nbsp; &nbsp;  xsltProcessor.setParameter(";urn:PointCross-
> GenericFunctions";,"Title",&quot;");
; &nbsp;  var ownerDocument= document.implementation.createDocument(&quot;",
&gt; "test", null);
>&nbsp; &nbsp;  var
> newFragment=xsltProcessor.transformToFragment(xmlDoc,document);
&gt;
>&nbsp; &nbsp;  document.body.appendChild( newFragment);
>
>  ; &nbsp; }catch(e){alert(e)}
&gt;
>&nbsp; &nbsp;  }
>
&gt; &nbsp; &nbsp; else
>
> &nbsp;   ;  {
>&nbsp; &nbsp; &nbsp; &nbsp;  alert(&quot;your browser cannot handle this script&quot;);
>&nbsp; &nbsp;   ; }}
>
&gt; </script>
> </head&gt;
> <body onload=&quot;loadXML()" >
> </body&gt;
> </html&gt;
>
&gt; ----------------------------------------------------------------------------------------------------------------------------
>
> please let me know if u encoumnter any issue....................
>
&gt; thanx and regards,
&gt; 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,*
* &nbsp; &nbsp;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://developer.mozilla.org/en/docs/XSLT

http://developer.mozilla.org/en/docs/Using_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-Informationgooglegroups.com
To unsubscribe from this group, send email to JavaScript-Information-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/JavaScript-Information?hl=en
-~----------~----~----~----~------~----~------~--~---

about | contact  Other archives ( Real Estate discussion Medical topics )