importNode and root node name

U

Une Bévue

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.parameters.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);

???
 
U

Une Bévue

Une Bévue said:
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)
 
M

Martin Honnen

Une said:
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.parameters.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.
 
U

Une Bévue

Martin Honnen said:
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 !
 
B

Bjoern Hoehrmann

* 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.parameters.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.
 
U

Une Bévue

Bjoern Hoehrmann said:
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)
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.xhtml> only
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...
 
B

Bjoern Hoehrmann

* 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.xhtml> only
tested on Mac OS X : firefox ans safari)

But //* is very different from /*.
 
U

Une Bévue

Bjoern Hoehrmann said:
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 !
But //* is very different from /*.

yes clearly ))
 
H

Holger Jeromin

Une Bévue schrieb am 26.04.2008 19:02:
Bjoern Hoehrmann <[email protected]> wrote:
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.xhtml> only
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
 
U

Une Bévue

Holger Jeromin said:
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 ;-)
 
H

Holger Jeromin

Une Bévue schrieb am 26.04.2008 20:46:
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 ;-)

:)
 
U

Une Bévue

Holger Jeromin said:
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 !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top