On 12/05/2011 02:48 PM, 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.
[1]
http://www.w3.org/TR/xml11/#NT-Reference
Mechanical conversion done with:
$ find -name '*.xml' | \
xargs sed -i
's/\([a-zA-Z0-9_]*=\)"\([^"]*\)"/\1'\''\2'\''/g'
followed by inspecting the results, and touching up the change
in tests/xml2sexprdata/xml2sexpr-escape.xml to fix 'make check'.
* cfg.mk (sc_rng_quote_style): Enforce the rule.
* examples/xml/storage/*.xml: Fix fallout.
* examples/xml/test/*.xml: Likewise.
* python/libvirt-*override-api.xml: Likewise.
* src/network/default.xml: Likewise.
* tests/*/*.xml: Likewise.
I also meant to say:
Proposed for post-0.9.8 (no need for this much churn pre-release). Also,
+# In xml files, prefer name='abc' over name="abc"
+sc_rng_quote_style:
+ @prohibit='\b[-a-zA-Z0-9_]+="' \
+ in_vc_files='\.(xml)$$' \
+ halt='use name='\'val\'', not name="val", in xml' \
+ $(_sc_search_regexp)
This rule is poorly named; it should be sc_xml_quote_style.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org