Subject: [xml2rfc] Best way to quote regexps?

From: Paul Hoffman <[email-masked]>
Date: Thu, 23 May 2013 16:00:36 -0700

Greetings again. I am XMLizing an old RFC in preparation for it to become a -bis document. It has a regexp in it that is killing xml2rfc. I currently have:

<figure><artwork>
var my_JSON_object = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
       text.replace(/"(\\.|[^"\\])*"/g, ''))) &&
   eval('(' + text + ')');
</artwork></figure>

This reports:

Parsing file pre-bis.xml
ERROR: Unable to parse the XML document: pre-bis.xml
 pre-bis.xml: Line 377: xmlParseEntityRef: no name
xml2rfc returned 1

The line number is the second one in the regexp ("text.parse.."). xml2rfc is version 2.4.0. 

If I add in CDATA, it makes things weirder:

<figure><artwork><![CDATA[
var my_JSON_object = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
       text.replace(/"(\\.|[^"\\])*"/g, ''))) &&
   eval('(' + text + ')');
]]</artwork></figure>

This reports:

Parsing file pre-bis.xml
ERROR: Unable to parse the XML document: pre-bis.xml
 pre-bis.xml: Line 387: Extra content at the end of the document
xml2rfc returned 1

The line number reported is about seven after the block above. 

Clues (or even guesses) appreciated.

--Paul Hoffman

---

From: Paul Hoffman <[email-masked]>
Date: Thu, 23 May 2013 16:07:31 -0700

Never mind: I forgot about the ampersands. Solution: change "&" to "&amp;" twice. Sorry about the noise.

--Paul Hoffman

---

From: Scott Lawrence <[email-masked]>
Date: Fri, 24 May 2013 10:53:01 -0400

On 2013-05-23 19:00 , Paul Hoffman wrote:
> It has a regexp in it that is killing xml2rfc. I currently have:
>
> <figure><artwork>

Did you try replacing the '&&' in that with '&amp;&amp;' ?

I have no idea why the CDATA fix didn't work... I think it should have.