On Mon, Dec 05, 2011 at 02:48:30PM -0700, Eric Blake wrote:
According to the official XML specification [1], attributes
can be specified with either ' or " (where the difference is
that you can use '"' or '"' but must use
""",
and conversely for "'" or "'" vs. ''').
But our
code generation in src/conf prefers to output the '' notation,
as it is easier to write C string literals for that style.
Using a consistent style throughout libvirt will make it
easier for users to copy-and-paste without wondering why we
switch quoting styles mid-stream.
[...]
diff --git a/tests/xml2sexprdata/xml2sexpr-escape.xml
b/tests/xml2sexprdata/xml2sexpr-escape.xml
index 6eed578..bca2c81 100644
--- a/tests/xml2sexprdata/xml2sexpr-escape.xml
+++ b/tests/xml2sexprdata/xml2sexpr-escape.xml
@@ -5,7 +5,7 @@
<type>hvm</type>
<kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
<initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
- <cmdline>
method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test...
</cmdline>
+ <cmdline>
method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test...
</cmdline>
<loader>/usr/lib/xen/boot/hvmloader</loader>
Actually I dislike for this kind of things. It's semantically
equivalent, and I don't think we should try to enforce arbitrary
requirements which are not needed. This is actually more confusing
for people who do know the XML spec,
"why isn't my example good"
it actually is! The choice of quotes is on purpose to allow easy
serialization when you have ' or " in an attribute value. Requiring
the user to escape is kind of wrong IMHO.
Also the automatic rule won't be able to distinguish " and " within
attribute text content from those within element text content, and
we certainly don't want to make a simili parser in perl or regexps.
Also if someone uses an XML editor on one of our fragment it's very
likely that the ' will be turned into " because the distinction is not
part of the XML infoset (i.e. the amount of data an XML parser should
report to the application) and the tool will serialize back using
his own preferences, and that's just fine.
I think the inconvenients in that case are not worth the possible
improvement.
Danil
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/