xmljs-users Mailing List for xml for SCRIPT (Page 9)
Brought to you by:
djoham,
witchhunter
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(8) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(11) |
Feb
(9) |
Mar
(20) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
(14) |
Aug
(14) |
Sep
(10) |
Oct
(5) |
Nov
(2) |
Dec
(11) |
2005 |
Jan
(12) |
Feb
(4) |
Mar
(3) |
Apr
(5) |
May
|
Jun
|
Jul
(2) |
Aug
(12) |
Sep
|
Oct
|
Nov
(1) |
Dec
(4) |
2006 |
Jan
(2) |
Feb
(2) |
Mar
(4) |
Apr
(2) |
May
|
Jun
(2) |
Jul
|
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
(8) |
2007 |
Jan
|
Feb
(2) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
(8) |
Nov
|
Dec
(2) |
2008 |
Jan
(4) |
Feb
|
Mar
|
Apr
(5) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(3) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
(1) |
Jul
(1) |
Aug
(4) |
Sep
(2) |
Oct
|
Nov
|
Dec
(1) |
2010 |
Jan
(6) |
Feb
(2) |
Mar
(4) |
Apr
(3) |
May
(2) |
Jun
(2) |
Jul
(5) |
Aug
(2) |
Sep
(1) |
Oct
(2) |
Nov
(1) |
Dec
(2) |
2011 |
Jan
(2) |
Feb
(1) |
Mar
(2) |
Apr
(2) |
May
(4) |
Jun
(4) |
Jul
(5) |
Aug
(5) |
Sep
(4) |
Oct
(3) |
Nov
(1) |
Dec
|
2012 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(3) |
Mar
(2) |
Apr
(2) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(6) |
2014 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2016 |
Jan
|
Feb
|
Mar
(5) |
Apr
(3) |
May
(5) |
Jun
(8) |
Jul
(3) |
Aug
(14) |
Sep
(22) |
Oct
(9) |
Nov
|
Dec
(1) |
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: David J. <dj...@ya...> - 2004-03-20 07:19:00
|
Hi Stepan, I *think* I might have a fix for this. I'll give it more of a look tomorrow and if it does work, send you a new copy of xmlw3cdom.js. What *are* you doing to my poor parser anyway? :) David --- Stepan Riha <xm...@no...> wrote: > The W3CDOM parser incorrectly strips whitespace before and after entities. For > example, the tag > <TAG>Say Hello <b>World</b> and Sky</TAG> > should be parsed as > "Say Hello <b>World</b> and Sky" > but is incorrectly parsed as > "Say Hello<b>World</b>and Sky" > > A workaround (for my application) is to use > parser.preserveWhiteSpace = true; > and then trim the text nodes myself. > > The problem is caused in DOMImplementation__parseLoop() where you trim pContent > in XMLP._TEXT nodes. The trimming should really only happen after text nodes > have been normalized (and thus contain entities). > > The following demonstrates the problem: > > function xmljsDOMExample() { > var xml; > xml = "" > + "<?xml version=\"1.0\"?>" > + "<ROOT>" > + "<TAG1>" > + "Say Hello <b>World</b> and Sky" > + "</TAG1>" > + "</ROOT>"; > > //instantiate the W3C DOM Parser > var parser = new DOMImplementation(); > > parser.preserveWhiteSpace = true; > > //load the XML into the parser and get the DOMDocument > var domDoc = parser.loadXML(xml); > > //get the root node > var docRoot = domDoc.getDocumentElement(); > > //get the "TAG1" element > var tag1 = docRoot.getElementsByTagName("TAG1").item(0); > > //the following should be > //"Hello <b>World</b> and Sky" > alert(tag1.firstChild.data); > }// end function xmljsDOMExample > > - Stepan > > -- > Stepan Riha > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users __________________________________ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html |
From: Stepan R. <xm...@no...> - 2004-03-19 17:44:41
|
The W3CDOM parser incorrectly strips whitespace before and after entities. For example, the tag <TAG>Say Hello <b>World</b> and Sky</TAG> should be parsed as "Say Hello <b>World</b> and Sky" but is incorrectly parsed as "Say Hello<b>World</b>and Sky" A workaround (for my application) is to use parser.preserveWhiteSpace = true; and then trim the text nodes myself. The problem is caused in DOMImplementation__parseLoop() where you trim pContent in XMLP._TEXT nodes. The trimming should really only happen after text nodes have been normalized (and thus contain entities). The following demonstrates the problem: function xmljsDOMExample() { var xml; xml = "" + "<?xml version=\"1.0\"?>" + "<ROOT>" + "<TAG1>" + "Say Hello <b>World</b> and Sky" + "</TAG1>" + "</ROOT>"; //instantiate the W3C DOM Parser var parser = new DOMImplementation(); parser.preserveWhiteSpace = true; //load the XML into the parser and get the DOMDocument var domDoc = parser.loadXML(xml); //get the root node var docRoot = domDoc.getDocumentElement(); //get the "TAG1" element var tag1 = docRoot.getElementsByTagName("TAG1").item(0); //the following should be //"Hello <b>World</b> and Sky" alert(tag1.firstChild.data); }// end function xmljsDOMExample - Stepan -- Stepan Riha |
From: Stepan R. <xm...@no...> - 2004-03-19 17:42:03
|
The W3CDOM parser incorrectly strips whitespace before and after entities. For example, the tag <TAG>Say Hello <b>World</b> and Sky</TAG> should be parsed as "Say Hello <b>World</b> and Sky" but is incorrectly parsed as "Say Hello<b>World</b>and Sky" A workaround (for my application) is to use parser.preserveWhiteSpace = true; and then trim the text nodes myself. The problem is caused in DOMImplementation__parseLoop() where you trim pContent in XMLP._TEXT nodes. The trimming should really only happen after text nodes have been normalized (and thus contain entities). The following demonstrates the problem: function xmljsDOMExample() { var xml; xml = "" + "<?xml version=\"1.0\"?>" + "<ROOT>" + "<TAG1>" + "Say Hello <b>World</b> and Sky" + "</TAG1>" + "</ROOT>"; //instantiate the W3C DOM Parser var parser = new DOMImplementation(); parser.preserveWhiteSpace = true; //load the XML into the parser and get the DOMDocument var domDoc = parser.loadXML(xml); //get the root node var docRoot = domDoc.getDocumentElement(); //get the "TAG1" element var tag1 = docRoot.getElementsByTagName("TAG1").item(0); //the following should be //"Hello <b>World</b> and Sky" alert(tag1.firstChild.data); }// end function xmljsDOMExample - Stepan -- Stepan Riha |
From: David J. <dj...@ya...> - 2004-03-15 16:20:30
|
Hi Stepan! Thanks for the bug report. I'll get this fix into 3.1. Would it be possible for you to provide a quick recreation for me on this bug. I'd like to take it and put it into one of the test suites so we make sure this doesn't happen again... Thanks! David --- Stepan Riha <xm...@no...> wrote: > The DOMNode.removeChild(oldChild) method does not clean up nextSibling and > previousSibling pointers of the oldChild. This can lead to problems when the > child is then appended to some other node. > > The fix is in DOMNode.prototype.removeChild. Replace > > return oldChild; > > with > > oldChild.previousSibling = null; > oldChild.nextSibling = null; > return oldChild; > > > - Stepan > > -- > Stepan Riha > xm...@no... > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users __________________________________ Do you Yahoo!? Yahoo! Mail - More reliable, more storage, less spam http://mail.yahoo.com |
From: Stepan R. <xm...@no...> - 2004-03-15 05:47:54
|
The DOMNode.removeChild(oldChild) method does not clean up nextSibling and previousSibling pointers of the oldChild. This can lead to problems when the child is then appended to some other node. The fix is in DOMNode.prototype.removeChild. Replace return oldChild; with oldChild.previousSibling = null; oldChild.nextSibling = null; return oldChild; - Stepan -- Stepan Riha xm...@no... |
From: David J. <dj...@ya...> - 2004-03-11 01:32:44
|
Hi Robert, Couple of questions... 1) Are you talking about the __escapeString and __unescapeString functions in the SAX file? Those use regular expressions and as far as I can see are one pass. The classic dom is multi-pass primarily because you can't count on regular expression support in all the browsers the classic dom is supposed to work with. 2) > 1) original: "put an < in the sentence" > 2) encode(&): "put an &lt; in the sentence" > 3) unencode(&): "put an < in the sentence" > unencode(<): put an < in the sentence That would be the behavior I would expect if (assuming the SAX/W3CDOM parser is used) encode == __escapeString and unencode == __unescapeString I'm missing something I'm sure. Can you give a code example that'll help me? > Also, code needs to be added to handle &#hex; and &numeric; > syntax. There are a host of other entities to be recognized, but they may > be HTML specific (like '). > That would totally rock. I thought ' was actually XML specific though and not an actual HTML entity. Moz and Konq support it in HTML, but IE doesn't IIRC. I remember this due to a vague memory of once saying "wow, something that IE is more compliant to the spec in than Mozilla. Wow! A flying pig!" :) > If someone is working on this or has some could that was started please let > me know, otherwise I will try to write it and submit it to the project. > Thanks. Again, this would totally rock. No one is working on this that I know of and I agree the escaping is due for a redesign. If you would like to do this, I would really appreciate it and I will happily include it in version 3.2 (or 3.1 if you're really quick). I would suggest the following: * Unless you *really* want to go back and test with old browsers, I would leave the classic DOM code as it is now. * Put your new code in xmlEscape.js and just point all of the DOM and SAX escape functions to this code. This will require that people include xmlEscape.js when using the W3C Parser and the SAX parser, but I'm OK with this since your code will provide significant functionality - even outside of XML for <SCRIPT> * If you would like to turn the existing functions in xmlEscape.js into single pass (presumably using regular expressions) that would be nice as well. If you do, I'll probably take the existing file and call it xmlEscape4xBrowsers.js just so folks who have to support older browsers can keep using the two functions is already provides without worrying about incompatibilities. * A test suite and some documentation about what entities we will officially support would be very nice! Thanks again! David __________________________________ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com |
From: <Rob...@Hy...> - 2004-03-10 23:07:43
|
A few items: - More immediate is that all of the unescape code (there are several in the SAX and DOM files) should move the ampersand replacement after <, >, " and ' to avoid: 1) original: "put an < in the sentence" 2) encode(&): "put an &lt; in the sentence" 3) unencode(&): "put an < in the sentence" unencode(<): put an < in the sentence - Moving forward the escape/unescape code should be reworked so that it is converted in a single pass, as multiple passes can cause invalid conversion. Also, code needs to be added to handle &#hex; and &numeric; syntax. There are a host of other entities to be recognized, but they may be HTML specific (like '). If someone is working on this or has some could that was started please let me know, otherwise I will try to write it and submit it to the project. Thanks. ************************************************************************ If you have received this e-mail in error, please delete it and notify the sender as soon as possible. The contents of this e-mail may be confidential and the unauthorized use, copying, or dissemination of it and any attachments to it, is prohibited. Internet communications are not secure and Hyperion does not, therefore, accept legal responsibility for the contents of this message nor for any damage caused by viruses. The views expressed here do not necessarily represent those of Hyperion. For more information about Hyperion, please visit our Web site at www.hyperion.com |
From: David J. <dj...@ya...> - 2004-03-10 07:11:38
|
Hello all, XML for <SCRIPT> 3.1 should be released by the end of March. The primary changes from 3.0 are a few fixes to the W3C DOM Parser relating to empty nodes and importNode problems and the addition of an XPath contributed add on. The XPath contributed add on allows for a subset of XPath expressions to be executed against W3C DOM objects. If anyone is interested in giving 3.1 a spin before it's released, I'd be happy to provide a pre-release copy. I'd be especially interested in folks who want to try out the XPath functionality to let me know how well it works in the "real world". If you are interested, please drop me a private email at djoham(at)yahoo[dot]com. Best regards, David __________________________________ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com |
From: David J. <dj...@ya...> - 2004-03-08 21:26:11
|
--- Rob...@Hy... wrote: > Since most of use tab stops in our editors, changing the spaces to tabs > would increase the indenting (and legibility), as well as reduce the size > of the non-compressed files. The files varied by author, some tabs were > floating around, some indented 2 spaces per level, some 4. > Hi Robert! I'm getting ready to put version 3.1 together (which by the way will fix the first bug you reported - I need to think about the possible ramifications of the second) and if you would like to do this, I would be happy to hold the release for a bit until you're finished. My only requirement would be that the files be in UNIX line-termination format. I don't think they all are now (Jon uses Windows) but I would prefer that we pick and stick to a standard. What do you think? David __________________________________ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com |
From: <Rob...@Hy...> - 2004-03-08 18:47:22
|
Since most of use tab stops in our editors, changing the spaces to tabs would increase the indenting (and legibility), as well as reduce the size of the non-compressed files. The files varied by author, some tabs were floating around, some indented 2 spaces per level, some 4. ************************************************************************ If you have received this e-mail in error, please delete it and notify the sender as soon as possible. The contents of this e-mail may be confidential and the unauthorized use, copying, or dissemination of it and any attachments to it, is prohibited. Internet communications are not secure and Hyperion does not, therefore, accept legal responsibility for the contents of this message nor for any damage caused by viruses. The views expressed here do not necessarily represent those of Hyperion. For more information about Hyperion, please visit our Web site at www.hyperion.com |
From: <Rob...@Hy...> - 2004-03-08 18:40:35
|
1) EMPTY ELEMENTS NOT ADDED - In DOMImplementation::_parseLoop, in the "else if(iEvt == XMLP._ELM_EMP)" block, the call to "iNodeParent.appendChild(iNode);" is only done in the "if (!this.namespaceAware)" block. If pushed this single line after the entire if-then-else. 2) EMPTY ELEMENT SERIALIZATION INVALID - the last few lines of DOMElement.toString should be like this: ret += "<" + this.nodeName + ns + attrs; if (this.childNodes.length > 0) { ret += ">"; ret += this.childNodes.toString(); ret += "</" + this.nodeName + ">"; } else { ret += " />"; } ************************************************************************ If you have received this e-mail in error, please delete it and notify the sender as soon as possible. The contents of this e-mail may be confidential and the unauthorized use, copying, or dissemination of it and any attachments to it, is prohibited. Internet communications are not secure and Hyperion does not, therefore, accept legal responsibility for the contents of this message nor for any damage caused by viruses. The views expressed here do not necessarily represent those of Hyperion. For more information about Hyperion, please visit our Web site at www.hyperion.com |
From: David J. <dj...@ya...> - 2004-03-05 04:19:39
|
Thanks! This will be fixed in the forthcoming 3.1 (AKA XPath) release. David --- Stepan Riha <xm...@no...> wrote: > DOMDocument.importNode() and DOMNode.cloneNode() do not work for nodes whose > attributes contain spaces or other "unexpected" characters. I.e. they'll fail > importing or cloning the following node: > > <NODE foo="hello world"> > </NODE> > > The problem seems to be in DOMElement.prototype.setAttributeNS(). The line that > says: > > if (!this.ownerDocument.implementation._isValidName(value)) { > > should actually say: > > if (!this.ownerDocument.implementation._isValidString(value)) { > > - Stepan > > -- > Stepan Riha > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users __________________________________ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com |
From: Stepan R. <xm...@no...> - 2004-03-05 00:46:51
|
DOMDocument.importNode() and DOMNode.cloneNode() do not work for nodes whose attributes contain spaces or other "unexpected" characters. I.e. they'll fail importing or cloning the following node: <NODE foo="hello world"> </NODE> The problem seems to be in DOMElement.prototype.setAttributeNS(). The line that says: if (!this.ownerDocument.implementation._isValidName(value)) { should actually say: if (!this.ownerDocument.implementation._isValidString(value)) { - Stepan -- Stepan Riha |
From: David J. <dj...@ya...> - 2004-03-03 16:34:40
|
Hello! There are a couple of different ways to do this in XML for <SCRIPT>. If you are only loading XML data from your own domain, the easist way to do this is to use the xmlIOLoadLocalData method in xmlIO.js. If you would like to load data from another domain (something I don't think MSXML lets you do), you can also use one of the server-side proxies. You can find documentation on this feature at the following address: http://xmljs.sourceforge.net/website/documentation-tools.html#toolsIOLoadLocalData You can find sample code that demonstrates this in action at the following address: http://xmljs.sourceforge.net/website/tools-loadLocalXML.html Hope this helps! David --- "Nermin B." <us...@gm...> wrote: > I would like to load an XML file from web server and parse its values while > using xml for script. All examples I was able to found are limited to parsing > XML that is within html on the page locally. > > Currently I am using Microsoft.XMLDOM for loading an separate XML file > into page: > > > xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); > xmlDoc.async = false; > while(xmlDoc.readyState != 4) {}; > xmlDoc.load(mydata.xml); > > var rootNode = xmlDoc.documentElement; > > (And than reading elements) > > mydata.xml is an separate file stored locally. > > How will this code look with XML for script?? > > Thank you in advance: > > N.B. > > -- > +++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz +++ > 100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users __________________________________ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com |
From: Nermin B. <us...@gm...> - 2004-03-03 06:20:38
|
I would like to load an XML file from web server and parse its values while using xml for script. All examples I was able to found are limited to parsing XML that is within html on the page locally. Currently I am using Microsoft.XMLDOM for loading an separate XML file into page: xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; while(xmlDoc.readyState != 4) {}; xmlDoc.load(mydata.xml); var rootNode = xmlDoc.documentElement; (And than reading elements) mydata.xml is an separate file stored locally. How will this code look with XML for script?? Thank you in advance: N.B. -- +++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz +++ 100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz |
From: David J. <dj...@ya...> - 2004-02-27 16:54:12
|
Hi Chandan, 1200 nodes is pretty much the upper limit XML for <SCRIPT> can handle. At that point the JavaScript interperator starts getting bogged down with all the objects it needs to create. A lot of it depends on the speed of the computer as well (naturally). If XML for <SCRIPT> is too slow, you might try sarissa at http://sarissa.sourceforge.net/. I've never tried it myself, but it uses the native DOM implementation of IE and Mozilla so the speed should be much faster. The price you'll pay is that you'll probably lose Safari, Konq and Opera support. You also need to be aware that Sarissa is GPL (rather than LGPL) so if you want to use it you need to be prepared to accept the more viral terms of its license. One option would be to use Sarissa for IE and Mozilla and XML for <SCRIPT> for the other browsers. The other browers would be slower, but at least functional after the initial load. If you do try it and it works, please let me know and I'll add it to the FAQ. Best regards, David --- Chandan Kumar <cha...@bl...> wrote: > Hi David, > I am using your wc3dom xml parser for parsing a xml string of around 1200 > nodes....problem is it takes over 30 secs to load in internet explorer. > > Is there any upper limit on the number of nodes it can parse fast enough? Do > you know any parser which can handle this amount of data fast enought. > > Your help in this regard will be greatly appreciated. > > Thanks, > Chandan > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users __________________________________ Do you Yahoo!? Get better spam protection with Yahoo! Mail. http://antispam.yahoo.com/tools |
From: Chandan K. <cha...@bl...> - 2004-02-27 05:50:59
|
Hi David, I am using your wc3dom xml parser for parsing a xml string of around 1200 nodes....problem is it takes over 30 secs to load in internet explorer. Is there any upper limit on the number of nodes it can parse fast enough? Do you know any parser which can handle this amount of data fast enought. Your help in this regard will be greatly appreciated. Thanks, Chandan |
From: James S. E. <jam...@co...> - 2004-02-24 17:21:01
|
The way I avoid that kind of problem is to write empty nodes as if they weren't empty: <ZIPCODE id="12345"></ZIPCODE> Just out of curiosity, why don't you use the ZIP code itself as the content instead of as an attribute value? <ZIPCODE>12345</ZIPCODE> -----Original Message----- From: xml...@li... [mailto:xml...@li...]On Behalf Of xml...@li... Sent: Tuesday, February 24, 2004 11:09 AM To: xml...@li... Subject: xmljs-users digest, Vol 1 #12 - 2 msgs Send xmljs-users mailing list submissions to xml...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/xmljs-users or, via email, send a message with subject or body 'help' to xml...@li... You can reach the person managing the list at xml...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of xmljs-users digest..." Today's Topics: 1. Empty Nodes (Thomas Schletter) 2. Re: Empty Nodes (David Joham) --__--__-- Message: 1 From: Thomas Schletter <tho...@gm...> Reply-To: tho...@fr... To: xml...@li... Date: Tue, 24 Feb 2004 11:14:10 +0100 Subject: [xmljs-users] Empty Nodes Hi I tried to parse nodes whitout text-content with the w3cdom-parser, until here there is no problem. When I try to get these empty nodes (to get the attributes) i can't access them, these nodes are not in the dom-tree. example xml taken from the sample-section and modified: <?xml version="1.0"?> <CONTACTS> <CONTACT id="4" > <FIRSTNAME> Kelly </FIRSTNAME> <LASTNAME> VanMcIntyre </LASTNAME> <ADDRESS> 92535 Highway 6 </ADDRESS> <CITY> Somewhere </CITY> <STATE> AZ </STATE> <ZIPCODE id="12345" /> </CONTACT> </CONTACTS> The Node "ZIPCODE" is not present in the dom-tree. Is there a way to get these Nodes? MfG Thomas Schletter -- Mail: tho...@gm... Tel: 0049 371/656 10654 --__--__-- Message: 2 Date: Tue, 24 Feb 2004 09:05:09 -0800 (PST) From: David Joham <dj...@ya...> Subject: Re: [xmljs-users] Empty Nodes To: tho...@fr..., xml...@li... --0-47996811-1077642309=:16634 Content-Type: text/plain; charset=us-ascii Content-Id: Content-Disposition: inline Hi Thomas, I think you're running into a known issue with the 3.0 parser. I have attached a new version of xmlw3cdom that should fix the problem for you. It's part of the 3.1 release which should come out sometime in late March or Early April. Please let me know if this doesn't fix the problem for you... David --- Thomas Schletter <tho...@gm...> wrote: > Hi > > I tried to parse nodes whitout text-content with the w3cdom-parser, until here > there is no problem. When I try to get these empty nodes (to get the > attributes) i can't access them, these nodes are not in the dom-tree. > > example xml taken from the sample-section and modified: > > <?xml version="1.0"?> > <CONTACTS> > <CONTACT id="4" > > <FIRSTNAME> > Kelly > </FIRSTNAME> > <LASTNAME> > VanMcIntyre > </LASTNAME> > <ADDRESS> > 92535 Highway 6 > </ADDRESS> > <CITY> > Somewhere > </CITY> > <STATE> > AZ > </STATE> > <ZIPCODE id="12345" /> > </CONTACT> > </CONTACTS> > > The Node "ZIPCODE" is not present in the dom-tree. Is there a way to get these > Nodes? > > > MfG Thomas Schletter > > -- > Mail: tho...@gm... > Tel: 0049 371/656 10654 > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools --0-47996811-1077642309=:16634 Content-Type: text/plain; name="xmlw3cdom.js" Content-Description: xmlw3cdom.js Content-Disposition: inline; filename="xmlw3cdom.js" // ========================================================================= // // xmlw3cdom.js - a W3C compliant DOM parser for XML for <SCRIPT> // // version 3.1 // // ========================================================================= // // Copyright (C) 2002, 2003 Jon van Noort (jo...@we...), David Joham (dj...@ya...) and Scott Severtson // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // This library 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 // Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // visit the XML for <SCRIPT> home page at xmljs.sourceforge.net // // Contains text (used within comments to methods) from the // XML Path Language (XPath) Version 1.0 W3C Recommendation // Copyright © 16 November 1999 World Wide Web Consortium, // (Massachusetts Institute of Technology, // European Research Consortium for Informatics and Mathematics, Keio University). // All Rights Reserved. // (see: http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/) /** * @function addClass - add new className to classCollection * * @author Jon van Noort (jo...@we...) * * @param classCollectionStr : string - list of existing class names * (separated and top and tailed with '|'s) * @param newClass : string - new class name to add * * @return : string - the new classCollection, with new className appended, * (separated and top and tailed with '|'s) */ function addClass(classCollectionStr, newClass) { if (classCollectionStr) { if (classCollectionStr.indexOf("|"+ newClass +"|") < 0) { classCollectionStr += newClass + "|"; } } else { classCollectionStr = "|"+ newClass + "|"; } return classCollectionStr; } /** * @class DOMException - raised when an operation is impossible to perform * * @author Jon van Noort (jo...@we...) * * @param code : int - the exception code (one of the DOMException constants) */ DOMException = function(code) { this._class = addClass(this._class, "DOMException"); this.code = code; }; // DOMException constants // Introduced in DOM Level 1: DOMException.INDEX_SIZE_ERR = 1; DOMException.DOMSTRING_SIZE_ERR = 2; DOMException.HIERARCHY_REQUEST_ERR = 3; DOMException.WRONG_DOCUMENT_ERR = 4; DOMException.INVALID_CHARACTER_ERR = 5; DOMException.NO_DATA_ALLOWED_ERR = 6; DOMException.NO_MODIFICATION_ALLOWED_ERR = 7; DOMException.NOT_FOUND_ERR = 8; DOMException.NOT_SUPPORTED_ERR = 9; DOMException.INUSE_ATTRIBUTE_ERR = 10; // Introduced in DOM Level 2: DOMException.INVALID_STATE_ERR = 11; DOMException.SYNTAX_ERR = 12; DOMException.INVALID_MODIFICATION_ERR = 13; DOMException.NAMESPACE_ERR = 14; DOMException.INVALID_ACCESS_ERR = 15; /** * @class DOMImplementation - provides a number of methods for performing operations * that are independent of any particular instance of the document object model. * * @author Jon van Noort (jo...@we...) */ DOMImplementation = function() { this._class = addClass(this._class, "DOMImplementation"); this._p = null; this.preserveWhiteSpace = false; // by default, ignore whitespace this.namespaceAware = true; // by default, handle namespaces this.errorChecking = true; // by default, test for exceptions }; /** * @method DOMImplementation.hasFeature - Test if the DOM implementation implements a specific feature * * @author Jon van Noort (jo...@we...) * * @param feature : string - The package name of the feature to test. the legal only values are "XML" and "CORE" (case-insensitive). * @param version : string - This is the version number of the package name to test. In Level 1, this is the string "1.0". * * @return : boolean */ DOMImplementation.prototype.hasFeature = function DOMImplementation_hasFeature(feature, version) { var ret = false; if (feature.toLowerCase() == "xml") { ret = (!version || (version == "1.0") || (version == "2.0")); } else if (feature.toLowerCase() == "core") { ret = (!version || (version == "2.0")); } return ret; }; /** * @method DOMImplementation.loadXML - parse XML string * * @author Jon van Noort (jo...@we...), David Joham (dj...@ya...) and Scott Severtson * * @param xmlStr : string - the XML string * * @return : DOMDocument */ DOMImplementation.prototype.loadXML = function DOMImplementation_loadXML(xmlStr) { // create SAX Parser var parser; try { parser = new XMLP(xmlStr); } catch (e) { alert("Error Creating the SAX Parser. Did you include xmlsax.js or tinyxmlsax.js in your web page?\nThe SAX parser is needed to populate XML for <SCRIPT>'s W3C DOM Parser with data."); } // create DOM Document var doc = new DOMDocument(this); // populate Document with Parsed Nodes this._parseLoop(doc, parser); // set parseComplete flag, (Some validation Rules are relaxed if this is false) doc._parseComplete = true; return doc; }; /** * @method DOMImplementation.translateErrCode - convert DOMException Code * to human readable error message; * * @author Jon van Noort (jo...@we...) * * @param code : int - the DOMException code * * @return : string - the human readbale error message */ DOMImplementation.prototype.translateErrCode = function DOMImplementation_translateErrCode(code) { var msg = ""; switch (code) { case DOMException.INDEX_SIZE_ERR : // 1 msg = "INDEX_SIZE_ERR: Index out of bounds"; break; case DOMException.DOMSTRING_SIZE_ERR : // 2 msg = "DOMSTRING_SIZE_ERR: The resulting string is too long to fit in a DOMString"; break; case DOMException.HIERARCHY_REQUEST_ERR : // 3 msg = "HIERARCHY_REQUEST_ERR: The Node can not be inserted at this location"; break; case DOMException.WRONG_DOCUMENT_ERR : // 4 msg = "WRONG_DOCUMENT_ERR: The source and the destination Documents are not the same"; break; case DOMException.INVALID_CHARACTER_ERR : // 5 msg = "INVALID_CHARACTER_ERR: The string contains an invalid character"; break; case DOMException.NO_DATA_ALLOWED_ERR : // 6 msg = "NO_DATA_ALLOWED_ERR: This Node / NodeList does not support data"; break; case DOMException.NO_MODIFICATION_ALLOWED_ERR : // 7 msg = "NO_MODIFICATION_ALLOWED_ERR: This object cannot be modified"; break; case DOMException.NOT_FOUND_ERR : // 8 msg = "NOT_FOUND_ERR: The item cannot be found"; break; case DOMException.NOT_SUPPORTED_ERR : // 9 msg = "NOT_SUPPORTED_ERR: This implementation does not support function"; break; case DOMException.INUSE_ATTRIBUTE_ERR : // 10 msg = "INUSE_ATTRIBUTE_ERR: The Attribute has already been assigned to another Element"; break; // Introduced in DOM Level 2: case DOMException.INVALID_STATE_ERR : // 11 msg = "INVALID_STATE_ERR: The object is no longer usable"; break; case DOMException.SYNTAX_ERR : // 12 msg = "SYNTAX_ERR: Syntax error"; break; case DOMException.INVALID_MODIFICATION_ERR : // 13 msg = "INVALID_MODIFICATION_ERR: Cannot change the type of the object"; break; case DOMException.NAMESPACE_ERR : // 14 msg = "NAMESPACE_ERR: The namespace declaration is incorrect"; break; case DOMException.INVALID_ACCESS_ERR : // 15 msg = "INVALID_ACCESS_ERR: The object does not support this function"; break; default : msg = "UNKNOWN: Unknown Exception Code ("+ code +")"; } return msg; } /** * @method DOMImplementation._parseLoop - process SAX events * * @author Jon van Noort (jo...@we...), David Joham (dj...@ya...) and Scott Severtson * * @param doc : DOMDocument - the Document to contain the parsed XML string * @param p : XMLP - the SAX Parser * * @return : DOMDocument */ DOMImplementation.prototype._parseLoop = function DOMImplementation__parseLoop(doc, p) { var iEvt, iNode, iAttr, strName; iNodeParent = doc; var el_close_count = 0; var entitiesList = new Array(); // if namespaceAware, add default namespace if (this.namespaceAware) { var iNS = doc.createNamespace(""); // add the default-default namespace iNS.setValue("http://www.w3.org/2000/xmlns/"); doc._namespaces.setNamedItem(iNS); } // loop until SAX parser stops emitting events while(true) { // get next event iEvt = p.next(); if (iEvt == XMLP._ELM_B || iEvt == XMLP._ELM_EMP) { // Begin-Element Event var pName = p.getName(); // get the Element name pName = trim(pName, true, true); // strip spaces from Element name if (!this.namespaceAware) { iNode = doc.createElement(p.getName()); // create the Element // add attributes to Element for(var i = 0; i < p.getAttributeCount(); i++) { strName = p.getAttributeName(i); // get Attribute name iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it if(!iAttr) { iAttr = doc.createAttribute(strName); // otherwise create it } iAttr.setValue(p.getAttributeValue(i)); // set Attribute value iNode.setAttributeNode(iAttr); // attach Attribute to Element } } else { // Namespace Aware // create element (with empty namespaceURI, // resolve after namespace 'attributes' have been parsed) iNode = doc.createElementNS("", p.getName()); // duplicate ParentNode's Namespace definitions iNode._namespaces = iNodeParent._namespaces._cloneNodes(iNode); // add attributes to Element for(var i = 0; i < p.getAttributeCount(); i++) { strName = p.getAttributeName(i); // get Attribute name // if attribute is a namespace declaration if (this._isNamespaceDeclaration(strName)) { // parse Namespace Declaration var namespaceDec = this._parseNSName(strName); if (strName != "xmlns") { iNS = doc.createNamespace(strName); // define namespace } else { iNS = doc.createNamespace(""); // redefine default namespace } iNS.setValue(p.getAttributeValue(i)); // set value = namespaceURI iNode._namespaces.setNamedItem(iNS); // attach namespace to namespace collection } else { // otherwise, it is a normal attribute iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it if(!iAttr) { iAttr = doc.createAttributeNS("", strName); // otherwise create it } iAttr.setValue(p.getAttributeValue(i)); // set Attribute value iNode.setAttributeNodeNS(iAttr); // attach Attribute to Element if (this._isIdDeclaration(strName)) { iNode.id = p.getAttributeValue(i); // cache ID for getElementById() } } } // resolve namespaceURIs for this Element if (iNode._namespaces.getNamedItem(iNode.prefix)) { iNode.namespaceURI = iNode._namespaces.getNamedItem(iNode.prefix).value; } // for this Element's attributes for (var i = 0; i < iNode.attributes.length; i++) { if (iNode.attributes.item(i).prefix != "") { // attributes do not have a default namespace if (iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix)) { iNode.attributes.item(i).namespaceURI = iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix).value; } } } } // if this is the Root Element if (iNodeParent.nodeType == DOMNode.DOCUMENT_NODE) { iNodeParent.documentElement = iNode; // register this Element as the Document.documentElement } iNodeParent.appendChild(iNode); // attach Element to parentNode if (iEvt == XMLP._ELM_B) { iNodeParent = iNode; // descend one level of the DOM Tree } } else if(iEvt == XMLP._ELM_E) { // End-Element Event iNodeParent = iNodeParent.parentNode; // ascend one level of the DOM Tree } else if(iEvt == XMLP._TEXT || iEvt == XMLP._ENTITY) { // TextNode and entity Events // get Text content var pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd()); if (!this.preserveWhiteSpace) { pContent = trim(pContent, true, true); // strip whitespace pContent.replace(/ +/g, ' '); // collapse multiple spaces to 1 space } if (pContent.length > 0) { // ignore empty TextNodes var textNode = doc.createTextNode(pContent); iNodeParent.appendChild(textNode); // attach TextNode to parentNode //the sax parser breaks up text nodes when it finds an entity. For //example hello<there will fire a text, an entity and another text //this sucks for the dom parser because it looks to us in this logic //as three text nodes. I fix this by keeping track of the entity nodes //and when we're done parsing, calling normalize on their parent to //turn the multiple text nodes into one, which is what DOM users expect //the code to do this is at the bottom of this function if (iEvt == XMLP._ENTITY) { entitiesList[entitiesList.length] = textNode; } } } else if(iEvt == XMLP._PI) { // ProcessingInstruction Event // attach ProcessingInstruction to parentNode iNodeParent.appendChild(doc.createProcessingInstruction(p.getName(), p.getContent().substring(p.getContentBegin(), p.getContentEnd()))); } else if(iEvt == XMLP._CDATA) { // CDATA Event // get CDATA data pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd()); if (!this.preserveWhiteSpace) { pContent = trim(pContent, true, true); // trim whitespace pContent.replace(/ +/g, ' '); // collapse multiple spaces to 1 space } if (pContent.length > 0) { // ignore empty CDATANodes iNodeParent.appendChild(doc.createCDATASection(pContent)); // attach CDATA to parentNode } } else if(iEvt == XMLP._COMMENT) { // Comment Event // get COMMENT data var pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd()); if (!this.preserveWhiteSpace) { pContent = trim(pContent, true, true); // trim whitespace pContent.replace(/ +/g, ' '); // collapse multiple spaces to 1 space } if (pContent.length > 0) { // ignore empty CommentNodes iNodeParent.appendChild(doc.createComment(pContent)); // attach Comment to parentNode } } else if(iEvt == XMLP._DTD) { // ignore DTD events } else if(iEvt == XMLP._ERROR) { throw(new DOMException(DOMException.SYNTAX_ERR)); // alert("Fatal Error: " + p.getContent() + "\nLine: " + p.getLineNumber() + "\nColumn: " + p.getColumnNumber() + "\n"); // break; } else if(iEvt == XMLP._NONE) { // no more events if (iNodeParent == doc) { // confirm that we have recursed back up to root break; } else { throw(new DOMException(DOMException.SYNTAX_ERR)); // one or more Tags were not closed properly } } } //normalize any entities in the DOM to a single textNode var intCount = entitiesList.length; for (intLoop = 0; intLoop < intCount; intLoop++) { var entity = entitiesList[intLoop]; //its possible (if for example two entities were in the //same domnode, that the normalize on the first entitiy //will remove the parent for the second. Only do normalize //if I can find a parent node var parentNode = entity.getParentNode(); if (parentNode) { parentNode.normalize(); } } }; /** * @method DOMImplementation._isNamespaceDeclaration - Return true, if attributeName is a namespace declaration * * @author Jon van Noort (jo...@we...) * * @param attributeName : string - the attribute name * * @return : boolean */ DOMImplementation.prototype._isNamespaceDeclaration = function DOMImplementation__isNamespaceDeclaration(attributeName) { // test if attributeName is 'xmlns' return (attributeName.indexOf('xmlns') > -1); } /** * @method DOMImplementation._isIdDeclaration - Return true, if attributeName is an id declaration * * @author Jon van Noort (jo...@we...) * * @param attributeName : string - the attribute name * * @return : boolean */ DOMImplementation.prototype._isIdDeclaration = function DOMImplementation__isIdDeclaration(attributeName) { // test if attributeName is 'id' (case insensitive) return (attributeName.toLowerCase() == 'id'); } /** * @method DOMImplementation._isValidName - Return true, * if name contains no invalid characters * * @author Jon van Noort (jo...@we...) * * @param name : string - the candidate name * * @return : boolean */ DOMImplementation.prototype._isValidName = function DOMImplementation__isValidName(name) { // test if name contains only valid characters return name.match(re_validName); } re_validName = /^[a-zA-Z_:][a-zA-Z0-9\.\-_:]*$/; /** * @method DOMImplementation._isValidString - Return true, if string does not contain any illegal chars * All of the characters 0 through 31 and character 127 are nonprinting control characters. * With the exception of characters 09, 10, and 13, (Ox09, Ox0A, and Ox0D) * Note: different from _isValidName in that ValidStrings may contain spaces * * @author Jon van Noort (jo...@we...) * * @param name : string - the candidate string * * @return : boolean */ DOMImplementation.prototype._isValidString = function DOMImplementation__isValidString(name) { // test that string does not contains invalid characters return (name.search(re_invalidStringChars) < 0); } re_invalidStringChars = /\x01|\x02|\x03|\x04|\x05|\x06|\x07|\x08|\x0B|\x0C|\x0E|\x0F|\x10|\x11|\x12| \x13|\x14|\x15|\x16|\x17|\x18|\x19|\x1A|\x1B|\x1C|\x1D|\x1E|\x1F|\x7F/ /** * @method DOMImplementation._parseNSName - parse the namespace name. * if there is no colon, the * * @author Jon van Noort (jo...@we...) * * @param qualifiedName : string - The qualified name * * @return : NSName - [ * .prefix : string - The prefix part of the qname * .namespaceName : string - The namespaceURI part of the qname * ] */ DOMImplementation.prototype._parseNSName = function DOMImplementation__parseNSName(qualifiedName) { var resultNSName = new Object(); resultNSName.prefix = qualifiedName; // unless the qname has a namespaceName, the prefix is the entire String resultNSName.namespaceName = ""; // split on ':' delimPos = qualifiedName.indexOf(':'); if (delimPos > -1) { // get prefix resultNSName.prefix = qualifiedName.substring(0, delimPos); // get namespaceName resultNSName.namespaceName = qualifiedName.substring(delimPos +1, qualifiedName.length); } return resultNSName; } /** * @method DOMImplementation._parseQName - parse the qualified name * * @author Jon van Noort (jo...@we...) * * @param qualifiedName : string - The qualified name * * @return : QName */ DOMImplementation.prototype._parseQName = function DOMImplementation__parseQName(qualifiedName) { var resultQName = new Object(); resultQName.localName = qualifiedName; // unless the qname has a prefix, the local name is the entire String resultQName.prefix = ""; // split on ':' delimPos = qualifiedName.indexOf(':'); if (delimPos > -1) { // get prefix resultQName.prefix = qualifiedName.substring(0, delimPos); // get localName resultQName.localName = qualifiedName.substring(delimPos +1, qualifiedName.length); } return resultQName; } /** * @class DOMNodeList - provides the abstraction of an ordered collection of nodes * * @author Jon van Noort (jo...@we...) * * @param ownerDocument : DOMDocument - the ownerDocument * @param parentNode : DOMNode - the node that the DOMNodeList is attached to (or null) */ DOMNodeList = function(ownerDocument, parentNode) { this._class = addClass(this._class, "DOMNodeList"); this._nodes = new Array(); this.length = 0; this.parentNode = parentNode; this.ownerDocument = ownerDocument; this._readonly = false; }; /** * @method DOMNodeList.getLength - Java style gettor for .length * * @author Jon van Noort (jo...@we...) * * @return : int */ DOMNodeList.prototype.getLength = function DOMNodeList_getLength() { return this.length; }; /** * @method DOMNodeList.item - Returns the indexth item in the collection. * If index is greater than or equal to the number of nodes in the list, this returns null. * * @author Jon van Noort (jo...@we...) * * @param index : int - Index into the collection. * * @return : DOMNode - The node at the indexth position in the NodeList, or null if that is not a valid index */ DOMNodeList.prototype.item = function DOMNodeList_item(index) { var ret = null; if ((index >= 0) && (index < this._nodes.length)) { // bounds check ret = this._nodes[index]; // return selected Node } return ret; // if the index is out of bounds, default value null is returned }; /** * @method DOMNodeList._findItemIndex - find the item index of the node with the specified internal id * * @author Jon van Noort (jo...@we...) * * @param id : int - unique internal id * * @return : int */ DOMNodeList.prototype._findItemIndex = function DOMNodeList__findItemIndex(id) { var ret = -1; // test that id is valid if (id > -1) { for (var i=0; i<this._nodes.length; i++) { // compare id to each node's _id if (this._nodes[i]._id == id) { // found it! ret = i; break; } } } return ret; // if node is not found, default value -1 is returned }; /** * @method DOMNodeList._insertBefore - insert the specified Node into the NodeList before the specified index * Used by DOMNode.insertBefore(). Note: DOMNode.insertBefore() is responsible for Node Pointer surgery * DOMNodeList._insertBefore() simply modifies the internal data structure (Array). * * @author Jon van Noort (jo...@we...) * * @param newChild : DOMNode - the Node to be inserted * @param refChildIndex : int - the array index to insert the Node before */ DOMNodeList.prototype._insertBefore = function DOMNodeList__insertBefore(newChild, refChildIndex) { if ((refChildIndex >= 0) && (refChildIndex < this._nodes.length)) { // bounds check // get array containing children prior to refChild var tmpArr = new Array(); tmpArr = this._nodes.slice(0, refChildIndex); if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { // node is a DocumentFragment // append the children of DocumentFragment tmpArr = tmpArr.concat(newChild.childNodes._nodes); } else { // append the newChild tmpArr[tmpArr.length] = newChild; } // append the remaining original children (including refChild) this._nodes = tmpArr.concat(this._nodes.slice(refChildIndex)); this.length = this._nodes.length; // update length } }; /** * @method DOMNodeList._replaceChild - replace the specified Node in the NodeList at the specified index * Used by DOMNode.replaceChild(). Note: DOMNode.replaceChild() is responsible for Node Pointer surgery * DOMNodeList._replaceChild() simply modifies the internal data structure (Array). * * @author Jon van Noort (jo...@we...) * * @param newChild : DOMNode - the Node to be inserted * @param refChildIndex : int - the array index to hold the Node */ DOMNodeList.prototype._replaceChild = function DOMNodeList__replaceChild(newChild, refChildIndex) { var ret = null; if ((refChildIndex >= 0) && (refChildIndex < this._nodes.length)) { // bounds check ret = this._nodes[refChildIndex]; // preserve old child for return if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { // node is a DocumentFragment // get array containing children prior to refChild var tmpArr = new Array(); tmpArr = this._nodes.slice(0, refChildIndex); // append the children of DocumentFragment tmpArr = tmpArr.concat(newChild.childNodes._nodes); // append the remaining original children (not including refChild) this._nodes = tmpArr.concat(this._nodes.slice(refChildIndex + 1)); } else { // simply replace node in array (links between Nodes are made at higher level) this._nodes[refChildIndex] = newChild; } } return ret; // return replaced node }; /** * @method DOMNodeList._removeChild - remove the specified Node in the NodeList at the specified index * Used by DOMNode.removeChild(). Note: DOMNode.removeChild() is responsible for Node Pointer surgery * DOMNodeList._replaceChild() simply modifies the internal data structure (Array). * * @author Jon van Noort (jo...@we...) * * @param refChildIndex : int - the array index holding the Node to be removed */ DOMNodeList.prototype._removeChild = function DOMNodeList__removeChild(refChildIndex) { var ret = null; if (refChildIndex > -1) { // found it! ret = this._nodes[refChildIndex]; // return removed node // rebuild array without removed child var tmpArr = new Array(); tmpArr = this._nodes.slice(0, refChildIndex); this._nodes = tmpArr.concat(this._nodes.slice(refChildIndex +1)); this.length = this._nodes.length; // update length } return ret; // return removed node }; /** * @method DOMNodeList._appendChild - append the specified Node to the NodeList * Used by DOMNode.appendChild(). Note: DOMNode.appendChild() is responsible for Node Pointer surgery * DOMNodeList._appendChild() simply modifies the internal data structure (Array). * * @author Jon van Noort (jo...@we...) * * @param newChild : DOMNode - the Node to be inserted */ DOMNodeList.prototype._appendChild = function DOMNodeList__appendChild(newChild) { if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { // node is a DocumentFragment // append the children of DocumentFragment this._nodes = this._nodes.concat(newChild.childNodes._nodes); } else { // simply add node to array (links between Nodes are made at higher level) this._nodes[this._nodes.length] = newChild; } this.length = this._nodes.length; // update length }; /** * @method DOMNodeList._cloneNodes - Returns a NodeList containing clones of the Nodes in this NodeList * * @author Jon van Noort (jo...@we...) * * @param deep : boolean - If true, recursively clone the subtree under each of the nodes; * if false, clone only the nodes themselves (and their attributes, if it is an Element). * @param parentNode : DOMNode - the new parent of the cloned NodeList * * @return : DOMNodeList - NodeList containing clones of the Nodes in this NodeList */ DOMNodeList.prototype._cloneNodes = function DOMNodeList__cloneNodes(deep, parentNode) { var cloneNodeList = new DOMNodeList(this.ownerDocument, parentNode); // create list containing clones of each child for (var i=0; i < this._nodes.length; i++) { cloneNodeList._appendChild(this._nodes[i].cloneNode(deep)); } return cloneNodeList; }; /** * @method DOMNodeList.toString - Serialize this NodeList into an XML string * * @author Jon van Noort (jo...@we...) and David Joham (dj...@ya...) * * @return : string */ DOMNodeList.prototype.toString = function DOMNodeList_toString() { var ret = ""; // create string containing the concatenation of the string values of each child for (var i=0; i < this.length; i++) { ret += this._nodes[i].toString(); } return ret; }; /** * @class DOMNamedNodeMap - used to represent collections of nodes that can be accessed by name * typically a set of Element attributes * * @extends DOMNodeList - note W3C spec says that this is not the case, * but we need an item() method identicle to DOMNodeList's, so why not? * * @author Jon van Noort (jo...@we...) * * @param ownerDocument : DOMDocument - the ownerDocument * @param parentNode : DOMNode - the node that the DOMNamedNodeMap is attached to (or null) */ DOMNamedNodeMap = function(ownerDocument, parentNode) { this._class = addClass(this._class, "DOMNamedNodeMap"); this.DOMNodeList = DOMNodeList; this.DOMNodeList(ownerDocument, parentNode); }; DOMNamedNodeMap.prototype = new DOMNodeList; /** * @method DOMNamedNodeMap.getNamedItem - Retrieves a node specified by name * * @author Jon van Noort (jo...@we...) * * @param name : string - Name of a node to retrieve * * @return : DOMNode */ DOMNamedNodeMap.prototype.getNamedItem = function DOMNamedNodeMap_getNamedItem(name) { var ret = null; // test that Named Node exists var itemIndex = this._findNamedItemIndex(name); if (itemIndex > -1) { // found it! ret = this._nodes[itemIndex]; // return NamedNode } return ret; // if node is not found, default value null is returned }; /** * @method DOMNamedNodeMap.setNamedItem - Adds a node using its nodeName attribute * * @author Jon van Noort (jo...@we...) * * @param arg : DOMNode - A node to store in a named node map. * The node will later be accessible using the value of the nodeName attribute of the node. * If a node with that name is already present in the map, it is replaced by the new one. * * @throws : DOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map. * @throws : DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this NamedNodeMap is readonly. * @throws : DOMException - INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object. * The DOM user must explicitly clone Attr nodes to re-use them in other elements. * * @return : DOMNode - If the new Node replaces an existing node with the same name the previously existing Node is returned, * otherwise null is returned */ DOMNamedNodeMap.prototype.setNamedItem = function DOMNamedNodeMap_setNamedItem(arg) { // test for exceptions if (this.ownerDocument.implementation.errorChecking) { // throw Exception if arg was not created by this Document if (this.ownerDocument != arg.ownerDocument) { throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); } // throw Exception if DOMNamedNodeMap is readonly if (this._readonly || (this.parentNode && this.parentNode._readonly)) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // throw Exception if arg is already an attribute of another Element object if (arg.ownerElement && (arg.ownerElement != this.parentNode)) { throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR)); } } // get item index var itemIndex = this._findNamedItemIndex(arg.name); var ret = null; if (itemIndex > -1) { // found it! ret = this._nodes[itemIndex]; // use existing Attribute // throw Exception if DOMAttr is readonly if (this.ownerDocument.implementation.errorChecking && ret._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } else { this._nodes[itemIndex] = arg; // over-write existing NamedNode } } else { this._nodes[this.length] = arg; // add new NamedNode } this.length = this._nodes.length; // update length arg.ownerElement = this.parentNode; // update ownerElement return ret; // return old node or null }; /** * @method DOMNamedNodeMap.removeNamedItem - Removes a node specified by name. * * @author Jon van Noort (jo...@we...) * * @param name : string - The name of a node to remove * * @throws : DOMException - NOT_FOUND_ERR: Raised if there is no node named name in this map. * @throws : DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this NamedNodeMap is readonly. * * @return : DOMNode - The node removed from the map or null if no node with such a name exists. */ DOMNamedNodeMap.prototype.removeNamedItem = function DOMNamedNodeMap_removeNamedItem(name) { var ret = null; // test for exceptions // throw Exception if DOMNamedNodeMap is readonly if (this.ownerDocument.implementation.errorChecking && (this._readonly || (this.parentNode && this.parentNode._readonly))) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // get item index var itemIndex = this._findNamedItemIndex(name); // throw Exception if there is no node named name in this map if (this.ownerDocument.implementation.errorChecking && (itemIndex < 0)) { throw(new DOMException(DOMException.NOT_FOUND_ERR)); } // get Node var oldNode = this._nodes[itemIndex]; // throw Exception if Node is readonly if (this.ownerDocument.implementation.errorChecking && oldNode._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // return removed node return this._removeChild(itemIndex); }; /** * @method DOMNamedNodeMap.getNamedItemNS - Retrieves a node specified by name * * @author Jon van Noort (jo...@we...) * * @param namespaceURI : string - the namespace URI of the required node * @param localName : string - the local name of the required node * * @return : DOMNode */ DOMNamedNodeMap.prototype.getNamedItemNS = function DOMNamedNodeMap_getNamedItemNS(namespaceURI, localName) { var ret = null; // test that Named Node exists var itemIndex = this._findNamedItemNSIndex(namespaceURI, localName); if (itemIndex > -1) { // found it! ret = this._nodes[itemIndex]; // return NamedNode } return ret; // if node is not found, default value null is returned }; /** * @method DOMNamedNodeMap.setNamedItemNS - Adds a node using * * @author Jon van Noort (jo...@we...) * * @param arg : string - A node to store in a named node map. * The node will later be accessible using the value of the nodeName attribute of the node. * If a node with that name is already present in the map, it is replaced by the new one. * * @throws : DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this NamedNodeMap is readonly. * @throws : DOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map. * @throws : DOMException - INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object. * The DOM user must explicitly clone Attr nodes to re-use them in other elements. * * @return : DOMNode - If the new Node replaces an existing node with the same name the previously existing Node is returned, * otherwise null is returned */ DOMNamedNodeMap.prototype.setNamedItemNS = function DOMNamedNodeMap_setNamedItemNS(arg) { // test for exceptions if (this.ownerDocument.implementation.errorChecking) { // throw Exception if DOMNamedNodeMap is readonly if (this._readonly || (this.parentNode && this.parentNode._readonly)) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // throw Exception if arg was not created by this Document if (this.ownerDocument != arg.ownerDocument) { throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); } // throw Exception if arg is already an attribute of another Element object if (arg.ownerElement && (arg.ownerElement != this.parentNode)) { throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR)); } } // get item index var itemIndex = this._findNamedItemNSIndex(arg.namespaceURI, arg.localName); var ret = null; if (itemIndex > -1) { // found it! ret = this._nodes[itemIndex]; // use existing Attribute // throw Exception if DOMAttr is readonly if (this.ownerDocument.implementation.errorChecking && ret._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } else { this._nodes[itemIndex] = arg; // over-write existing NamedNode } } else { this._nodes[this.length] = arg; // add new NamedNode } this.length = this._nodes.length; // update length arg.ownerElement = this.parentNode; return ret; // return old node or null }; /** * @method DOMNamedNodeMap.removeNamedItemNS - Removes a node specified by name. * * @author Jon van Noort (jo...@we...) * * @param namespaceURI : string - the namespace URI of the required node * @param localName : string - the local name of the required node * * @throws : DOMException - NOT_FOUND_ERR: Raised if there is no node with the specified namespaceURI and localName in this map. * @throws : DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this NamedNodeMap is readonly. * * @return : DOMNode - The node removed from the map or null if no node with such a name exists. */ DOMNamedNodeMap.prototype.removeNamedItemNS = function DOMNamedNodeMap_removeNamedItemNS(namespaceURI, localName) { var ret = null; // test for exceptions // throw Exception if DOMNamedNodeMap is readonly if (this.ownerDocument.implementation.errorChecking && (this._readonly || (this.parentNode && this.parentNode._readonly))) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // get item index var itemIndex = this._findNamedItemNSIndex(namespaceURI, localName); // throw Exception if there is no matching node in this map if (this.ownerDocument.implementation.errorChecking && (itemIndex < 0)) { throw(new DOMException(DOMException.NOT_FOUND_ERR)); } // get Node var oldNode = this._nodes[itemIndex]; // throw Exception if Node is readonly if (this.ownerDocument.implementation.errorChecking && oldNode._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } return this._removeChild(itemIndex); // return removed node }; /** * @method DOMNamedNodeMap._findNamedItemIndex - find the item index of the node with the specified name * * @author Jon van Noort (jo...@we...) * * @param name : string - the name of the required node * * @return : int */ DOMNamedNodeMap.prototype._findNamedItemIndex = function DOMNamedNodeMap__findNamedItemIndex(name) { var ret = -1; // loop through all nodes for (var i=0; i<this._nodes.length; i++) { // compare name to each node's nodeName if (this._nodes[i].name == name) { // found it! ret = i; break; } } return ret; // if node is not found, default value -1 is returned }; /** * @method DOMNamedNodeMap._findNamedItemNSIndex - find the item index of the node with the specified namespaceURI and localName * * @author Jon van Noort (jo...@we...) * * @param namespaceURI : string - the namespace URI of the required node * @param localName : string - the local name of the required node * * @return : int */ DOMNamedNodeMap.prototype._findNamedItemNSIndex = function DOMNamedNodeMap__findNamedItemNSIndex(namespaceURI, localName) { var ret = -1; // test that localName is not null if (localName) { // loop through all nodes for (var i=0; i<this._nodes.length; i++) { // compare name to each node's namespaceURI and localName if ((this._nodes[i].namespaceURI == namespaceURI) && (this._nodes[i].localName == localName)) { ret = i; // found it! break; } } } return ret; // if node is not found, default value -1 is returned }; /** * @method DOMNamedNodeMap._hasAttribute - Returns true if specified node exists * * @author Jon van Noort (jo...@we...) * * @param name : string - the name of the required node * * @return : boolean */ DOMNamedNodeMap.prototype._hasAttribute = function DOMNamedNodeMap__hasAttribute(name) { var ret = false; // test that Named Node exists var itemIndex = this._findNamedItemIndex(name); if (itemIndex > -1) { // found it! ret = true; // return true } return ret; // if node is not found, default value false is returned } /** * @method DOMNamedNodeMap._hasAttributeNS - Returns true if specified node exists * * @author Jon van Noort (jo...@we...) * * @param namespaceURI : string - the namespace URI of the required node * @param localName : string - the local name of the required node * * @return : boolean */ DOMNamedNodeMap.prototype._hasAttributeNS = function DOMNamedNodeMap__hasAttributeNS(namespaceURI, localName) { var ret = false; // test that Named Node exists var itemIndex = this._findNamedItemNSIndex(namespaceURI, localName); if (itemIndex > -1) { // found it! ret = true; // return true } return ret; // if node is not found, default value false is returned } /** * @method DOMNamedNodeMap._cloneNodes - Returns a NamedNodeMap containing clones of the Nodes in this NamedNodeMap * * @author Jon van Noort (jo...@we...) * * @param parentNode : DOMNode - the new parent of the cloned NodeList * * @return : DOMNamedNodeMap - NamedNodeMap containing clones of the Nodes in this DOMNamedNodeMap */ DOMNamedNodeMap.prototype._cloneNodes = function DOMNamedNodeMap__cloneNodes(parentNode) { var cloneNamedNodeMap = new DOMNamedNodeMap(this.ownerDocument, parentNode); // create list containing clones of all children for (var i=0; i < this._nodes.length; i++) { cloneNamedNodeMap._appendChild(this._nodes[i].cloneNode(false)); } return cloneNamedNodeMap; }; /** * @method DOMNamedNodeMap.toString - Serialize this NodeMap into an XML string * * @author Jon van Noort (jo...@we...) and David Joham (dj...@ya...) * * @return : string */ DOMNamedNodeMap.prototype.toString = function DOMNamedNodeMap_toString() { var ret = ""; // create string containing concatenation of all (but last) Attribute string values (separated by spaces) for (var i=0; i < this.length -1; i++) { ret += this._nodes[i].toString() +" "; } // add last Attribute to string (without trailing space) if (this.length > 0) { ret += this._nodes[this.length -1].toString(); } return ret; }; /** * @class DOMNamespaceNodeMap - used to represent collections of namespace nodes that can be accessed by name * typically a set of Element attributes * * @extends DOMNamedNodeMap * * @author Jon van Noort (jo...@we...) * * @param ownerDocument : DOMDocument - the ownerDocument * @param parentNode : DOMNode - the node that the DOMNamespaceNodeMap is attached to (or null) */ DOMNamespaceNodeMap = function(ownerDocument, parentNode) { this._class = addClass(this._class, "DOMNamespaceNodeMap"); this.DOMNamedNodeMap = DOMNamedNodeMap; this.DOMNamedNodeMap(ownerDocument, parentNode); }; DOMNamespaceNodeMap.prototype = new DOMNamedNodeMap; /** * @method DOMNamespaceNodeMap._findNamedItemIndex - find the item index of the node with the specified localName * * @author Jon van Noort (jo...@we...) * * @param localName : string - the localName of the required node * * @return : int */ DOMNamespaceNodeMap.prototype._findNamedItemIndex = function DOMNamespaceNodeMap__findNamedItemIndex(localName) { var ret = -1; // loop through all nodes for (var i=0; i<this._nodes.length; i++) { // compare name to each node's nodeName if (this._nodes[i].localName == localName) { // found it! ret = i; break; } } return ret; // if node is not found, default value -1 is returned }; /** * @method DOMNamespaceNodeMap._cloneNodes - Returns a NamespaceNodeMap containing clones of the Nodes in this NamespaceNodeMap * * @author Jon van Noort (jo...@we...) * * @param parentNode : DOMNode - the new parent of the cloned NodeList * * @return : DOMNamespaceNodeMap - NamespaceNodeMap containing clones of the Nodes in this NamespaceNodeMap */ DOMNamespaceNodeMap.prototype._cloneNodes = function DOMNamespaceNodeMap__cloneNodes(parentNode) { var cloneNamespaceNodeMap = new DOMNamespaceNodeMap(this.ownerDocument, parentNode); // create list containing clones of all children for (var i=0; i < this._nodes.length; i++) { cloneNamespaceNodeMap._appendChild(this._nodes[i].cloneNode(false)); } return cloneNamespaceNodeMap; }; /** * @method DOMNamespaceNodeMap.toString - Serialize this NamespaceNodeMap into an XML string * * @author Jon van Noort (jo...@we...) and David Joham (dj...@ya...) * * @return : string */ DOMNamespaceNodeMap.prototype.toString = function DOMNamespaceNodeMap_toString() { var ret = ""; // identify namespaces declared local to this Element (ie, not inherited) for (var ind = 0; ind < this._nodes.length; ind++) { // if namespace declaration does not exist in the containing node's, parentNode's namespaces var ns = null; try { var ns = this.parentNode.parentNode._namespaces.getNamedItem(this._nodes[ind].localNa me); } catch (e) { //breaking to prevent default namespace being inserted into return value break; } if (!(ns && (""+ ns.nodeValue == ""+ this._nodes[ind].nodeValue))) { // display the namespace declaration ret += this._nodes[ind].toString() +" "; } } return ret; }; /** * @class DOMNode - The Node interface is the primary datatype for the entire Document Object Model. * It represents a single node in the document tree. * * @author Jon van Noort (jo...@we...) * * @param ownerDocument : DOMDocument - The Document object associated with this node. */ DOMNode = function(ownerDocument) { this._class = addClass(this._class, "DOMNode"); if (ownerDocument) { this._id = ownerDocument._genId(); // generate unique internal id } this.namespaceURI = ""; // The namespace URI of this node (Level 2) this.prefix = ""; // The namespace prefix of this node (Level 2) this.localName = ""; // The localName of this node (Level 2) this.nodeName = ""; // The name of this node this.nodeValue = ""; // The value of this node this.nodeType = 0; // A code representing the type of the underlying object // The parent of this node. All nodes, except Document, DocumentFragment, and Attr may have a parent. // However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null this.parentNode = null; // A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes. // The content of the returned NodeList is "live" in the sense that, for instance, changes to the children of the node object // that it was created from are immediately reflected in the nodes returned by the NodeList accessors; // it is not a static snapshot of the content of the node. This is true for every NodeList, including the ones returned by the getElementsByTagName method. this.childNodes = new DOMNodeList(ownerDocument, this); this.firstChild = null; // The first child of this node. If there is no such node, this is null this.lastChild = null; // The last child of this node. If there is no such node, this is null. this.previousSibling = null; // The node immediately preceding this node. If there is no such node, this is null. this.nextSibling = null; // The node immediately following this node. If there is no such node, this is null. this.attributes = new DOMNamedNodeMap(ownerDocument, this); // A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise. this.ownerDocument = ownerDocument; // The Document object associated with this node this._namespaces = new DOMNamespaceNodeMap(ownerDocument, this); // The namespaces in scope for this node this._readonly = false; }; // nodeType constants DOMNode.ELEMENT_NODE = 1; DOMNode.ATTRIBUTE_NODE = 2; DOMNode.TEXT_NODE = 3; DOMNode.CDATA_SECTION_NODE = 4; DOMNode.ENTITY_REFERENCE_NODE = 5; DOMNode.ENTITY_NODE = 6; DOMNode.PROCESSING_INSTRUCTION_NODE = 7; DOMNode.COMMENT_NODE = 8; DOMNode.DOCUMENT_NODE = 9; DOMNode.DOCUMENT_TYPE_NODE = 10; DOMNode.DOCUMENT_FRAGMENT_NODE = 11; DOMNode.NOTATION_NODE = 12; DOMNode.NAMESPACE_NODE = 13; /** * @method DOMNode.hasAttributes * * @author Jon van Noort (jo...@we...) & David Joham (dj...@ya...) * * @return : boolean */ DOMNode.prototype.hasAttributes = function DOMNode_hasAttributes() { if (this.attributes.length == 0) { return false; } else { return true; } }; /** * @method DOMNode.getNodeName - Java style gettor for .nodeName * * @author Jon van Noort (jo...@we...) * * @return : string */ DOMNode.prototype.getNodeName = function DOMNode_getNodeName() { return this.nodeName; }; /** * @method DOMNode.getNodeValue - Java style gettor for .NodeValue * * @author Jon van Noort (jo...@we...) * * @return : string */ DOMNode.prototype.getNodeValue = function DOMNode_getNodeValue() { return this.nodeValue; }; /** * @method DOMNode.setNodeValue - Java style settor for .NodeValue * * @author Jon van Noort (jo...@we...) * * @param nodeValue : string - unique internal id */ DOMNode.prototype.setNodeValue = function DOMNode_setNodeValue(nodeValue) { // throw Exception if DOMNode is readonly if (this.ownerDocument.implementation.errorChecking && this._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } this.nodeValue = nodeValue; }; /** * @method DOMNode.getNodeType - Java style gettor for .nodeType * * @author Jon van Noort (jo...@we...) * * @return : int */ DOMNode.prototype.getNodeType = function DOMNode_getNodeType() { return this.nodeType; }; /** * @method DOMNode.getParentNode - Java style gettor for .parentNode * * @author Jon van Noort (jo...@we...) * * @return : DOMNode */ DOMNode.prototype.getParentNode = function DOMNode_getParentNode() { return this.parentNode; }; /** * @method DOMNode.getChildNodes - Java style gettor for .childNodes * * @author Jon van Noort (jo...@we...) * * @return : DOMNodeList */ DOMNode.prototype.getChildNodes = function DOMNode_getChildNodes() { return this.childNodes; }; /** * @method DOMNode.getFirstChild - Java style gettor for .firstChild * * @author Jon van Noort (jo...@we...) * * @return : DOMNode */ DOMNode.prototype.getFirstChild = function DOMNode_getFirstChild() { return this.firstChild; }; /** * @method DOMNode.getLastChild - Java style gettor for .lastChild * * @author Jon van Noort (jo...@we...) * * @return : DOMNode */ DOMNode.prototype.getLastChild = function DOMNode_getLastChild() { return this.lastChild; }; /** * @method DOMNode.getPreviousSibling - Java style gettor for .previousSibling * * @author Jon van Noort (jo...@we...) * * @return : DOMNode */ DOMNode.prototype.getPreviousSibling = function DOMNode_getPreviousSibling() { return this.previousSibling; }; /** * @method DOMNode.getNextSibling - Java style gettor for .nextSibling * * @author Jon van Noort (jo...@we...) * * @return : DOMNode */ DOMNode.prototype.getNextSibling = function DOMNode_getNextSibling() { return this.nextSibling; }; /** * @method DOMNode.getAttributes - Java style gettor for .attributes * * @author Jon van Noort (jo...@we...) * * @return : DOMNamedNodeList */ DOMNode.prototype.getAttributes = function DOMNode_getAttributes() { return this.attributes; }; /** * @method DOMNode.getOwnerDocument - Java style gettor for .ownerDocument * * @author Jon van Noort (jo...@we...) * * @return : DOMDocument */ DOMNode.prototype.getOwnerDocument = function DOMNode_getOwnerDocument() { return this.ownerDocument; }; /** * @method DOMNode.getNamespaceURI - Java style gettor for .namespaceURI * * @author Jon van Noort (jo...@we...) * * @return : String */ DOMNode.prototype.getNamespaceURI = function DOMNode_getNamespaceURI() { return this.namespaceURI; }; /** * @method DOMNode.getPrefix - Java style gettor for .prefix * * @author Jon van Noort (jo...@we...) * * @return : String */ DOMNode.prototype.getPrefix = function DOMNode_getPrefix() { return this.prefix; }; /** * @method DOMNode.setPrefix - Java style settor for .prefix * * @author Jon van Noort (jo...@we...) * * @param prefix : String * * @throws : DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Node is readonly. * @throws : DOMException - INVALID_CHARACTER_ERR: Raised if the string contains an illegal character * @throws : DOMException - NAMESPACE_ERR: Raised if the Namespace is invalid * */ DOMNode.prototype.setPrefix = function DOMNode_setPrefix(prefix) { // test for exceptions if (this.ownerDocument.implementation.errorChecking) { // throw Exception if DOMNode is readonly if (this._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // throw Exception if the prefix string contains an illegal character if (!this.ownerDocument.implementation._isValidName(prefix)) { thr... [truncated message content] |
From: David J. <dj...@ya...> - 2004-02-24 17:05:57
|
Hi Thomas, I think you're running into a known issue with the 3.0 parser. I have attached a new version of xmlw3cdom that should fix the problem for you. It's part of the 3.1 release which should come out sometime in late March or Early April. Please let me know if this doesn't fix the problem for you... David --- Thomas Schletter <tho...@gm...> wrote: > Hi > > I tried to parse nodes whitout text-content with the w3cdom-parser, until here > there is no problem. When I try to get these empty nodes (to get the > attributes) i can't access them, these nodes are not in the dom-tree. > > example xml taken from the sample-section and modified: > > <?xml version="1.0"?> > <CONTACTS> > <CONTACT id="4" > > <FIRSTNAME> > Kelly > </FIRSTNAME> > <LASTNAME> > VanMcIntyre > </LASTNAME> > <ADDRESS> > 92535 Highway 6 > </ADDRESS> > <CITY> > Somewhere > </CITY> > <STATE> > AZ > </STATE> > <ZIPCODE id="12345" /> > </CONTACT> > </CONTACTS> > > The Node "ZIPCODE" is not present in the dom-tree. Is there a way to get these > Nodes? > > > MfG Thomas Schletter > > -- > Mail: tho...@gm... > Tel: 0049 371/656 10654 > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools |
From: Thomas S. <tho...@gm...> - 2004-02-24 10:14:52
|
Hi I tried to parse nodes whitout text-content with the w3cdom-parser, until here there is no problem. When I try to get these empty nodes (to get the attributes) i can't access them, these nodes are not in the dom-tree. example xml taken from the sample-section and modified: <?xml version="1.0"?> <CONTACTS> <CONTACT id="4" > <FIRSTNAME> Kelly </FIRSTNAME> <LASTNAME> VanMcIntyre </LASTNAME> <ADDRESS> 92535 Highway 6 </ADDRESS> <CITY> Somewhere </CITY> <STATE> AZ </STATE> <ZIPCODE id="12345" /> </CONTACT> </CONTACTS> The Node "ZIPCODE" is not present in the dom-tree. Is there a way to get these Nodes? MfG Thomas Schletter -- Mail: tho...@gm... Tel: 0049 371/656 10654 |
From: David J. <dj...@ya...> - 2004-02-16 17:09:57
|
Hi Chandan, Currently, XPath isn't supported by the w3c parser. I'm working on a rather limited XPath solution at the moment that I hope to release sometime in the April timeframe. It will be similar in functionality to the tagPath searching for the classic DOM. Best regards, David --- Chandan Kumar <cha...@bl...> wrote: > Hi, > > Can we do XPath searches in the W3C version of the XML Parser. > > I have the following XML - > > <root> > <tagName1> > <text>1</text> > <tagName2> > <text>1</text> > <tagName3> > <text>1</text> > </tagName3> > </tabName2> > </tagName1> > </root> > > > I want to make an XPath expression search for //tagName1//tagName2//tagName3 > > Could you please suggest, how can I make the search if I have a w3cDOM > implementation. > > Thanks and regards, > Chandan > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html |
From: Chandan K. <cha...@bl...> - 2004-02-16 11:42:59
|
Hi, Can we do XPath searches in the W3C version of the XML Parser. I have the following XML - <root> <tagName1> <text>1</text> <tagName2> <text>1</text> <tagName3> <text>1</text> </tagName3> </tabName2> </tagName1> </root> I want to make an XPath expression search for //tagName1//tagName2//tagName3 Could you please suggest, how can I make the search if I have a w3cDOM implementation. Thanks and regards, Chandan |
From: David J. <dj...@ya...> - 2004-02-08 04:25:11
|
<oops, forgot to cc the list. I'm doing so now and added another question> Hi James, No clue here. I just tried the Linux version of Mozilla 1.6 with the xmlIOLoadLocalData sample application and it worked fine. Are you using Windows? If so, what happens when you go to http://xmljs.sourceforge.net/website/tools-loadLocalXML.html and run the sample? Does it work? If so, can you see if there is any difference in what your php is putting out vs. the text file? Is your php script on the open internet somewhere where I can take a look at it? David --- "James S. Elkins" <jam...@co...> wrote: > From the Desk of James S. ElkinsDavid, > > I'm having a strange problem with xmlIOLoadLocalData in Mozilla 1.5 > and 1.6. It's strange because it's happening in one application I've > written, but not in another. Here's what's happening: > > My PHP server application escapes XML as follows: > > $xml = "<?xml version=\"1.0\" ?>" > . " <personal-agent > member=\"".$this->member->get_handle()."\" > messages=\"".$this->new_messages."\" alerts=\"".$this->alerts."\" > posts=\"".$this->new_posts."\" > events=\"".$this->events."\"></personal-agent>"; > $xml = str_replace('<',chr(171),$xml); > $xml = str_replace('>',chr(187),$xml); > $xml = str_replace('&',chr(167),$xml); > > In Internet Explorer 6, xmlUnescapeHTMLToXML correctly unescapes this > as follows (for example): > > <?xml version="1.0" ?> > <personal-agent member="member_name" messages="1" alerts="0" posts="5" > events="0"></personal-agent> > > In Mozilla, however, xmlUnescapeHTMLToXML returns this: > > <?xml version="1.0" ?< > <personal-agent member="member_name" messages="1" alerts="0" posts="5" > events="0"<</personal-agent< > > In other words, it unescapes both greater-than and less-than symbols > as less-than sysmbols. Any ideas what might be causing this? > > Thanks, > James > authorized agent > > > James S. Elkins > 3606 S. Lee Ave. > Oklahoma City OK 73109 > > E-mail: jam...@co... > WWW: http://digitalarcana.net > > Specializing in: > > Web Development > Shopping Carts > Discussion Boards > Live Chat Systems > Content Management > E-Commerce Solutions > User Interface Design > Custom Integration > Standards Compatibility > > > PHP · MySQL · DHTML · CSS · XML > > digital arcana > > "Weaving Wicked Webs > Since 1994" > > > __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html |
From: James S. E. <jam...@co...> - 2004-02-07 23:56:05
|
From the Desk of James S. ElkinsDavid, I'm having a strange problem with xmlIOLoadLocalData in Mozilla 1.5 and 1.6. It's strange because it's happening in one application I've written, but not in another. Here's what's happening: My PHP server application escapes XML as follows: $xml = "<?xml version=\"1.0\" ?>" . " <personal-agent member=\"".$this->member->get_handle()."\" messages=\"".$this->new_messages."\" alerts=\"".$this->alerts."\" posts=\"".$this->new_posts."\" events=\"".$this->events."\"></personal-agent>"; $xml = str_replace('<',chr(171),$xml); $xml = str_replace('>',chr(187),$xml); $xml = str_replace('&',chr(167),$xml); In Internet Explorer 6, xmlUnescapeHTMLToXML correctly unescapes this as follows (for example): <?xml version="1.0" ?> <personal-agent member="member_name" messages="1" alerts="0" posts="5" events="0"></personal-agent> In Mozilla, however, xmlUnescapeHTMLToXML returns this: <?xml version="1.0" ?< <personal-agent member="member_name" messages="1" alerts="0" posts="5" events="0"<</personal-agent< In other words, it unescapes both greater-than and less-than symbols as less-than sysmbols. Any ideas what might be causing this? Thanks, James authorized agent James S. Elkins 3606 S. Lee Ave. Oklahoma City OK 73109 E-mail: jam...@co... WWW: http://digitalarcana.net Specializing in: Web Development Shopping Carts Discussion Boards Live Chat Systems Content Management E-Commerce Solutions User Interface Design Custom Integration Standards Compatibility PHP · MySQL · DHTML · CSS · XML digital arcana "Weaving Wicked Webs Since 1994" |
From: David J. <dj...@ya...> - 2004-01-22 19:20:06
|
Hello, 7000 lines? That might be a little bit more than XML for <SCRIPT> can handle, unless you're on a very fast computer. XML for <SCRIPT> is dependant on the speed of JavaScript on each browser. Sadly, JavaScript isn't the fastest thing around and as you get more and more nodes, XML for <SCRIPT>'s performance starts to drag. Sadly, there isn't a whole lot I've been able to figure out to do about this. The Classic DOM is faster than the W3C DOM, but not a whole lot faster. My current idea is to try to somehow use the C++ based parsers of the individual browsers, but that solution is still unproven. I'm sorry if XML for <SCRIPT> won't work for you, but I'd rather tell you how it is than try to lead you down a path I don't think will work for you... Best regards, David --- nurti <nu...@em...> wrote: > Thank's David, > for your response. > I have now another big problem! > > I have to parse an xml stream with 7000 line and w3cdom parser get much time for load this > stream! > Have yuo any suggest? > You think that is better an applet that xml for script for this large stream? > > Thank's > > > -- > Email.it, the professional e-mail, gratis per te: http://www.email.it/f > > Sponsor: > Vieni a visitare il Garden Center Peraga. Seimila metri quadrati di esposizione per servire una > clientela competente ed esigente. > Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=1480&d=22-1 __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ |