Search the web
Sign In
New User? Sign Up
tdom · tDOM - fast DOM / XPath for Tcl in C
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Uset tdom from C   Message List  
Reply | Forward Message #1935 of 1982 |
Re: [tdom] Re: Uset tdom from C

Gotcha. Indeed it works with a built in DTD but would be nice to have the lookup-id-table.

Thanks, reb.
 ==
A goal is not always meant to be reached, it often serves simply as something to aim at.
Bruce Lee



From: Rolf Ade <rolf@...>
To: tdom@yahoogroups.com
Sent: Friday, March 6, 2009 10:22:54 AM
Subject: Re: [tdom] Re: Uset tdom from C


rebosher wrote:
> getElementById doesn't work for me.
>
> $nodeObj find "id" "idname" will get the right tag.
>
> Does getElementById needs a DTD validation? How about a schema (xsd)?

No, it doesn't need DTD validation, but of course a parsed DTD. (Note
the 'parsed', that's a hint in case you've an external DTD subset.)

This is needed because the parser needs to know which attributes are
of the attribute type ID. The name of the attribute is completely
irrelevant, its the attribute type, which makes it to an ID attribute.

Without a DTD, getElementById returns always the empty string. Provide
the correct DTD and it works pretty well.

No, there isn't xsd support.

Note, that the html parser does fill the internal lookup table used by
getElementById if it sees an attribute with the name "id" (in recent
tDOM).

If you know the name of the ID attribue, you could always get the node
with (say, the attribute name is 'id')

$doc selectNodes //*[@id='your_ id_value_ here']

though that is much lesser efficient that getElementById (with a DTD
in place), because the first does a complete tree scan and the later
uses a lookup hash table.

If you need several lookups (and still want/could not provid a DTD)
you could easily build your own lookup table at script level.

The xml:id recommendation
http://www.w3. org/TR/2005/ REC-xml-id- 20050909/ probably would be a
nice feature to have. I'm thinking about adding that for the next
release.

rolf




Fri Mar 6, 2009 9:47 pm

rebosher
Offline Offline
Send Email Send Email

Forward
Message #1935 of 1982 |
Expand Messages Author Sort by Date

Hello, Normally, it is better to use tdom from tcl, but sometimes, for eficiency reasons, it could be interesting to use it from C. I think that it would be a...
ramsan100
ramsan@...
Send Email
Jul 10, 2003
11:03 am

... I'm far from being an expert on this (like Rolf and/or Jochen are) but AFAIK, DOM tree functions are exported and there is already an DOM C-API (look into...
Zoran Vasiljevic
vungerk
Offline Send Email
Jul 10, 2003
11:20 am

Right, dom.c (see dom.h) provides standard DOM inferface (here C functions). Similar, domxpat.h and domxlst.h provide XPATH and XSLT processing functions ...
Jochen Loewer
loewerj
Offline Send Email
Jul 11, 2003
6:46 am

getElementById doesn't work for me. $nodeObj find "id" "idname" will get the right tag. Does getElementById needs a DTD validation? How about a schema (xsd)?...
rebosher
Offline Send Email
Mar 6, 2009
2:42 pm

... No, it doesn't need DTD validation, but of course a parsed DTD. (Note the 'parsed', that's a hint in case you've an external DTD subset.) This is needed...
Rolf Ade
rolf@...
Send Email
Mar 6, 2009
3:23 pm

Gotcha. Indeed it works with a built in DTD but would be nice to have the lookup-id-table. Thanks, reb. ==A goal is not always meant to be reached, it often...
Asher Klatchko
rebosher
Offline Send Email
Mar 6, 2009
9:47 pm

... Well, it also works with an external DTD, if you prefer that. In that case, you've to provide an -externalentitycommand as URI resolver. In other words,...
Rolf Ade
rolf@...
Send Email
Mar 6, 2009
11:50 pm

The DTD is alright as a hydra for the XML data-structure. But we often times skip it in our amateurish approach to data and yet have it as well formed...
Asher Klatchko
rebosher
Offline Send Email
Mar 9, 2009
1:09 am

... I'm not sure, I understand the question. Do you ask for DTD validation? If yes, look at the tnc extension (which is bundled with the distribution). ... I...
Rolf Ade
rolf@...
Send Email
Mar 9, 2009
8:11 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help