attribute value quoting bug in Trang?

James Miller <[email protected]>
Newsgroups gmane.text.xml.relaxng.general
Message-ID <[email protected]>
Hi,

I typed in the example of annotations in the compact syntax on pages 218
and 219 of Eric van der Vlist's _RELAX NG_ book and ran trang-20030619
on it to see the XML syntax equivalent (which appears on page 218,
BTW).  The .rng output was not well-formed XML because of a badly quoted
attribute value.

The relevant part of the .rnc input is right near its start:

  namespace ann = "http://dyomedea.com/examples/ns/annotations"

  [
     ann:attribute = 'Annotation as foreign attribute for "grammar"'
     ann:element [ 'Initial annotation as foreign element for "grammar"' ]
  ]
  grammar {
  # ...

Note that the ann:attribute attribute's value is delimited by single
quotes and contains double quotes.

Here's the beginning of the corresponding .rng output:

  <?xml version="1.0" encoding="UTF-8"?>
  <grammar ann:attribute="Annotation as foreign attribute for "grammar""
           xmlns:ann="http://dyomedea.com/examples/ns/annotations"
           xmlns="http://relaxng.org/ns/structure/1.0">
    <ann:element>Initial annotation as foreign element for "grammar"</ann:element>

Whoops -- the value of the ann:attribute attribute is now delimited by
double quotes, but still also contains raw double quotes (as opposed to,
say, ``&quot;'' character entity references).

This behavior might be a result of some code in
com/thaiopensource/relaxng/output/common/XmlWriter.java,

  public void attribute(String name, String value) {
    if (!inStartTag)
      throw new IllegalStateException("attribute outside of start-tag");
    write(' ');
    write(name);
    write('=');
    write('"');
    data(value);
    write('"');
  }

which isn't doing anything to ``escape double quotes'' in the value its
given.


  -James Miller
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.