469,627 Members | 943 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,627 developers. It's quick & easy.

importNode and root node name

at the page :
<http://thoraval.yvon.free.fr/Fixed_layout/import_nodes.xhtml>
when importing an svg document i have to do :
document.importNode(
req.responseXML.getElementsByTagName(req.parameter s.root)[0],true))

(lines 46/47)

in case of SVG : req.parameters.root = 'svg'
and 'math' in case of MathML
there is no DOM method for getting the root node, enabling not to
specify the root is svg|math ???

or could i do that using DOM/XPath ?

ie something like :
req.responseXML.evaluate('/',document, nsResolver, XPathResult.ANY_TYPE,
null);

???
--
Une Bévue
Jun 27 '08 #1
11 2442
Une Bévue <un************@weltanschauung.com.invalidwrote:
>
there is no DOM method for getting the root node, enabling not to
specify the root is svg|math ???

req.responseXML.documentElement

response given over the french clj (fr.c.l.j)

--
Une Bévue
Jun 27 '08 #2
Une Bévue wrote:
at the page :
<http://thoraval.yvon.free.fr/Fixed_layout/import_nodes.xhtml>
when importing an svg document i have to do :
document.importNode(
req.responseXML.getElementsByTagName(req.parameter s.root)[0],true))

(lines 46/47)

in case of SVG : req.parameters.root = 'svg'
and 'math' in case of MathML
there is no DOM method for getting the root node, enabling not to
specify the root is svg|math ???

or could i do that using DOM/XPath ?

ie something like :
req.responseXML.evaluate('/',document, nsResolver, XPathResult.ANY_TYPE,
null);

???
The root element is simply accessible as
req.responseXML.documentElement

The root node in the XPath data model is the document node in the DOM
model thus if you want to access the root node then you simply need
req.responseXML
However you can't import document nodes.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #3
Martin Honnen <ma*******@yahoo.dewrote:
>
The root element is simply accessible as
req.responseXML.documentElement

The root node in the XPath data model is the document node in the DOM
model thus if you want to access the root node then you simply need
req.responseXML
However you can't import document nodes.
OK, fine thanks !
--
Une Bévue
Jun 27 '08 #4
* Une Bévue wrote in comp.lang.javascript:
>at the page :
<http://thoraval.yvon.free.fr/Fixed_layout/import_nodes.xhtml>
when importing an svg document i have to do :
document.importNode(
req.responseXML.getElementsByTagName(req.paramete rs.root)[0],true))

(lines 46/47)

in case of SVG : req.parameters.root = 'svg'
and 'math' in case of MathML
When dealing with elements in a namespace you should instead use the
method getElementsByTagNameNS() and properly specify the namespace in
addition to the local name, like

.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'svg');
>or could i do that using DOM/XPath ?

ie something like :
req.responseXML.evaluate('/',document, nsResolver, XPathResult.ANY_TYPE,
null);
You would select '/*' to get the root element as opposed to the root
node.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jun 27 '08 #5
Bjoern Hoehrmann <bj****@hoehrmann.dewrote:
>
When dealing with elements in a namespace you should instead use the
method getElementsByTagNameNS() and properly specify the namespace in
addition to the local name, like

.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'svg');
OK, then, i do have to assume i was somehow "lucky" when not specifying
the ns ? (that works without it)
or could i do that using DOM/XPath ?

ie something like :
req.responseXML.evaluate('/',document, nsResolver, XPathResult.ANY_TYPE,
null);

You would select '/*' to get the root element as opposed to the root
node.
then a dom/xpath expression isn't equivalent to an xslt/xpath one ?

i understand '/*' takes the root + everything below it.

'/' takes the node only.

and again, i'd have to specify the ns :

'/xhtml|svg|math:*'

this is unclear to me because when i specify '//xhtml:body' (for example
in the dropdown at
<http://thoraval.yvon.free.fr/Fixed_layout/editable_dropdown.xhtmlonly
tested on Mac OS X : firefox ans safari)

i'm able to log the children and attributes.

i think i misunderstood the difference between node and element...
--
Une Bévue
Jun 27 '08 #6
* Une Bévue wrote in comp.lang.javascript:
>then a dom/xpath expression isn't equivalent to an xslt/xpath one ?

i understand '/*' takes the root + everything below it.
No, this matches any element that is a child of the root node. There can
only be one element with the root node as parent, the root element. This
is the same wherever you use XPath. The root node and everything below
it would be //node(), for example.
>this is unclear to me because when i specify '//xhtml:body' (for example
in the dropdown at
<http://thoraval.yvon.free.fr/Fixed_layout/editable_dropdown.xhtmlonly
tested on Mac OS X : firefox ans safari)
But //* is very different from /*.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jun 27 '08 #7
Bjoern Hoehrmann <bj****@hoehrmann.dewrote:
>
No, this matches any element that is a child of the root node. There can
only be one element with the root node as parent, the root element. This
is the same wherever you use XPath. The root node and everything below
it would be //node(), for example.
OK, clear enough, thanks !
>
this is unclear to me because when i specify '//xhtml:body' (for example
in the dropdown at
<http://thoraval.yvon.free.fr/Fixed_layout/editable_dropdown.xhtmlonly
tested on Mac OS X : firefox ans safari)

But //* is very different from /*.
yes clearly ))
--
Une Bévue
Jun 27 '08 #8
Une Bévue schrieb am 26.04.2008 19:02:
Bjoern Hoehrmann <bj****@hoehrmann.dewrote:
this is unclear to me because when i specify '//xhtml:body' (for example
in the dropdown at
<http://thoraval.yvon.free.fr/Fixed_layout/editable_dropdown.xhtmlonly
tested on Mac OS X : firefox ans safari)
Just for your Information:

Internet Explorer gives a download Requester for each xhtml file (sent
by xhtml+xml)

http://blogs.msdn.com/ie/archive/2005/09/15/467901.aspx

--
Mit freundlichen Grüßen
Holger Jeromin
Jun 27 '08 #9
Holger Jeromin <ne*********@katur.dewrote:
>
Internet Explorer gives a download Requester for each xhtml file (sent
by xhtml+xml)
yes, i know even if i can't test over win* ...

but could i implement xhtml served as text/html with more than 4
namespaces ???

vielen dank ;-)
--
Une Bévue
Jun 27 '08 #10
Une Bévue schrieb am 26.04.2008 20:46:
Holger Jeromin <ne*********@katur.dewrote:
>Internet Explorer gives a download Requester for each xhtml file (sent
by xhtml+xml)
yes, i know even if i can't test over win* ...

but could i implement xhtml served as text/html with more than 4
namespaces ???
you can, but it is not nice and can only used for IE, because Opera und
FF don't support this as a HTML mess.
vielen dank ;-)
:-)

--
Mit freundlichen Grüßen
Holger Jeromin
Jun 27 '08 #11
Holger Jeromin <ne*********@katur.dewrote:
>
you can, but it is not nice and can only used for IE, because Opera und
FF don't support this as a HTML mess.
OK, seems strange to me the fact the guys of Microsoft have less man
power than Apple for that kind of things...

they argue about "improving our CSS support" and html parser where i
discovered today the latest WebKit (safari) even the Gtk version for
gnome is 100% Acid3 test successfull...

tchuss !

--
Une Bévue
Jun 27 '08 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Andy Fish | last post: by
12 posts views Thread by pillepop2003 | last post: by
1 post views Thread by Andrew Jacobs | last post: by
15 posts views Thread by Stig Brautaset | last post: by
5 posts views Thread by yawnmoth | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.