GNOME Bugzilla – Bug 319705
gnome-doc-utils should valid OMF categories
Last modified: 2006-11-08 15:06:56 UTC
gnome-doc-utils should yell and scream and whinge and yell and, well, something like that... when the category in OMF files is not set to something out of the controlled list. The list is at http://scrollkeeper.sourceforge.net/documentation/categories.html
Here's a rough attempt that could probably be cleaned up into something good: @subjects=`echo \ '<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" ' \ 'xmlns:str="http://exslt.org/strings" version="1.0" ' \ 'extension-element-prefixes="str"><output method="text"/>' \ '<template match="/"><for-each select="//subject/@category">' \ '<for-each select="str:tokenize(.)"><value-of select="."/>' \ '<if test="position() != last()"><text>_</text></if></for-each>' \ '<text> </text></for-each></template></stylesheet>' \ | xsltproc - $(_DOC_OMF_IN)`; \ for subject in $$subjects; do \ code=`echo $$subject | sed -e 's/|//g' -e 's/_/ /g'`; \ valid=`echo \ '<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" ' \ 'version="1.0"><output method="text"/><template match="/">' \ '<if test="//sect[@categorycode='"'$$code'"']">1</if>' \ '</template></stylesheet>' | xsltproc - \ /usr/share/scrollkeeper/Templates/C/scrollkeeper_cl.xml`; \ if [ "x$$valid" != "x1" ]; then \ echo -n "Invalid OMF category code: "; \ echo $$subject | sed -e 's/_/ /g'; \ exit 1; \ fi; \ done; This would be put in the rule for building $(_DOC_OMF_DB). There are a few issues with this: 1) I hard-coded the path to scrollkeeper_cl.xml. 2) I don't think the echo/exit business is the proper way to handle the error. 3) This will wrong for each OMF file we build, as in once for each language. I suppose we could just let that happen, and maybe even make each language OMF check against the appropriate language's scrollkeeper_cl.xml file. But if there's actually a difference in codes between languages, we've got more serious problems. Since we're just verifying an input file (the .omf.in file), we don't really need to check it for every output file it makes. I suppose an easy solution is just to wrap the whole check in a conditional that checks if we're outputting the C OMF file. (Yeah, the inline XSLT makes me cringe too. But I'm not allowed to use XML Starlet here.)
Under point (3), s/This will wrong/This will run/
On point (1): `scrollkeeper-config --pkgdatadir`/Templates/C/scrollkeeper_cl.xml That'll give us the file less stupidly.
I did this in db2omf.xsl instead.