Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > importNode and root node name

Reply
Thread Tools

importNode and root node name

 
 
Une Bévue
Guest
Posts: n/a
 
      04-26-2008
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
 
Reply With Quote
 
 
 
 
Une Bévue
Guest
Posts: n/a
 
      04-26-2008
Une Bévue <(E-Mail Removed)> wrote:

>
> 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
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      04-26-2008
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/
 
Reply With Quote
 
Une Bévue
Guest
Posts: n/a
 
      04-26-2008
Martin Honnen <(E-Mail Removed)> wrote:

>
> 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
 
Reply With Quote
 
Bjoern Hoehrmann
Guest
Posts: n/a
 
      04-26-2008
* 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 · (E-Mail Removed) · 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/
 
Reply With Quote
 
Une Bévue
Guest
Posts: n/a
 
      04-26-2008
Bjoern Hoehrmann <(E-Mail Removed)> wrote:

>
> 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.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...
--
Une Bévue
 
Reply With Quote
 
Bjoern Hoehrmann
Guest
Posts: n/a
 
      04-26-2008
* 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 /*.
--
Björn Höhrmann · (E-Mail Removed) · 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/
 
Reply With Quote
 
Une Bévue
Guest
Posts: n/a
 
      04-26-2008
Bjoern Hoehrmann <(E-Mail Removed)> wrote:

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

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


yes clearly ))
--
Une Bévue
 
Reply With Quote
 
Holger Jeromin
Guest
Posts: n/a
 
      04-26-2008
Une Bévue schrieb am 26.04.2008 19:02:
> Bjoern Hoehrmann <(E-Mail Removed)> 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

--
Mit freundlichen Grüßen
Holger Jeromin
 
Reply With Quote
 
Une Bévue
Guest
Posts: n/a
 
      04-26-2008
Holger Jeromin <(E-Mail Removed)> wrote:

>
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem updating an attribute that appears in both root node and child node! Tedros.G@googlemail.com XML 1 05-08-2007 11:32 AM
Document.importNode(Node,boolean) - what supports it? Simon Brooke XML 10 03-17-2007 02:06 PM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM
performance of importNode Andy Fish XML 0 11-04-2003 10:52 AM



Advertisments