473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

xml and xsl transformation(adding parameter)

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
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type='text/xsl' href='emp.xsl'?>
  3. <employee>
  4.     <employee1>
  5.     <first>Abhimanyu</first>
  6.     <last>Singh</last> 
  7.     <sex>male</sex>
  8.     <dob>5Aug1983</dob>
  9.     <lang>Hindi</lang> 
  10.     </employee1> 
  11.  
  12.     <employee1>
  13.     <first>Abhishek</first>
  14.     <last>Tyagi</last> 
  15.     <sex>male</sex>
  16.     <dob>1Sep1983</dob>
  17.     <lang>English</lang> 
  18.     </employee1> 
  19.  
  20.     <employee1>
  21.     <first>Ajay</first>
  22.     <last>Gupta</last> 
  23.     <sex>male</sex>
  24.     <dob>4Nov1983</dob>
  25.     <lang>marathi</lang> 
  26.     </employee1> 
  27.  
  28.     <employee1>
  29.     <first>Mukund</first>
  30.     <last>Gupta</last> 
  31.     <sex>male</sex>
  32.     <dob>3Mar1981</dob>
  33.     <lang>english</lang> 
  34.     </employee1> 
  35.  
  36. </employee>  
  37.  
---------------------------------------------------------------------------------------------------------------------

emp.xsl


Expand|Select|Wrap|Line Numbers
  1. <?
  2.  
  3. xml version=" 1.0"?> 
  4. <
  5.  
  6. xsl:stylesheet version=" 1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" 
  7.  
  8. xmlns:PC="urn:PointCross-GenericFunctions" > 
  9.  
  10. <
  11.  
  12. xsl:output method=" html"/> 
  13. <
  14.  
  15. xsl:param name=" Title" /> 
  16.  
  17.  
  18. <
  19.  
  20. xsl:template match=" /"> 
  21. <
  22.  
  23. html> 
  24. <
  25.  
  26. body> 
  27. <
  28.  
  29. h1> 
  30. <
  31.  
  32. xsl:value-of select=" $Title"/> 
  33. </
  34.  
  35. h1> 
  36.  
  37. <
  38.  
  39. table border=" 1"> 
  40. <
  41.  
  42. tr bgcolor=" #cccccc"> 
  43. <
  44.  
  45. th align=" left"> 
  46. <
  47.  
  48. xsl:value-of select=" PC:ColumnTitle(1)"/> 
  49. </
  50.  
  51. th> 
  52. <
  53.  
  54. th align=" left"> 
  55. <
  56.  
  57. xsl:value-of select=" PC:ColumnTitle(2)"/> 
  58. </
  59.  
  60. th> 
  61. <
  62.  
  63. th align=" left"><xsl:value-of select ="PC:ColumnTitle(3)"/> 
  64. </
  65.  
  66. th> 
  67. <
  68.  
  69. th align=" left"><xsl:value-of select ="PC:ColumnTitle(4)"/> 
  70. </
  71.  
  72. th> 
  73. <
  74.  
  75. th align=" left"><xsl:value-of select ="PC:ColumnTitle(5)"/> 
  76. </
  77.  
  78. th> 
  79. </
  80.  
  81. tr> 
  82.  
  83.  
  84. <
  85.  
  86. xsl:for-each select=" employee/employee1"> 
  87. <
  88.  
  89. tr> 
  90. <
  91.  
  92. td><xsl:value-of select="first"/></ td> 
  93. <
  94.  
  95. td><xsl:value-of select="last"/></ td> 
  96. <
  97.  
  98. td><xsl:value-of select="sex"/></ td> 
  99. <
  100.  
  101. td><xsl:value-of select="dob"/></ td> 
  102. <
  103.  
  104. td><xsl:value-of select="lang"/></ td> 
  105. </
  106.  
  107. tr> 
  108. </
  109.  
  110. xsl:for-each> 
  111. </
  112.  
  113. table> 
  114. </
  115.  
  116. body> 
  117. </
  118.  
  119. html> 
  120. </
  121.  
  122. xsl:template> 
  123. </
  124.  
  125. xsl:stylesheet> 
  126.  
--------------------------------------------------------------------------------------------------------------------------

emp.html



Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head >
  3. <script type="text/javascript"> 
Expand|Select|Wrap|Line Numbers
  1. function OrchGeneric(){
  2.     this.ColumnTitle=_ColumnTitle;
  3. }
  4.  
  5. function _ColumnTitle(Col){
  6.     var rtn="";
  7.     switch (Col){
  8.         case 1: 
  9.             rtn="First Name";
  10.             break;
  11.         case 2: 
  12.             rtn="Last name"; 
  13.             break;
  14.         case 3: 
  15.             rtn="Sex";
  16.             break;
  17.         case 4:
  18.             rtn="DOB"
  19.             break;  
  20.         default:
  21.             rtn="Lang"; 
  22.     }     
  23.     return rtn;
  24. }
  25.  
  26. var Orch=new OrchGeneric();
  27.  
  28. function loadXML()
  29. {
  30.      // code for IE
  31.  
  32.      if(window.ActiveXObject)
  33.  
  34.       {
  35.  
  36.        try{ 
  37.        var ClientXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument") 
  38.        ClientXML.async = false
  39.        ClientXML.load("emp.xml")
  40.  
  41.        var ClientXSL = new ActiveXObject(" Msxml2.FreeThreadedDOMDocument") 
  42.        ClientXSL.async = false 
  43.        ClientXSL.load("emp.xsl")
  44.  
  45.        var xslTemplate=new ActiveXObject("Msxml2.XSLTemplate") 
  46.        xslTemplate.stylesheet=ClientXSL 
  47.        var xslProcessor=xslTemplate.createProcessor 
  48.  
  49.        xslProcessor.input=ClientXML ;
  50.        xslProcessor.addObject(Orch, "urn:PointCross-GenericFunctions" );
  51.        xslProcessor.addParameter ("Title", "Employee Record"); 
  52.  
  53.  
  54.  
  55.        xslProcessor.transform();
  56.        document.write(xslProcessor.output);
  57.         //alert(xslProcessor.output);
  58.  
  59.        }catch(e){alert(e)} 
  60.  
  61.  
  62.      }
  63.  
  64.    // code for Mozilla, etc.
  65.  
  66.    else if(document.implementation && document.implementation.createDocument)
  67.  
  68.     {
  69.  
  70.     try{
  71.     var xslStylesheet;
  72.     var myDOM;
  73.     var xmlDoc;
  74.     var xsltProcessor = new XSLTProcessor(); 
  75.     // load the xslt file, example1.xsl        
  76.     var myXMLHTTPRequest = new XMLHttpRequest(); 
  77.     myXMLHTTPRequest.open("GET","emp.xsl", false);
  78.     myXMLHTTPRequest.send(null);
  79.  
  80.     xslStylesheet = myXMLHTTPRequest.responseXML;
  81.  
  82.     xsltProcessor.importStylesheet(xslStylesheet); 
  83.  
  84.     // load the xml file, example1.xml
  85.     myXMLHTTPRequest = new XMLHttpRequest();
  86.     myXMLHTTPRequest.open("GET","emp.xml", false);
  87.     myXMLHTTPRequest.send(null);
  88.  
  89.     xmlDoc = myXMLHTTPRequest.responseXML; 
  90.     xsltProcessor.setParameter("urn:PointCross-GenericFunctions","Title","");   
  91.     var ownerDocument=document.implementation.createDocument("", "test", null); 
  92.     var newFragment=xsltProcessor.transformToFragment(xmlDoc,document);
  93.  
  94.     document.body.appendChild( newFragment); 
  95.  
  96.     }catch(e){alert(e)} 
  97.  
  98.     }
  99.  
  100.     else
  101.  
  102.       {
  103.         alert("your browser cannot handle this script");
  104.       }
  105. }
Expand|Select|Wrap|Line Numbers
  1. </script>  
  2. </head>
  3. <body onload="loadXML()" >
  4. </body>
  5. </html>
----------------------------------------------------------------------------------------------------------------------------

please let me know if u encoumnter any issue....................


thanx and regards,
Abhimanyu Singh
Nov 3 '07 #1
2 2079
acoder
16,027 Expert Mod 8TB
Do you get any errors? If so, what errors and on what lines?
Nov 3 '07 #2
in FF how to use addobject means how to process table header........
Nov 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Kevin Dean | last post by:
I'm trying to create an XSL transformation that will strip out development-specific attributes from deployment descriptors and other XML files. I have already successfully done so with web.xml but...
1
by: Michael | last post by:
I am having a problem with scoping of parameters in my XSLT Stylesheet...here is the stylesheet (the xml document is irrelevant for the example) <?xml version="1.0" encoding="UTF-8"?>...
10
by: bbembi_de | last post by:
Hello everyone, is it possible to give a transformation a input parameter? I want to use this parameter as a variable in my transformation. thanks. bye bembi
0
by: Amit00 | last post by:
Hi, I'm performing an xsl transformation in a page I built, and would like to use some custom controls in it (or asp controls, for that matter). I looked this issue up, and understood that it...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.