After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 154934 - Yelp gets confused without id attributes
Yelp gets confused without id attributes
Status: RESOLVED FIXED
Product: yelp
Classification: Applications
Component: General
2.13.x
Other Linux
: High critical
: ---
Assigned To: Shaun McCance
Yelp maintainers
: 156021 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-10-08 20:28 UTC by Ken Harris
Modified: 2009-09-22 01:48 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
Docbook file mentioned in bug report (2.04 KB, text/plain)
2004-10-08 20:30 UTC, Ken Harris
  Details
autogenerate id attributes when they don't exist (2.20 KB, patch)
2006-01-08 16:03 UTC, Brent Smith (smitten)
none Details | Review
updated patch (47 bytes, patch)
2006-01-08 18:04 UTC, Brent Smith (smitten)
committed Details | Review

Description Ken Harris 2004-10-08 20:28:25 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".)
Comment 1 Ken Harris 2004-10-08 20:30:09 UTC
Created attachment 32412 [details]
Docbook file mentioned in bug report
Comment 2 Shaun McCance 2004-10-08 21:29:16 UTC
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.
Comment 3 Don Scorgie 2004-11-20 16:40:56 UTC
*** Bug 156021 has been marked as a duplicate of this bug. ***
Comment 4 Brent Smith (smitten) 2006-01-08 05:29:29 UTC
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?
Comment 5 Brent Smith (smitten) 2006-01-08 05:34:29 UTC
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.
Comment 6 Brent Smith (smitten) 2006-01-08 16:03:00 UTC
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?
Comment 7 Brent Smith (smitten) 2006-01-08 18:04:21 UTC
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