Re: [xmljs-users] Q: catching a DOMException, retrieving line and column
Brought to you by:
djoham,
witchhunter
|
From: Simon O. <sim...@we...> - 2007-10-10 17:54:06
|
Hi Dmitry,
I hoped there was a no-code-change solution.
It would be helpful if the parser object is accessible after parsing in
the next release of XML-for-SCRIPT.
I changed my version of XML-for-SCRIPT already, so that the parser can
be accessed:
Line 172:
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);
*this.parser = parser;*
// 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;
};
Ok, I admit, it's a hack ;)
After loadXML has returned I can print a custom error message to my gui.
Greetings
Simon
Dmitry Khudorozhkov schrieb:
> Hi Simon,
>
> there is a line in 'xmlw3cdom.js' file, '_parseLoop' method
> (line 554, it is commented):
>
> // alert("Fatal Error: " + p.getContent() + "\nLine: " +
> p.getLineNumber() + "\nColumn: " + p.getColumnNumber() + "\n");
>
> By uncommenting this line, you'll get your debug information.
>
> Hope it helps,
>
> - Dmitry Khudorozhkov, maintainer of XML-for-SCRIPT.
>
> */Simon Ottenhaus <sim...@we...>/* wrote:
>
> Hi all,
>
> I'm using the DOMImplementation of XML for to parse
> user-written xml. So syntax errors are likely.
>
> My code is:
> var parser = new DOMImplementation();
> try {
> var domDoc = parser.loadXML(sXml);
> } catch (e) {
> var sCode = parser.translateErrCode(e.code);
> }
>
> How do I retrieve the line and the column where the error occurred?
>
> The XMLP-parser provides getLineNumber and getColumnNumber, but the
> parser-object used in xmlw3cdom.js (line 177) cannot be accessed from
> outside.
>
> Excuse my english, please ;)
>
> Greetings
>
> Simon
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a
> browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> xmljs-users mailing list
> xml...@li...
> https://lists.sourceforge.net/lists/listinfo/xmljs-users
>
>
> ------------------------------------------------------------------------
> Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user
> panel
> <http://us.rd.yahoo.com/evt=48516/*http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7%20>
> and lay it on us.
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> ------------------------------------------------------------------------
>
> _______________________________________________
> xmljs-users mailing list
> xml...@li...
> https://lists.sourceforge.net/lists/listinfo/xmljs-users
>
|