Comments & Suggestions - xmlObjectifier
I'm looking forward to hearing your comments, questions and suggestions


# 1
From: proton17
Date: 12/20/2007 7:00:07 PM
Welcome to Comments & Suggestions for xmlObjectifier!
# 2
From: chris thatcher
Date: 12/22/2007 9:31:16 AM
Hi, I noticed in one of my unit tests that a case like <pre> <mytag> text that wraps over the course of several lines </mytag> </pre> will not have the inner new lines stripped by your strip regexp. I forget the specification exactly, but i think that all new lines are removed unless there are 2 or more new lines in succession with only white space in between, in which case they are reduced to a sinlge new line. Thanks for the useful library!
# 3
From: chris thatcher
Date: 12/22/2007 9:35:44 AM
hmm that didnt post correctly... Hi, I noticed in one of my unit tests that a case like <pre> <mytag> text that wraps\n over the course of\n several lines\n </mytag> </pre> will not have the inner new lines stripped by your strip regexp. I forget the specification exactly, but i think that all new lines are removed unless there are 2 or more new lines in succession with only white space in between, in which case they are reduced to a sinlge new line. Thanks for the useful library!
# 4
From: Olivier
Date: 1/25/2008 5:16:30 AM
Hi, thanks for your great job. What is the difference between the standalone version available here (12/04/07) and the JQuery plugin (1.0.2 published the 11/12/07). If it's different, have you planned an update of the standalone version of this library ? Thanks in advance, Best regards, Olivier
# 5
From: proton17
Date: 1/28/2008 6:27:42 PM
@Oliver Standalone version is the same code only used independently from jQuery. If your environment has no need to use jQuery then use that one.
As far as code, it's maintained in a synchronous fashion, so if one changes, another one get's the same changes as well. Sincerely, Proton17
# 6
From: Ren? Paul
Date: 1/30/2008 12:26:26 AM
1-)Possible to see examples of: .getNodeByAttribute(attr, obj) .contains(attr, obj) .indexOf (attr, obj) ... 2-)If I know id "r2", How to read value "2" in root ? <root> <roman> <id>r1</id> <value>1</value> </roman> <roman> <id>r2</id> <value>2</value> </roman> </root>
# 7
From: Proton17
Date: 1/31/2008 12:46:44 PM
@Ren? Paul Hi Ren?, I have already added an example of indexOf, and working on the rest ...
# 8
From: Proton17
Date: 1/31/2008 2:51:34 PM
@Ren? Paul 2) There is no speciffic functionality to retrieve a parent node of a child. But you could loop through root.roman array until your root.roman[i].id[0].Text == "r2" I hope that answers your question.
# 9
From: Ren? Paul
Date: 2/2/2008 4:45:02 AM
Thanks for your answer. I follow your development with interest ... Great possibility. Good work. I check your others examples.
# 10
From: Zachary McCoy
Date: 2/20/2008 11:55:12 PM
Great job! I have two questions: (1) Would it be possible to license the code with Creative Commons AND GPLv2 or higher? JQuery is already MIT/GPL, and I could continue to use xmlObjectifier in my GPL'd production code ;-) (2) How do you get the element name of the root node? I'd like to check if the XML message is formatted as below... <event>some text</event> Thanks
# 11
From: Zachary McCoy
Date: 2/20/2008 11:57:54 PM
Sorry, that example XML is: <event>some text</event> Hopefully, it shows up this time... if not, it's just a single node (event) with some text inside.
# 12
From: Giovanni Siano
Date: 2/21/2008 1:53:49 PM
Great job! Trying to convert a simple empty DOMNode object with only attributes (eg: <node attr1="one" attr2="two"></node>) I've noticed a different behaviour of Mozilla and IE. The last one return a null JSON object. I solve the "bug" modifying setObjects() function changing if(!node.hasChildNodes()) {return null}; statement in if(node.hasChildNodes()) { .... omissis ...} and moving it after if () {setAttributes() } block. If you want I can send you the modified source code. Hope this help. Best regards. Giovanni
# 13
From: proton17
Date: 2/28/2008 12:49:07 PM
@Zachary McCoyDate 1) I'll definately look into that. After so many years of license free code I never actualy licensed anything till now :) 2) Hm.. Right now I don't have a way to show a root node name, but I'll look into that in the next release. P.S. I also fixed stupid escape bug for tags. Sry.
# 14
From: proton17
Date: 2/28/2008 5:42:03 PM
@Giovanni Siano Nice catch Giovanny, I'm looking at that problem myself, but it would be nice to compare your approach with mine (just for sanity check). If you have time u can shoot me you updated code at questions@terracoder.com Thank You
# 15
From: Proton17
Date: 2/28/2008 7:02:54 PM
@Zachary McCoyDate @Giovanni Siano All the fixes are in and ready for download. Enjoy :) Thank you for your input!!!
# 16
From: Zachary McCoy
Date: 2/28/2008 11:44:07 PM
You rock!
# 17
From: w?rmchen
Date: 3/19/2008 6:49:25 AM
Hi, I have problems getting started... I plan to send my complete form from my website as a JSON object to a script of mine. But I have no idea at the moment, how to insert your code and bind the send action to the submit button. It would be great if you could help me a little bit. Regards!
# 18
From: Jessiebb
Date: 3/23/2008 1:04:04 PM
omg.. good work, guy
# 19
From: proton17
Date: 3/24/2008 1:50:31 PM
@w?rmchen It seems like your request is a bit unrelated to xmlObjectifier library, but I'll try to help anyways. 1) You'll need jQuery - download it and include it on your page. 2) In the script block use this notation: $("#idofyourform").submit(function() { //use $.post(); return false // to cancel html native form submit }); Also look at jQuery serialize method to convert form data to post(able) format.
# 20
From: Ward
Date: 4/14/2008 8:11:12 PM
Is it possible to read a file with a very complex structure, say a mods file (this is a metadata schema for documenting objects, full of namespaces and attributes, and other things)? ex. (partial): <xmlData> <mods:mods> <mods:titleInfo> <mods:title>1 championnat d'Europe tous les 4 ans [inscribed]</mods:title> </mods:titleInfo> <mods:note>Depicts man marking a green soccer field with white chalk lines. Poster contrasts the length of time it takes to claim a championship with the length of time it takes for AIDS to claim another person.</mods:note> <mods:note>Part of "Le Sida en on meurt encore" campaign [AIDS, people still die from it]</mods:note> <mods:note>Poster held by Louise M. Darling Biomedical Library. History & Special Collections, Collection no. 306, item FR023.</mods:note> <mods:inscription>Additional poster text: 1 personne contamin?e par le virus de Sida toutes les 2 heures en France</mods:inscription> <mods:inscription>Translation of additional poster text: One person contaminated by the AIDS virus every two hours in France.</mods:inscription> <mods:originInfo> <mods:publisher>France</mods:publisher> <mods:dateCreated>[2000?]</mods:dateCreated> <mods:dateCreated>2000</mods:dateCreated> </mods:originInfo> <mods:typeOfResource>posters</mods:typeOfResource> <mods:typeOfResource>still image</mods:typeOfResource> <mods:physicalDescription> <mods:dimensions>41 x 61 cm. (16 x 24 in.)</mods:dimensions> </mods:physicalDescription> <mods:language>fre</mods:language> <mods:subject> <mods:topic>Athletic fields</mods:topic> <mods:topic>Soccer</mods:topic> <mods:topic>AIDS (Disease)--Transmission</mods:topic> <mods:topic>Acquired Immunodeficiency Syndrome--transmission</mods:topic> </mods:subject> <mods:name> <mods:namePart>Louise M. Darling Biomedical Library. History & Special Collections</mods:namePart> <mods:role><mods:roleTerm type="text">repository</mods:roleTerm></mods:role> <mods:namePart>Comit? fran?ais d'?ducation pour la sant?</mods:namePart> <mods:role><mods:roleTerm type="text">publisher</mods:roleTerm></mods:role> <mods:namePart>France. Minist?re de l'emploi et de la solidarit?</mods:namePart> <mods:role><mods:roleTerm type="text">sponsor</mods:roleTerm></mods:role> <mods:namePart>France. Secretariat d'Etat ? la sant? et aux handicapes</mods:namePart> <mods:role><mods:roleTerm type="text">sponsor</mods:roleTerm></mods:role> <mods:namePart>Sida Info Service (France)</mods:namePart> <mods:role><mods:roleTerm type="text">repository</mods:roleTerm></mods:role> </mods:name> </mods:mods> </xmlData>
# 21
From: proton17
Date: 4/16/2008 9:20:38 AM
@Ward Yes. :) (ty for posting such a big example) File will be converted (as long as it's valid, the only exception is that all namespaces will be stripped. Ex. what was "mods:namePart" will be just "namePart"
# 22
From: leo
Date: 5/17/2008 5:16:16 PM
Thanks much, your plugin just pulled me out of an XML rabbit hole! THANK YOU! THANK YOU! THANK YOU!
# 23
From: leo
Date: 5/17/2008 6:07:30 PM
Can you please post an example in this comments section showing how to use the "getNodeByAttribute" method? Ive tried a few things and I am getting no love. Ive been trying things like this: json.getNodeByAttribute('name', 'user') my goal being to get the node where name="user". Am I just completely dafted or what?
# 24
From: Proton17
Date: 5/17/2008 11:00:14 PM
@leo Method getNodeByAttribute is not as flexible as XPath expressions, so it works on an array of nodes that may contain attribute name = "user". So example would be: json.search_nodes.getNodeByAttribute("name", "user") //returns you a matching search_nodes json.search_nodes is an array. I hope this helps - i'm trying to make this more user friendly :)
# 25
From: epsilon
Date: 6/5/2008 8:59:28 PM
xmlObjectifier does not enclose its code under the following block: (function($) { // plugin code here, use $ as much as you like })(jQuery); Hence it's impossible to use this library if one changes the jQuery alias to something else.
# 26
From: proton17
Date: 6/9/2008 4:06:36 PM
@epsilon Point taken, corrections have been made. Thank you
# 27
From: name
Date: 7/19/2008 8:01:05 AM
neploxo tak, i`m glad,
# 28
From: taylor
Date: 7/22/2008 3:35:55 PM
I've been unable to get any of the examples to run. It seems like they contain snippets of the code but not all of it and I'm somewhat new to this and don't know how to get it to work. Is there some sort of "Hello World" version of the examples that contains a complete HTML page that can be copied, pasted, and modified? Thanks
# 29
From: proton17
Date: 7/23/2008 6:47:37 PM
@taylor Hello World example is now available for download from examples page (at the top).
# 30
From: AlexM
Date: 8/16/2008 10:11:19 AM
Your blog is interesting! Keep up the good work!
# 31
From: Paul F
Date: 8/18/2008 6:43:53 AM
Hi, thanks for this really handy bit of code. Have been using this quite heavily and encountered a couple of bugs, easily fixed but thought you should know about them ;) Firstly a simple issue - the _children array gets initialised every time a child node is encountered - this occurs on line 185 of the current source: obj._children = []; This is called for every child node, meaning the _children array only lists the last child node encountered. This should be correctly initialised outside the loop e.g. after line 179: var n = 0; obj._children = []; do {... Secondly the major issue I have encountered is the namespace clash between attributes and children. E.g. a file containing the following XML snippet will not be correctly loaded: <screen title="Screen Title 1"> <title>Screen Title 2</title> </screen> Admittedly this is partly down to our poorly designed XML schema but we are stuck with it (it has been built up over the last 4-5 years...) My own fix has been to move the attributes to obj._attr, which is referenced by obj.getAttribute() and obj.setAttribute(). I would be happy to provide my source and contribute these changes to the plugin if you wish :) However the second fix does remove the convenience of being able to use dot notation for attributes, and will break existing code that uses the plugin. For most uses it may be better to fix the XML schema! Paul
# 32
From: Paul F
Date: 8/18/2008 6:47:37 AM
Just to add - you can still use dot notation via the _attr array - e.g. obj._attr.title in the above example. But this still requires a change to existing code using the library.
# 33
From: proton17
Date: 8/18/2008 8:02:14 AM
@Paul F Thank you for using my code and paying such a close attention to little imperfections it may have :). I'm always trying to improve it so these kind of comments are very valuable to me. Now let's get to bugs ... 1. First issue described is not really a bug, it's done for a reason. If you pay closer attention obj._children is only added to the nodes of type 1(a Node) since I wouldn't want to have that array assigned to CDATA or Text nodes. With your suggestion I would have _children node present in every type of node I encounter during processing, and is undesired effect that adds to the size of the output. 2. This is a more serious bug that I will definately attempt to fix w/o breaking existing functionality. Maybe I will add numeration or a prefix to the attribute names whenever a collision is encountered. Still deciding :).
# 34
From: Paul F
Date: 8/18/2008 8:34:30 AM
I'm glad you found the feedback useful :) I just had a look at your beta which fixes the initialisation of obj._children in a better way ;) I'm going to make use of the beta now (rolling my own modifications back in) as it looks a lot more efficient. (The other modification I have made was a simple convenience - adding a nodeName property to each node.) WRT solving the namespace issue, since names containing hyphens are changed anyway, a prefix for names seems like a consistent approach. Thanks again for all your work
Leave a comment
* - required
You can enter (X)HTML tags here.
Terracoder.com © 2007 | All Rights reserved
xmlObjectifier by terracoder.com is licensed under a Creative Commons Attribution-No Derivative Works 3.0 United States License. Based on a work at terracoder.com.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses.
Creative Commons License
Job Opportunities