Subject: Re: [xml2rfc] Question about “tocInclude” in xml2rfc

From: Stuart Cheshire <[email-masked]>
Date: Wed, 03 Mar 2021 21:02:54 -0800

I may have just found the solution myself.

The error message said “object has no attribute ‘xpath’ in add_pageno_placeholders.”

I added a single “if” statement so that it doesn’t try to get toc.xpath for a document that has no TOC. That seemed to fix it.

  % diff -u text-orig.py text.py   
  --- text-orig.py    2021-03-03 19:58:39.000000000 -0800
  +++ text.py         2021-03-03 20:50:34.000000000 -0800
  @@ -369,8 +369,9 @@

       def add_pageno_placeholders(self):
           toc = self.root.find('./front/toc/section')
  -        for e in toc.xpath('.//xref[2]'):
  -            e.set('pageno', '0000')
  +        if toc:
  +            for e in toc.xpath('.//xref[2]'):
  +                e.set('pageno', '0000')

       def paginate(self, lines):
           """

Stuart Cheshire

---

From: Julian Reschke <[email-masked]>
Date: Thu, 4 Mar 2021 08:46:18 +0100

>    +++ text.py         2021-03-03 20:50:34.000000000 -0800

-> <https://trac.tools.ietf.org/tools/xml2rfc/trac/newticket>

Best regards, Julian

---

From: Stuart Cheshire <[email-masked]>
Date: Thu, 04 Mar 2021 00:32:17 -0800

> -> <https://trac.tools.ietf.org/tools/xml2rfc/trac/newticket>

Thanks.

<https://trac.tools.ietf.org/tools/xml2rfc/trac/ticket/604>

Stuart Cheshire