-
29 Nov 2007 6:37 PM #1
xml namespaces with Ext.DomQuery
xml namespaces with Ext.DomQuery
Hi,
I have an xml document which contains element names consisting of namespaces, i.e.:
<cam:Alertcode>3000</cam:AlertCode>
I'd like to use the DomQuery class to select this node from the document but it throws an error:
The command I'm using to do the select isCode:Ext.DomQuery.pseudos[name] is not a function.
Is there a way to use DomQuery to select elements who's name contains a namespace reference?Code:Ext.DomQuery.selectNode("cam:AlertCode", doc.firstChild);Last edited by mystix; 29 Nov 2007 at 6:42 PM. Reason: moved to 1.x Help from 1.x Bugs
-
9 Mar 2008 3:41 AM #2
I you want to use xml namespaces with DomQuery you have to modify a little bit the source code :
replace
byCode:var tagTokenRe = /^(#)?([\w-\*]+)/;
andCode:var tagTokenRe = /^(#)?([\w-\*]+:?[\w-\*]+)/
byCode:re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/, select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
addCode:re: /^(?:([\[\{])(?:@)?([\w-:]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/, [\]\}])/, select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
just afterCode:var namespaceRe = /^([\w]+:)?([\w-\*]+)/;
and thus modifyCode:var tagTokenRe = /^(#)?([\w]+:?[\w]+|\*)/;
like thisCode:if(!mode){ for(var i = 0, ni; ni = ns[i]; i++){ cs = ni.getElementsByTagName(tagName); for(var j = 0, ci; ci = cs[j]; j++){ result[++ri] = ci; } }
You can ask me by PM if I'm not clear.Code:if(!mode){ for(var i = 0, ni; ni = ns[i]; i++){ cs = ni.getElementsByTagName(tagName.match(namespaceRe)[2]); for(var j = 0, ci; ci = cs[j]; j++){ result[++ri] = ci; } }
Is a modification is planned for this problem ?
Because with ns, DomQuery is so amazing
EDIT :
I realized that selectValue didn't work, to correct edit ext-all-debug like this :
Code:re: /^@([\w-]+:?[\w-]+)/, // re: /^@([\w-]+)/, select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
-
27 Jan 2009 10:41 AM #3
Thank you very much for the information at this time it works

-
1 Feb 2009 1:07 PM #4
When using the modified class are not working class library ExtJS. But I created a class Ext.nsDomQueryYu in which the modification and use it for their needs. A class Ext.DomQuery using library classes.
-
3 Feb 2009 4:42 AM #5
Changes failed
Changes failed
I'm trying to fulfill instructions. But
raises error in EXTJS.Code:re: /^(?:([\[\{])(?:@)?([\w-:]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/, [\]\}])/, select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
Would you post the whole source as attachment?
-
3 Feb 2009 5:08 AM #6
Syntax error. Try this:Code:re: /^(?:([\[\{])(?:@)?([\w-:]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/, [\]\}])/, select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
But with these changes, the library ExtJS does not work. I created aCode:re: /^(?:([\[\{])(?:@)?([\w-:]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/, select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
separate class for working with namespaces. Full source file
ext-all-debug.js as an attachment.
-
11 Feb 2009 12:27 PM #7
I have the same problem, I downloaded your version of ext-all-debug.js and
I put in my html file:
byCode:<script type="text/javascript" src="../../ext-all.js"></script>
but it does notCode:<script type="text/javascript" src="../../ext-all-debug.js"></script>
-
12 Feb 2009 1:24 AM #8
-
12 Feb 2009 3:37 AM #9
I make the changes as Hadrian, and when I use a feedviewer it does not work so I tested the solution smail.
this solution does not work too, I know how to use it?
-
12 Feb 2009 4:27 AM #10
Ext JS will not work with any version of files.
But, you can use the class nsDomQuery for their own needs. For example query xpath.
If you want to receive data from a server in the format of XML, which uses a namespace, you must convert the data from XML to any format and then use the transformed data in the widgets Ext JS.


Reply With Quote