Subject: wrong assumptions on PIs cause TDG processing to fail

From: Yann Dirson <[email-masked]>
Date: Sun, 30 Mar 2003 23:28:42 +0200

Package: docbook-dsssl
Version: 1.78-3
Severity: important

As of 2.0.8, TDG includes PIs such as:

<?ORA last-page-blank?>

where the PI parameters are not of the form name="value"

The following clearly fails on such PI parameters, as string-index
returns -1:

(define (parse-pi-attribute pivalues #!optional (skip #f))
  (let* ((equalpos (string-index pivalues "="))
         (name     (substring pivalues 0 equalpos))
         (quotchar (substring pivalues (+ equalpos 1) (+ equalpos 2)))
         (rest     (substring pivalues 
                              (+ equalpos 2) 
                              (string-length pivalues)))
         (quotpos  (string-index rest quotchar))
         (value    (substring rest 0 quotpos))
         (morevals (strip (substring rest 
                                     (+ quotpos 1) 
                                     (string-length rest)))))
    (if skip
        morevals
        (list name value))))

I originally thought to try fixing this code (and may do that anyway),
but was puzzled by another assumption, namely that the 1st char
following the = sign should be a quote.  Not knowing whether that's
correct as well, I prefered to use a stub returning an empty list
instead, by adding the following to my customisation layer:

;; attempt to workaround bug in docbook-dsssl 1.78 
(define (parse-pi-attribute pivalues #!optional (skip #f))  
  '()) 

Unfortunately this has no effect, and TDG processing fails with the
same error messages refering to the original defn:

openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/lib/dblib.dsl:1796:12:E: argument out of range

I suspect this new problem would be a bug in openjade, as it violates
my understanding of the DSSSL standard (section 7.1).  I'll do more
tests with a modified version of docbook-dsssl to work around htis.

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux bylbo 2.4.19+mppe-k6 #1 SMP Fri Nov 15 20:50:49 CET 2002 i586
Locale: LANG=français, LC_CTYPE=français

Versions of packages docbook-dsssl depends on:
ii  debconf                      1.2.34      Debian configuration management sy
ii  docbook                      4.2-3       standard SGML representation syste
ii  jade                         1.2.1-29.1  James Clark's DSSSL Engine
ii  openjade                     1.4devel1-8 Implementation of the DSSSL langua
ii  perl                         5.8.0-17    Larry Wall's Practical Extraction 
ii  sgml-base                    1.17        utilities to maintain SGML catalog
ii  sgml-data                    1.9.1       Common SGML and XML DTDs and entit

-- debconf information:
* docbook-dsssl/visual-acuity: normal
* docbook-dsssl/html-ext: .html
* docbook-dsssl/set-papersize: do not set
* docbook-dsssl/title-font-family: %body-font-family%
* docbook-dsssl/show-comments: true
* docbook-dsssl/body-start-indent: false
* docbook-dsssl/use-id-as-filename: true

-- 
Yann Dirson    <[email-masked]> |    Why make M$-Bill richer & richer ?
Debian-related: <[email-masked]> |   Support Debian GNU/Linux:
Pro:    <[email-masked]> |  Freedom, Power, Stability, Gratuity
     http://ydirson.free.fr/        | Check <http://www.debian.org/>

---

From: Adam DiCarlo <[email-masked]>
Date: 30 Mar 2003 17:53:15 -0600

I don't clearly understand what the bug is.  Can you give me a docbook
XML file that is small and shows the behavior that should work but
doesn't?

-- 
.....Adam Di [email-masked].....<URL:http://www.debian.org/>

---

From: Yann Dirson <[email-masked]>
Date: Thu, 3 Apr 2003 16:10:59 +0200

On Sun, Mar 30, 2003 at 05:53:15PM -0600, Adam DiCarlo wrote:
> I don't clearly understand what the bug is.

It is somewhat explained in the code itself:

  ;; REFENTRY parse-starttag-pi
  ;; PURP Parses a structured PI and returns a list of values
  ;; DESC
  ;; It has become common practice to give PIs structured values.  The
  ;; resultis a PI that looks a lot like a start tag with attributes:
  ;;
  ;; &#60;?pitarget name1="value1" name2='value2' name3="value '3'">
  ;; 
  ;; This function parses a PI with this form and returns a list. The
  ;; list contains the pitarget and each of the name/value pairs:
  ;;
  ;; ("pitarget" "name1" "value1" "name2" "value2" "name3" "value '3'")

As explained in the original bugreport, one of the support functions
for this functionality does not look generic enough to cope with more
general PIs.

> Can you give me a docbook XML file that is small and shows the
> behavior that should work but doesn't?

I tried to make a couple of simples doc with the PI that appears to
cause problem in TDG, but they all processed fine.  I'll have to hunt
to find in which conditions PI processing gets triggered.

In the meantime you can fetch docbook-defguide_2.0.8 (in incoming) and
comment out the workaround at the end of ./defguide.dsl.  On a K6-II
350 it takes less a little more than 10 minutes to get the 1st error
messages:

cd en && docbook-2-html -O -G -O -Vhtml-index -O -D`pwd` --style local=../defguide.dsl book.xml
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/lib/dblib.dsl:1796:12:E: argument out of range
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/lib/dblib.dsl:1811:2:I: called from here
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/lib/dblib.dsl:1839:8:I: called from here
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/lib/dblib.dsl:1839:2:I: called from here
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/lib/dblib.dsl:1836:4:I: called from here
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/dbpi.dsl:46:6:I: called from here...(5 calls omitted)
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/dbchunk.dsl:148:2:I: called from here
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/dbchunk.dsl:192:5:I: called from here
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/dbchunk.dsl:234:17:I: called from here
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/dbchunk.dsl:249:12:I: called from here
openjade1.3:/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/dbautoc.dsl:32:11:I: called from here