Jump to content

karthikin

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by karthikin

  1. This is my input xml file: <MyTest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.test.com/test"> <MyHubs xsi:nil="true" /><MyLanes xsi:nil="true" /> When i serilaize it i'm getting the output xml in this format: <MyTest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.test.com/test"> <MyHubs /><MyLanes/> How can i maintain the same format for the output xml file as exactly as the input file??
  2. This is my xml file: <?xml version="1.0" encoding="UTF-8"?><CONTACTS><CONTACT><FirstName>Arun</FirstName><LastName>Arun_Neelam</LastName><Email>nuraaa_iceee@yahoo.co.in</Email></CONTACT><CONTACT><FirstName>Arun</FirstName><LastName>Arun_Neelam</LastName><Email>nuraaa_iceee@gmail.com</Email></CONTACT></CONTACTS> I want to have the output in the following way: <?xml version="1.0" encoding="windows-1250"?><CONTACTS> <CONTACT> <FirstName>Arun</FirstName> <LastName>Arun_Neelam</LastName> <Email>nuraaa_iceee@gmail.com</Email> <Email>nuraaa_iceee@yahoo.co.in</Email></CONTACT></CONTACTS> How do i group them by checking two identical values of the <FirstName><LastName>, if it's true then take the email values and put it as a single contact.I'm not sure I can do it with current-group() and current-grouping-key().Thank you for your support.
  3. I have an xml file and I want to how can i remove the white-space in the xml file.For example this is my xml file: <?xml version="1.0" encoding="UTF-8"?><CONTACTS><CONTACT><FirstName>SandfordFrankie</FirstName><LastName>Frankie Sandford</LastName><gmail/><yahoo/><URL>http://www.facebook.com/FrankieSandfordApprovedPage</URL><Facebook-ID/></CONTACT><CONTACT><FirstName>Julien </FirstName><LastName>Foder</LastName><gmail/><yahoo/><URL/><Facebook-ID/></CONTACT><CONTACT><FirstName>Stéphénè</FirstName><LastName>Rio</LastName><gmail/><yahoo>rio.sté1234@yahoo.com</yahoo><URL/><Facebook-ID/></CONTACT><CONTACT><FirstName>Aana</FirstName><LastName>Joséph</LastName><gmail></gmail><yahoo>aana.josé@yahoo.com</yahoo><URL></URL><Facebook-ID></Facebook-ID></CONTACT></CONTACTS> If i delete a record and it'll be like this: <?xml version="1.0" encoding="UTF-8"?><CONTACTS><CONTACT><FirstName>Julien </FirstName><LastName>Foder</LastName><gmail/><yahoo/><alcatel-lucent/><URL/><Facebook-ID/></CONTACT><CONTACT><FirstName>Stéphénè</FirstName><LastName>Rio</LastName><gmail/><yahoo>rio.sté1234@yahoo.com</yahoo><URL/><Facebook-ID/></CONTACT><CONTACT><FirstName>Aana</FirstName><LastName>Joséph</LastName><gmail></gmail><yahoo>aana.josé@yahoo.com</yahoo><URL></URL><Facebook-ID></Facebook-ID></CONTACT></CONTACTS> When i delete a record from my xml file, how can i remove the white space from the file?Thanks guys.
  4. Sorry guys found the solution. The below code works fine. Thanks guys. function closeWindow() {window.close();if (window.opener && !window.opener.closed) {window.opener.location.reload();} }
  5. Hi Friends,I'm working on XUL, I have a window that opens another window. When the child window closes I want to refresh the contents of the parent.This is my first window(sundayevening.xul), which has a function to open the child window(iframetest.xul) function edit(){var windowObjectReference = window.openDialog("chrome://hello/content/iframetest.xul","iframetest", "Height=600, width=1024,resizable,scrollbars=yes,status=1" );}var sURL = unescape(window.location.pathname); function refresh(){ window.location.href = sURL;} This is my second xul file(iframetest.xul), here i have a button to close the this child window. When I close this child window, how can I refresh/reload the parent window(sundayevening.xul).In the second window, i use the following script: function closeWindow() {window.close();refresh();} My above code is not refreshing/reloading the parent window when i close the child window! Thanks for your support and help.
  6. Hi Guys,I use XSLT function to generate a unique id for my xml file <xsl:value-of select="generate-id(.)"/> and the output is "N65539".Then I used the same function and run the XSLT processor in Firefox XUL for the same XML file, the output of the id is "id0x03bb5600" in this format.How can i specify certain type to generate a unique id?This function generate id for <Customer-ID> </Customer-ID> in my XML file. Output 1: <Customer-ID>N65539</Customer-ID>Output 2: <Customer-ID>id0x03bb5600</Customer-ID>Thanks for your support.
  7. Hi guys, I have a xml file and I append a new contact in my XML file from XUL.When i append a new contact I want to generate a ID to my new customer contact in my xml file using XSLT.Is it possible to load my XSLT file through my xml file and save it? Please give me a suggestion guys!!! Thank you.My xml file: <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="idgenerator.xsl"?><CONTACTS><CONTACT><Customer-ID>N65539</Customer-ID><FirstName>Ben</FirstName><LastName>Foden</LastName><email></email><address></address><state>AZ</state><country>US</country></CONTACT><CONTACT><Customer-ID>N65539</Customer-ID><FirstName>Nimal</FirstName><LastName>Anup</LastName><email>nimal.anup@gmail.com</email><address></address><state>TN</state><country>IN</country></CONTACT><CONTACTS> My XSLT file: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="CONTACT"> <xsl:copy> <PDE-Identity> <xsl:value-of select="generate-id(.)"/> </PDE-Identity> </xsl:copy> </xsl:template></xsl:stylesheet>
  8. I couldn't get the values of my XML file in my XUL tree. I have a problem with my query expr here: <query expr="*"> <assign anonid="fulltext" var="?FULLTEXT" expr= "concat(Customer-ID,FirstName,LastName,gmail,yahoo,URL,Facebook-ID)"/> </query>Please check my full code below. Thanks for you support in advance. <tree editable="false" id="myTodoListTree" flex="1" seltype="multiple"datasources="file://D:/xmlparserinxul/final.xml" ref="*" querytype="xml" > <treecols> <treecol id="pde" label="Customer-ID" flex="1" persist="width ordinal hidden" /> <treecol sortActive="true" sort="?name" id="name" label="FirstName" flex="1" persist="width ordinal hidden" sortDirection="ascending"/> <treecol sortActive="true" sort="?lastname" id="lastname" label="LastName" flex="1" persist="width ordinal hidden" sortDirection="ascending"/> <treecol sortActive="true" sort="?gmail" id="gmail" label="Gmail" flex="1" persist="width ordinal hidden" sortDirection="ascending"/> <treecol sortActive="true" sort="?yahoo" id="yahoo" label="Yahoo" flex="1" persist="width ordinal hidden" sortDirection="ascending"/> <treecol sortActive="true" sort="?url" id="url" label="Facebook" flex="1" persist="width ordinal hidden" sortDirection="descending"/> <treecol sortActive="true" sort="?pin" id="pin" label="Facebook-ID" flex="1" persist="width ordinal hidden" sortDirection="ascending"/> </treecols> <template> <query expr="*"> <assign anonid="fulltext" var="?FULLTEXT" expr= "concat(Customer-ID,FirstName,LastName,gmail,yahoo,URL,Facebook-ID)"/> </query> <rule> <conditions> <where id="filter" subject="?FULLTEXT" rel="contains" value="" ignorecase="true" multiple="true" /> </conditions> <action> <treechildren id="myTodoListTreeChildren"> <treeitem uri="?"> <treerow> <treecell label="?Customer-ID"/> <treecell label="?FirstName"/> <treecell label="?LastName"/> <treecell label="?gmail"/> <treecell label="?yahoo"/> <treecell label="?URL"/> <treecell label="?Facebook-ID"/> </treerow> </treeitem> </treechildren> </action> </rule> </template> </tree> My xml file: <CONTACTS><CONTACT><Customer-ID>N65553</Customer-ID><FirstName>John</FirstName><LastName>Killer</LastName><gmail>john.killer@gmail.com</gmail><yahoo/><URL/><Facebook-ID/></CONTACT><CONTACT><Customer-ID>N65560</Customer-ID><FirstName>Karthik</FirstName><LastName>Kayan</LastName><gmail/><yahoo>karthy@yahoo.co.in</yahoo><alcatel-lucent/><URL/><Facebook-ID/></CONTACT></CONTACTS> Solution : This solution just for FirstName:<query expr="CONTACT"> <assign var="?fname" expr="./FirstName/text()"/> </query><assign var="?fulltext" expr="concat(./FirstName/text());<rule> <conditions> <where id="filter" subject="?fulltext" rel="contains" value="" ignorecase="true" multiple="true" /> </conditions> </rule>
  9. Her is the link: //function from http://puna.net.nz/archives/Code/Mozilla%2...cal%20files.htm
  10. HI, I'm able to edit, add new contact in my XML file using java-script. Please have a look at this code:function saveFile(output, savefile) { //var savefile = "c:\\mozdata.txt"; try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("Permission to save file was denied."); } var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath( savefile ); if ( file.exists() == false ) { alert( "File Updated Successfully "); file.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 ); } var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance( Components.interfaces.nsIFileOutputStream ); /* Open flags #define PR_RDONLY 0x01 #define PR_WRONLY 0x02 #define PR_RDWR 0x04 #define PR_CREATE_FILE 0x08 #define PR_APPEND 0x10 #define PR_TRUNCATE 0x20 #define PR_SYNC 0x40 #define PR_EXCL 0x80 */ /* ** File modes .... ** ** CAVEAT: 'mode' is currently only applicable on UNIX platforms. ** The 'mode' argument may be ignored by PR_Open on other platforms. ** ** 00400 Read by owner. ** 00200 Write by owner. ** 00100 Execute (search if a directory) by owner. ** 00040 Read by group. ** 00020 Write by group. ** 00010 Execute by group. ** 00004 Read by others. ** 00002 Write by others ** 00001 Execute by others. ** */ outputStream.init( file, 0x04 | 0x08 | 0x20, 420, 0 ); var result = outputStream.write( output, output.length ); outputStream.close();alert( "File Updated Successfully ");clear();}
  11. <?xml version="1.0" encoding="UTF-8"?><CONTACTS><CONTACT> <PDE-Identity>N676767</PDE-Identity> <FirstName>Dido</FirstName> <LastName>Lorence</LastName> <gmail/> <yahoo>dido.lorence@yahoo.com</yahoo> <alcatel-lucent/> <URL/> <Facebook-ID/></CONTACT></CONTACTS> How can i get the value of my PDE-Identity and delete all the childNodes including the <CONTACT> using Javascript, DOM Method.Thanks Guys!
  12. You are right! Could you please explain to me how could I check for PDE-Identity element in each contact and get the remaining values.I have a for loop to check for the number of characters of the search item how could I proceed further?Could you explain to me in detail with some code. Thank you very much!
  13. Hi Friends,(I'm not really good at programming but still i'm learning to understand and do it.)How can i search for a tagName in XML file using JavaScript if a match found then store all the values in an array and display the output.In my xml file <CONTACT> is the parent node and inside i have a <PDE-Identity>N65553</PDE-Identity> when a user type the <PDE-Identity>value in the search box and click on search it should match the corresponding PDE-Identity value in the contact and display the output in the corresponding text boxes.I'll be grateful for any help offered! Thanks guys.My xml file: <?xml version="1.0" encoding="UTF-8"?><CONTACTS><CONTACT><PDE-Identity>N65539</PDE-Identity><FirstName>Arun_niit</FirstName><LastName>Arun_niit</LastName><gmail/><yahoo>nura_poping@yahoo.co.in</yahoo><alcatel-lucent/><URL/><Facebook-ID/></CONTACT><CONTACT><PDE-Identity>N65593</PDE-Identity><FirstName>Rangarajkarthik</FirstName><LastName>karthik Rangaraj</LastName><gmail>kart2006@gmail.com</gmail><yahoo>karthikrangaraj@yahoo.com</yahoo><alcatel-lucent/><URL/><Facebook-ID/></CONTACT></CONTACTS> This is my java script: window.onload = loadIndex;function loadIndex() { // load indexfile// most current browsers support document.implementation if (document.implementation && document.implementation.createDocument) { xmlDoc = document.implementation.createDocument("", "", null); xmlDoc.load("file://D:/xmlparserinxul/finalversion2.xml"); }// MSIE uses ActiveX else if (window.ActiveXObject) { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; xmlDoc.load("file://D:/xmlparserinxul/finalversion2.xml"); }}function searchIndex() { // search the index (duh!) if (!xmlDoc) { loadIndex(); } // get the search term from a form field with id 'searchme' var searchterm = document.getElementById("find").value; var x = xmlDoc.getElementsByTagName("CONTACT"); var allitems = xmlDoc.getElementsByTagName("PDE-Identity"); results = new Array; if (searchterm.length < 6) { alert("Please enter 6 characters, PDE starts with 'N' followed by 5 numbers"); } else { for (var i=0;i<allitems.length;i++) {// see if the XML entry matches the search term,// and (if so) store it in an array }// send the results to another function that displays them to the user showResults(); }}function showResults() {var str = get_node_value(x.getElementsByTagName("PDE-Identity")[0] );document.getElementById("PDE-Identity").value=str; var str = get_node_value(x.getElementsByTagName("FirstName")[0] );document.getElementById("FirstName").value=str; var str = get_node_value(x.getElementsByTagName("LastName")[0] );document.getElementById("LastName").value=str; var str = get_node_value(x.getElementsByTagName("gmail")[0] );document.getElementById("gmail").value=str; var str = get_node_value(x.getElementsByTagName("yahoo")[0] );document.getElementById("yahoo").value=str; var str = get_node_value(x.getElementsByTagName("alcatel-lucent")[0] );document.getElementById("alcatel-lucent").value=str; var str = get_node_value(x.getElementsByTagName("URL")[0] );document.getElementById("URL").value=str; var str = get_node_value(x.getElementsByTagName("Facebook-ID")[0] );document.getElementById("Facebook-ID").value=str;}function get_node_value (element) { if (element.childNodes.length > 0) { return element.childNodes[0].nodeValue; } else { return ""; }}function clear(){document.getElementById("find").value='';} My text boxes in XUL : <label value="Type PDE-ID to Search"/> <textbox id="find" type="search"/> <button label="Search" oncommand="searchIndex();"/> <button label="Clear" oncommand="clear();"/> </hbox><row> <label value="PDE-Identity"/> <textbox id="PDE-Identity" value=""/> </row> <row> <label value="FirstName"/> <textbox id="FirstName" value=""/> </row> <row> <label value="LastName"/> <textbox id="LastName" value=""/> </row> <row> <label value="Gmail"/> <textbox id="gmail" value=""/> </row> <row> <label value="Yahoo"/> <textbox id="yahoo" value=""/> </row> <row> <label value="Alcatel-Lucent"/> <textbox id="alcatel-lucent" value="" /> </row> <row> <label value="URL"/> <textbox id="URL" value="" /> </row> <row> <label value="Facebook-ID"/> <textbox id="Facebook-ID" value="" /> </row>
  14. @Deirdre's Dad: You are right. I should learn basics properly. This is the first time i'm working on a real project and it's a big experience for me. I'm struggling a lot. I hope i'll be able to do it with some help.I'm sorry that I have bothered you too much. You have helped me a lot.Thank you very much.
  15. @Deirdre's Dad: I'm waiting for you reply. Thank you.
  16. @Deirdre's Dad: I just thought that if i have more than 5O contacts in xml file using it'll be hard to display in the menu list. So i would like to have a search field to type the PDE-ID to display the contact information. <hbox align="center" > <label value="Type PDE-ID to Search"/> <textbox id="find" type="search"/> <button label="Search" oncommand="search();"/> <button label="Clear" oncommand="clear();"/> </hbox> function search(){var x = document.getElementById("find").value;alert('hi');} function clear(){document.getElementById("find").value='';} I hope now you can assist me like the other day. This time i have learnt as much as i could. Please help me... Thank you.
  17. I'm sorry if i wasted your time unnecessarily. I completely forgot to include the function in the menu-list. <menulist id="menulist" oncommand="display()"> I'm started working on it. I know how to make event function in the menu-list. I'm sure i'll get back to you with the code to select menu item. I'm a slow learner and I never worked on programming much. I'm sure i'll be able to do this and I already started working on it.I'll get back to you tomorrow. Please stand by me. Thank you very much.
  18. Hi, i'm sorry. I have no idea how to start writing function when we select a menu item. I need some guidance to proceed. Thank you very much.
  19. I'm sorry to bother you too much 'cause it's confusing to me a little bit. Please give me some more detailed information. Thank you very much.Her is my complete code, I have written this code in XUL file. <?xml version="1.0"?><?xml-stylesheet href="chrome://global/skin/" type="text/css"?><window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" > <grid> <columns> <column flex="1"/> <column flex="4"/> <column flex="4"/> <column flex="4"/> <column flex="4"/> </columns> <rows> <row><label control="" value="Select PDE-ID:"/><menulist id="menulist" oncommand="display()"> > <menupopup id="populate"> </menupopup></menulist> </row> </rows></grid><groupbox> <label control="" accesskey="" value=""/> <grid> <columns> <column flex="1"/> <column flex="4"/> <column flex="4"/> <column flex="4"/><column flex="4"/> </columns> <rows > <row> <label value="PDE-Identity"/> <textbox id="pde" value=""/> </row> <row> <label value="FirstName"/> <textbox id="fname" value=""/> </row> <row> <label value="LastName"/> <textbox id="lname" value=""/> </row> <row> <label value="Gmail"/> <textbox id="gmaail" value=""/> </row> <row> <label value="Yahoo"/> <textbox id="yaahoo" value=""/> </row> <row> <label value="Alcatel-Lucent"/> <textbox id="alcaatel-lucent" value="" /> </row> <row> <label value="URL"/> <textbox id="facebook" value="" /> </row> <row> <label value="Facebook-ID"/> <textbox id="fid" value="" /> </row> </rows> </grid><label value=""/><grid flex="1"> <columns> <column flex=""/> <hbox align="center" > <button id="previous" label="Previous" oncommand="previous()" /> <button id="next" label="Next" oncommand="next()"/> <button id="save" label="Save" onclick="write()"/> <button id="reset" label="Reset" onclick="reset()"/> </hbox></columns></grid></groupbox> <separator/><text value="© 2011"/><separator/> <script type="application/x-javascript"><![CDATA[ var objXMLDoc = document.implementation.createDocument('','doc',null);var objXMLHTTP = new XMLHttpRequest(); objXMLHTTP.open("GET", "file://D:/xmlparserinxul/finalversion2.xml", false);objXMLHTTP.send(null);objXMLDoc = objXMLHTTP.responseXML; var objNodeList = objXMLDoc.getElementsByTagName("PDE-Identity"); for (var i=0; i<objNodeList.length; i++){ var menuPopup=document.getElementById('populate'); val = get_node_value(objNodeList[i] ); var menu1=document.createElement("menuitem"); menu1.setAttribute("label", val); menuPopup.appendChild(menu1);}function display(){} var x = objXMLDoc.getElementsByTagName("CONTACT");i=-1; function init(){ var str = get_node_value(x[i].getElementsByTagName("PDE-Identity")[0] );document.getElementById("pde").value=str; var str = get_node_value(x[i].getElementsByTagName("FirstName")[0] );document.getElementById("fname").value=str; var str = get_node_value(x[i].getElementsByTagName("LastName")[0] );document.getElementById("lname").value=str; var str = get_node_value(x[i].getElementsByTagName("gmail")[0] );document.getElementById("gmaail").value=str; var str = get_node_value(x[i].getElementsByTagName("yahoo")[0] );document.getElementById("yaahoo").value=str; var str = get_node_value(x[i].getElementsByTagName("alcatel-lucent")[0] );document.getElementById("alcaatel-lucent").value=str; var str = get_node_value(x[i].getElementsByTagName("URL")[0] );document.getElementById("facebook").value=str; var str = get_node_value(x[i].getElementsByTagName("Facebook-ID")[0] );document.getElementById("fid").value=str; }function get_node_value (element) { if (element.childNodes.length > 0) { return element.childNodes[0].nodeValue; } else { return ""; }} function next(){ if (i<x.length-1) { i++; init(); }} function previous(){/*document.getElementById("pde").value='';document.getElementById("fname").value='';document.getElementById("lname").value=''; document.getElementById("gmaail").value='';document.getElementById("yaahoo").value='';document.getElementById("alcaatel-lucent").value='';document.getElementById("facebook").value='';document.getElementById("fid").value=''; */ if (i>0) { i--; init(); }}function reset(){document.getElementById("pde").value='';document.getElementById("fname").value='';document.getElementById("lname").value='';document.getElementById("gmaail").value='';document.getElementById("yaahoo").value='';document.getElementById("alcaatel-lucent").value='';document.getElementById("facebook").value='';document.getElementById("fid").value=''; } function save(){Components.utils.import("resource://gre/modules/NetUtil.jsm");Components.utils.import("resource://gre/modules/FileUtils.jsm"); // file is nsIFile, data is a string // You can also optionally pass a flags parameter here. It defaults to// FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE;var ostream = FileUtils.openSafeFileOutputStream(file) var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]. createInstance(Components.interfaces.nsIScriptableUnicodeConverter);converter.charset = "UTF-8";var istream = converter.convertToInputStream(data); // The last argument (the callback) is optional.NetUtil.asyncCopy(istream, ostream, function(status) { if (!Components.isSuccessCode(status)) { // Handle error! return; } // Data has been written to the file.}); } ]]></script> </window>
  20. Thank you for being patient with me and for your help. It works! I used you code and put it in my for loop. Like this: var objNodeList = objXMLDoc.getElementsByTagName("PDE-Identity"); for (var i=0; i<objNodeList.length; i++){ var menuPopup=document.getElementById('populate'); val = get_node_value(objNodeList[i] ); var menu1=document.createElement("menuitem"); menu1.setAttribute("label", val); menuPopup.appendChild(menu1);} Do you have any suggestion/idea to get information all the <contact> when we select the "PDE-Identity" from the menu-list? Thank you very much.
  21. Hi, do you have any suggestion? Please give me some idea...I'm waiting for your reply. Thanks for your support.
  22. OK. I'm sorry...Here is the detailed problem....This is my menulist<label control="" value="Select PDE-ID:"/><menulist id="menulist" oncomman=""> <menupopup id="populate"> </menupopup></menulist> This is my java script: var objNodeList = objXMLDoc.getElementsByTagName("PDE-Identity"); for (var i=0; i<objNodeList.length; i++){ var menuPopup=document.getElementById('populate'); var menu1=document.createElement("menuitem"); menu1.setAttribute("label",'objNodeList'); menuPopup.appendChild(menu1);} Here i'm trying to get the "getElementsByTagName("PDE-Identity");" to my menu-list. I couldn't get the values of the PDE-Identity in my menu-list.Thank you.
×
×
  • Create New...