[PATCH 0/2] Recipe xml validation

Jan Tluka jtluka at redhat.com
Thu May 16 14:16:51 UTC 2013


Attached is my RelaxNG schema ... it may seem a bit awkward but it worked
for me. Please consider it "under construction" ...

I attached a standalone validator I was using during testing the schema.

Usage:
./recipe_validator_rng.py $relaxng_schema_file $lnst_recipe_file

Thu, May 16, 2013 at 04:00:18PM CEST, olichtne at redhat.com wrote:
>We can definitely postpone, I posted this patch because I didn't see any
>replies to my previous email that contained the first schema I create. I
>therefore assumed that I didn't accidentally forgot anything, turns out
>I did... sorry about that.
>
>I agree with having the schema validation as optional or even as a
>standalone app. Adding the define tag could be troublesome as it can
>appear anywhere. The same goes for the source attribute.
>
>-Ondrej
>
>On Thu, May 16, 2013 at 03:39:10PM +0200, Jan Tluka wrote:
>> Hi, I have doubts about including this patch as I'm afraid it would
>> break running of recipes that have <define> tag in it. The schemes
>> posted in patch do not deal with this tag so any recipe that contains
>> the tag won't be processed.
>> 
>> I'm currently working on another schema for validation. I was digging into
>> RelaxNG a bit and I found it more flexible with respect of ordering of
>> tags.
>> 
>> I'm proposing some of the following
>> 1. make validation optional or provide a way to disable validation
>> 2. add <define> in the schema
>> 3. implement validator as a standalone app
>> 
>> I think the schema also misses 'source' attribute. Could we postpone
>> the second patch until the scheme is checked by users for any possible
>> issues?
>> 
>> -Jan
>> 
>> Thu, May 16, 2013 at 03:22:52PM CEST, olichtne at redhat.com wrote:
>> >From: Ondrej Lichtner <olichtne at redhat.com>
>> >
>> >The following two patches add files required for recipe validation and
>> >impplement a basic form of validation with the XML Schema file provided. At the
>> >moment the validation relies on the schema file to be in the same directory as
>> >the lnst-ctl script. In the future this should be changed to a more
>> >standardized location.
>> >
>> >At the moment though this should be sufficient to try out the validation, it
>> >reflects the currently accepted recipe format so it can help with changing your
>> >older recipes to the new format.
>> >
>> >Ondrej Lichtner (2):
>> >  add recipe.xsd and recipe.dtd
>> >  lnst-ctl: add recipe validation
>> >
>> > lnst-ctl   |  22 +++++++
>> > recipe.dtd |  56 ++++++++++++++++++
>> > recipe.xsd | 196 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> > 3 files changed, 274 insertions(+)
>> > create mode 100644 recipe.dtd
>> > create mode 100644 recipe.xsd
>> >
>> >-- 
>> >1.7.11.7
>> >
>> >_______________________________________________
>> >LNST-developers mailing list
>> >LNST-developers at lists.fedorahosted.org
>> >https://lists.fedorahosted.org/mailman/listinfo/lnst-developers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: recipe-schema.rng
Type: text/xml
Size: 5146 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/lnst-developers/attachments/20130516/f03b16b0/attachment.xml>
-------------- next part --------------
#!/usr/bin/python

from lxml import etree
import sys

f = sys.argv[1]

relaxng_doc = etree.parse(f)
relaxng = etree.RelaxNG(relaxng_doc)

valid = sys.argv[2]
doc = etree.parse(valid)

try:
    relaxng.assertValid(doc)
except:
    log = relaxng.error_log
    error = log.last_error
    print log
    print error
    print(error.domain_name)
    print(error.type_name)
    sys.exit(1)

sys.exit(0)



More information about the LNST-developers mailing list