GNOME Bugzilla – Bug 154934
Yelp gets confused without id attributes
Last modified: 2009-09-22 01:48:06 UTC
I can't get Yelp to love me at all. So here's a simple Docbook file that demonstrates some of the problems I'm having. Try to open the attached Docbook file with Yelp, by typing "yelp manual.xml" in a Terminal window. - The sidebar shows only "Contents" (not the "Using My Program" chapter, or any of its sections) - Any section you click on shows "Error: The selected page could not be found in this document." - If you uncomment the "repeated a bunch of times:" sect1's (which is the last section, repeated 10 times), it'll sometimes work (as well as before) but usually it'll freeze up; sometimes it'll freeze up and eat 100% CPU; sometimes it'll "quit unexpectedly".)
Created attachment 32412 [details] Docbook file mentioned in bug report
This happens because the sections don't have id attributes. Yelp doesn't know how to reference them, and gets horribly confused. I've been meaning to make Yelp generate id attributes when they don't exist. But that won't happen on the 2.6.x branch.
*** Bug 156021 has been marked as a duplicate of this bug. ***
Shaun: I've been looking at this. Can't we do some xpath right before the call to walker_walk_xml in yelp-db-pager.c:278 in HEAD? Essentially do something like the following: xmlstarlet sel -t -m 'not(/article/sect1/@id)' -v '.' -n doc.xml xmlstarlet sel -t -m 'not(/article/sect1/sect2/@id)' -v '.' -n doc.xml once we have the nodes that don't have id attributes, we can replace them in the true using xmlReplaceNode() I did something similar in yelp-toc-pager.c:776 where if the directory mtime has changed, then I reindex that directory and replace the node and write it to disk. What do you think?
actually the xpath would be the following so we are selecting the elements and not the attributes. /article/sect1[not(attribute::id)] /article/sect1/sect2[not(attribute::id)] The more I think about it, the easier it sounds. I'll try to cook up a patch.
Created attachment 56972 [details] [review] autogenerate id attributes when they don't exist When the id attribute isn't present on a chunkable element, it is autogenerated with a unique ID and inserted into the in-memory tree. Therefore, any links/references in the left pane table of contents should be valid. This patch has two xmlDocDump() calls to print the document to stdout before and after the modification so you can see the changes made. Also fixes the case where there is no id attribute on the root element node, (book|article). Previously this caused yelp to not be able to open the document at all. It ended up being much easier than I thought! Shaun, Don: comments?
Created attachment 56976 [details] [review] updated patch Updated patch to remove the xmlDocDump()s and append a _ to the beginning of the id value committed to head 2006-01-08 Brent Smith <gnome@nextreality.net> * src/yelp-db-pager.c: (db_pager_parse), (walker_walk_xml): Make yelp autogenerate ids when they are missing on chunkable elements, fixes #154934