Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Ajax ISBN: 978-0-471-77778-6
This is the forum to discuss the Wrox book Professional Ajax by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780471777786
Important: For the new 2nd edition of this book, please post here instead: [url="http://p2p.wrox.com/forum.asp?FORUM_ID=307"]http://p2p.wrox.com/forum.asp?FORUM_ID=307[/url]
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax ISBN: 978-0-471-77778-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 22nd, 2006, 12:43 PM
Registered User
 
Join Date: Apr 2006
Location: Oakland, CA, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default zxml.js errors?

Environment -
Dreamweaver MX6
IE6
WindowsXP(SP2)
IIS5
PHP5

In Dreamweaver MX 6.0, I select Preview/Debug in browser -> Debug in iexplore
[The parent page is "IncrementalFormValidationExample.htm" from the chapter 3 example patterns.]

See pop-up box with warnings & errors:
Warning 5002 variable "sXmlNs" already defined. The variable name was already used inside this function.
Warning 5002 variable "i" already defined. The variable name was already used inside this function.
Error 1013 expected label for break. The break statement can optionally be followed by a label that allows it to break out of an outer loop or block statement. If the break is not inside a loop, then it must have a label. The label must be on the same line or else Javascript will assume it is part of the next statement following the break statement.

Is there a better version of zxml.js to use, at least to eliminate the error?
Reply With Quote
  #2 (permalink)  
Old April 22nd, 2006, 01:48 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I don't use Dreamweaver for development, so I'm not sure exactly what error it thinks it's finding, but zXml works properly in IE6 and Firefox, so I'm not sure there's any updates needed.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #3 (permalink)  
Old April 22nd, 2006, 03:02 PM
Registered User
 
Join Date: Apr 2006
Location: Oakland, CA, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Fair enough. I have not been too impressed with the JavaScript debugger in MX 6.

Reply With Quote
  #4 (permalink)  
Old February 20th, 2012, 06:44 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello.
On Internet Explore 9, there is a problema this line:

oMozDocument.prototype.onreadystatechange=null

IE error:
SCRIPT65535: Oggetto chiamante non valido
zxml.js, Riga 1 Carattere 1971

Can You Help ME
Thankssssssssss
Reply With Quote
  #5 (permalink)  
Old April 13th, 2015, 01:57 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Now its working on latest browser.
I have written the following code to solve the zxml.js issues. Hope it will help.

Code:
var zXml = {
    useActiveX: (window.ActiveXObject || "ActiveXObject" in window),
    useDom: document.implementation && document.implementation.createDocument && !(window.ActiveXObject || "ActiveXObject" in window),
    useXmlHttp: (typeof XMLHttpRequest != "undefined") && !(window.ActiveXObject || "ActiveXObject" in window)
};

zXml.ARR_XMLHTTP_VERS = ["MSXML2.XmlHttp.6.0", "MSXML2.XmlHttp.3.0"];
zXml.ARR_DOM_VERS = ["MSXML2.DOMDocument.6.0", "MSXML2.DOMDocument.3.0", "Microsoft.XMLDOM"];

function zXmlHttp() { }

zXmlHttp.createRequest = function () {
    if (zXml.useXmlHttp) {
        return new XMLHttpRequest();
    } else if (zXml.useActiveX) {
        if (!zXml.XMLHTTP_VER) {
            for (var i = 0; i < zXml.ARR_XMLHTTP_VERS.length; i++) {
                try {
                    new ActiveXObject(zXml.ARR_XMLHTTP_VERS[i]);
                    zXml.XMLHTTP_VER = zXml.ARR_XMLHTTP_VERS[i];
                    break;
                } catch (oError) { ; }
            }
        }

        if (zXml.XMLHTTP_VER) {
            return new ActiveXObject(zXml.XMLHTTP_VER);
        } else {
            throw new Error("Could not create XML HTTP Request.");
        }
    } else {
        throw new Error("Your browser doesn't support an XML HTTP Request.");
    }
};

zXmlHttp.isSupported = function () {
    return zXml.useXmlHttp || zXml.useActiveX;
};

function zXmlDom() { }
zXmlDom.createDocument = function () {
    if (zXml.useDom) {
        var oXmlDom = document.implementation.createDocument("", "", null);
        oXmlDom.parseError = {
            valueOf: function () {
                return this.errorCode;
            },
            toString: function () {
                return this.errorCode.toString()
            }
        };
        oXmlDom.__initError__();
        oXmlDom.addEventListener("load", function () {
            this.__checkForErrors__();
            this.__changeReadyState__(4);
        }, false);
        return oXmlDom;
    } else if (zXml.useActiveX) {
        if (!zXml.DOM_VER) {
            for (var i = 0; i < zXml.ARR_DOM_VERS.length; i++) {
                try {
                    new ActiveXObject(zXml.ARR_DOM_VERS[i]);
                    zXml.DOM_VER = zXml.ARR_DOM_VERS[i];
                    break;
                } catch (oError) { ; }
            }
        }
        if (zXml.DOM_VER) {
            return new ActiveXObject(zXml.DOM_VER);
        } else {
            throw new Error("Could not create XML DOM document.");
        }
    } else {
        throw new Error("Your browser doesn't support an XML DOM document.");
    }
};

zXmlDom.isSupported = function () {
    return zXml.useDom || zXml.useActiveX;
};

var oMozDocument = null;
if (typeof XMLDocument != "undefined") {
    oMozDocument = XMLDocument;
} else if (typeof Document != "undefined") {
    oMozDocument = Document;
}
if (oMozDocument && !window.opera && !!document.evaluate) {
    oMozDocument.prototype.readyState = 0;
    try {
        oMozDocument.prototype.onreadystatechange = null;
    } catch (oError) { ; }
    oMozDocument.prototype.__changeReadyState__ = function (iReadyState) {
        this.readyState = iReadyState;
        if (typeof this.onreadystatechange == "function") {
            this.onreadystatechange();
        }
    };
    oMozDocument.prototype.__initError__ = function () {
        this.parseError.errorCode = 0;
        this.parseError.filepos = -1;
        this.parseError.line = -1;
        this.parseError.linepos = -1;
        this.parseError.reason = null;
        this.parseError.srcText = null;
        this.parseError.url = null;
    };
    oMozDocument.prototype.__checkForErrors__ = function () {
        if (this.documentElement.tagName == "parsererror") {
            var reError = />([\s\S]*?)Location:([\s\S]*?)Line Number(\d+),Column(\d+):<sourcetext>([\s\S]*?)(?:\-*\^)/;
            reError.test(this.xml);
            this.parseError.errorCode = -999999;
            this.parseError.reason = RegExp.$1;
            this.parseError.url = RegExp.$2;
            this.parseError.line = parseInt(RegExp.$3);
            this.parseError.linepos = parseInt(RegExp.$4);
            this.parseError.srcText = RegExp.$5;
        }
    };
    oMozDocument.prototype.loadXML = function (sXml) {
        this.__initError__();
        this.__changeReadyState__(1);
        var oParser = new DOMParser();
        var oXmlDom = oParser.parseFromString(sXml, "text/xml");
        while (this.firstChild) {
            this.removeChild(this.firstChild);
        }
        for (var i = 0; i < oXmlDom.childNodes.length; i++) {
            var oNewNode = this.importNode(oXmlDom.childNodes[i], true);
            this.appendChild(oNewNode);
        }
        this.__checkForErrors__();
        this.__changeReadyState__(4);
    };
    oMozDocument.prototype.__load__ = oMozDocument.prototype.load;
    oMozDocument.prototype.load = function (sURL) {
        this.__initError__();
        this.__changeReadyState__(1);
        this.__load__(sURL);
    };
    
    Node.prototype.selectNodes = function (sXPath) { return zXPath.selectNodes(this, sXPath, null); };
    Node.prototype.selectSingleNode = function (sXPath) { return zXPath.selectSingleNode(this, sXPath, null); };

    Object.defineProperty(Node.prototype, "xml", {
        get: function () {
            var oSerializer = new XMLSerializer();
            return oSerializer.serializeToString(this, "text/xml");
        }
    });
    Object.defineProperty(Node.prototype, "text", {
        set: function (val) {
            this.textContent = val;
        },

        get: function () {
            var sText = "";
            for (var i = 0; i < this.childNodes.length; i++) {
                if (this.childNodes[i].hasChildNodes()) {
                    sText += this.childNodes[i].text;
                } else {
                    sText += this.childNodes[i].nodeValue;
                }
            }
            return sText;
        }
    });
}

function zXslt() { }
zXslt.transformToText = function (oXml, oXslt) {
    if (typeof XSLTProcessor != "undefined") {
        var oProcessor = new XSLTProcessor();
        oProcessor.importStylesheet(oXslt);
        var oResultDom = oProcessor.transformToDocument(oXml);
        var sResult = oResultDom.xml;
        if (sResult.indexOf("<transformiix:result") > -1) {
            sResult = sResult.substring(sResult.indexOf(">") + 1, sResult.lastIndexOf("<"));
        }
        return sResult;
    } else if (zXml.useActiveX) {
        return oXml.transformNode(oXslt);
    } else {
        throw new Error("No XSLT engine found.");
    }
};

function zXPath() { }
zXPath.selectNodes = function (oRefNode, sXPath, oXmlNs) {
    if (typeof XPathEvaluator != "undefined") {
        oXmlNs = oXmlNs || {};
        var nsResolver = function (sPrefix) {
            return oXmlNs[sPrefix];
        };
        var oEvaluator = new XPathEvaluator();
        var oResult = oEvaluator.evaluate(sXPath, oRefNode, nsResolver, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
        var aNodes = new Array;
        if (oResult != null) {
            var oElement = oResult.iterateNext(); while (oElement) {
                aNodes.push(oElement); oElement = oResult.iterateNext();
            }
        } return aNodes;
    } else if (zXml.useActiveX) {
        if (oXmlNs) {
            var sXmlNs = "";
            for (var sProp in oXmlNs) {
                sXmlNs += "xmlns:" + sProp + "=\'" + oXmlNs[sProp] + "\' ";
            }
            oRefNode.ownerDocument.setProperty("SelectionNamespaces", sXmlNs);
        };
        return oRefNode.selectNodes(sXPath);
    } else {
        throw new Error("No XPath engine found.");
    }
};

zXPath.selectSingleNode = function (oRefNode, sXPath, oXmlNs) {
    if (typeof XPathEvaluator != "undefined") {
        ; oXmlNs = oXmlNs || {};
        var nsResolver = function (sPrefix) { return oXmlNs[sPrefix]; };
        var oEvaluator = new XPathEvaluator();
        var oResult = oEvaluator.evaluate(sXPath, oRefNode, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
        if (oResult != null) {
            return oResult.singleNodeValue;
        } else {
            return null;
        };
    } else if (zXml.useActiveX) {
        if (oXmlNs) {
            var sXmlNs = "";
            for (var sProp in oXmlNs) {
                sXmlNs += "xmlns:\'" + sProp + "=" + oXmlNs[sProp] + "\' ";
            } oRefNode.ownerDocument.setProperty("SelectionNamespaces", sXmlNs);
        }; return oRefNode.selectSingleNode(sXPath);
    } else {
        throw new Error("No XPath engine found.");
    }
};

function zXMLSerializer() { }
zXMLSerializer.prototype.serializeToString = function (oNode) {
    var sXml = "";
    switch (oNode.nodeType) {
        case 1: sXml = "<" + oNode.tagName;
            for (var i = 0; i < oNode.attributes.length; i++) {
                sXml += " " + oNode.attributes[i].name + "=\"" + oNode.attributes[i].value + "\"";
            } sXml += ">"; for (var i = 0; i < oNode.childNodes.length; i++) {
                sXml += this.serializeToString(oNode.childNodes[i]);
            }
            sXml += "</" + oNode.tagName + ">";
            break;
        case 3: sXml = oNode.nodeValue;
            break;
        case 4: sXml = "<![CDATA[" + oNode.nodeValue + "]]>";
            break;
        case 7: sXml = "<?" + oNode.nodevalue + "?>";
            break;
        case 8: sXml = "<!--" + oNode.nodevalue + "-->";
            break;
        case 9: for (var i = 0; i < oNode.childNodes.length; i++) {
                sXml += this.serializeToString(oNode.childNodes[i]);
            } break;
    };
    return sXml;
};
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
zxml.js library for firefox 3.0 manahual BOOK: Professional Ajax ISBN: 978-0-471-77778-6 4 March 2nd, 2010 03:59 AM
Zxml.js and input radio problem tezro BOOK: Professional Ajax ISBN: 978-0-471-77778-6 3 December 8th, 2007 04:19 PM
zxml.js - is there a readable copy available? bobwazz BOOK: Professional Ajax ISBN: 978-0-471-77778-6 3 May 17th, 2007 09:21 AM
syntax error only when zxml.js included daddy BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 July 1st, 2006 10:33 PM
MSXML 6 in zxml.js rloewy BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 May 2nd, 2006 02:23 AM



All times are GMT -4. The time now is 05:59 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.