提交 369cdfa8 编写于 作者: E Eric Blake 提交者: Jiri Denemark

conf: set up for per-grammar overrides in schemas

This patch is my first experience playing with nested grammars,
as documented in http://relaxng.org/tutorial-20011203.html#IDA3PZR.
I plan on doing more overrides in order to make the RelaxNG
grammar mirror the C code refactoring into a common
virStorageSource, but where different clients of that source do
not support the same subset of functionality.  By starting with
something fairly easy to validate, I can make sure my later
patches will be possible.

This patch adds a use of the no-op <ref
name='sourceStartupPolicy'/> to the disksnapshot definition, so
that the snapshot version of a type='file' <source> more closely
resembles the version in domaincommon.  A future patch will merge
the two files into using a common define, but this patch is
sufficient for testing that adding <source
startupPolicy='optional'/> in any of the
tests/domainsnapshotxml2xmlin/*.xml files still gets rejected
unless it occurs within the <domain> subelement, because the
definition of startupPolicy is empty outside of domain.rng.

* docs/schemas/storagecommon.rng (storageStartupPolicy)
(storageSourceExtra): Create no-op defaults.
* docs/schemas/domainsnapshot.rng (domain): Use nested grammar
to avoid restricting <domain>.
(storageSourceExtra): Create new override.
(disksnapshot): Access overrides through common names.
* docs/schemas/domaincommon.rng (disk): Access overrides through
common names.
* docs/schemas/domain.rng (storageStartupPolicy)
(storageSourceExtra): Create new overrides.
Signed-off-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 db7d7c0e
<?xml version="1.0"?> <?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<!-- We handle only document defining a domain --> <!-- Grammar for accepting a domain element, both as top level, and
also suitable for inclusion in domainsnapshot.rng -->
<start> <start>
<ref name="domain"/> <ref name="domain"/>
</start> </start>
<include href='domaincommon.rng'/> <include href='domaincommon.rng'/>
<define name='storageStartupPolicy' combine='choice'>
<!-- overrides the no-op version in storagecommon.rng -->
<ref name='startupPolicy'/>
</define>
<define name='storageSourceExtra' combine='choice'>
<!-- overrides the no-op version in storagecommon.rng -->
<ref name='diskspec'/>
</define>
</grammar> </grammar>
...@@ -1213,7 +1213,7 @@ ...@@ -1213,7 +1213,7 @@
</attribute> </attribute>
</optional> </optional>
<optional> <optional>
<ref name="startupPolicy"/> <ref name="storageStartupPolicy"/>
</optional> </optional>
<optional> <optional>
<ref name='devSeclabel'/> <ref name='devSeclabel'/>
...@@ -1235,7 +1235,7 @@ ...@@ -1235,7 +1235,7 @@
</attribute> </attribute>
</optional> </optional>
<optional> <optional>
<ref name="startupPolicy"/> <ref name="storageStartupPolicy"/>
</optional> </optional>
<optional> <optional>
<ref name='devSeclabel'/> <ref name='devSeclabel'/>
...@@ -1255,7 +1255,7 @@ ...@@ -1255,7 +1255,7 @@
<ref name="absFilePath"/> <ref name="absFilePath"/>
</attribute> </attribute>
<optional> <optional>
<ref name="startupPolicy"/> <ref name="storageStartupPolicy"/>
</optional> </optional>
<empty/> <empty/>
</element> </element>
...@@ -1296,7 +1296,7 @@ ...@@ -1296,7 +1296,7 @@
</attribute> </attribute>
</optional> </optional>
<optional> <optional>
<ref name="startupPolicy"/> <ref name="storageStartupPolicy"/>
</optional> </optional>
<optional> <optional>
<ref name='devSeclabel'/> <ref name='devSeclabel'/>
...@@ -1306,10 +1306,11 @@ ...@@ -1306,10 +1306,11 @@
</interleave> </interleave>
</group> </group>
</choice> </choice>
<ref name="diskspec"/> <ref name="storageSourceExtra"/>
</interleave> </interleave>
</element> </element>
</define> </define>
<define name="diskSourceNetwork"> <define name="diskSourceNetwork">
<attribute name="protocol"> <attribute name="protocol">
<choice> <choice>
......
...@@ -75,7 +75,12 @@ ...@@ -75,7 +75,12 @@
<ref name="UUID"/> <ref name="UUID"/>
</element> </element>
</element> </element>
<ref name='domain'/> <!-- Nested grammar ensures that any of our overrides of
storagecommon/domaincommon defines do not conflict
with any domain.rng overrides. -->
<grammar>
<include href='domain.rng'/>
</grammar>
</choice> </choice>
</optional> </optional>
<optional> <optional>
...@@ -102,6 +107,11 @@ ...@@ -102,6 +107,11 @@
</choice> </choice>
</define> </define>
<define name='storageSourceExtra' combine='choice'>
<!-- overrides the no-op version in storagecommon.rng -->
<ref name='disksnapshotdriver'/>
</define>
<define name='disksnapshot'> <define name='disksnapshot'>
<element name='disk'> <element name='disk'>
<attribute name='name'> <attribute name='name'>
...@@ -138,10 +148,13 @@ ...@@ -138,10 +148,13 @@
<ref name='absFilePath'/> <ref name='absFilePath'/>
</attribute> </attribute>
</optional> </optional>
<optional>
<ref name='storageStartupPolicy'/>
</optional>
<empty/> <empty/>
</element> </element>
</optional> </optional>
<ref name='disksnapshotdriver'/> <ref name='storageSourceExtra'/>
</interleave> </interleave>
</group> </group>
<group> <group>
...@@ -157,7 +170,7 @@ ...@@ -157,7 +170,7 @@
<empty/> <empty/>
</element> </element>
</optional> </optional>
<ref name='disksnapshotdriver'/> <ref name='storageSourceExtra'/>
</interleave> </interleave>
</group> </group>
<group> <group>
...@@ -170,7 +183,7 @@ ...@@ -170,7 +183,7 @@
<ref name='diskSourceNetwork'/> <ref name='diskSourceNetwork'/>
</element> </element>
</optional> </optional>
<ref name='disksnapshotdriver'/> <ref name='storageSourceExtra'/>
</interleave> </interleave>
</group> </group>
</choice> </choice>
......
...@@ -79,4 +79,18 @@ ...@@ -79,4 +79,18 @@
</choice> </choice>
</define> </define>
<define name='storageStartupPolicy'>
<!-- Use a combine='choice' override in client files that want to
add additional attributes to a <source> sub-element
associated with a storage source -->
<notAllowed/>
</define>
<define name='storageSourceExtra'>
<!-- Use a combine='choice' override in client files that want to
add additional elements as siblings of a <source> sub-element
associated with a storage source -->
<notAllowed/>
</define>
</grammar> </grammar>
<domainsnapshot>
<name>asdf</name>
<description>adsf</description>
<disks>
<disk name='vda' snapshot='external'>
<source file='/tmp/foo' startupPolicy='optional'/>
<driver/>
</disk>
</disks>
</domainsnapshot>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册