Verify that resources have xml:id
Add validation check for WADL files to ensure they contain an xml:id at the parent resources. This is a new requirement that has to do with the generation of PDFs from WADL files – without this, the paths are not unique across WADL files. Change-Id: Id43470e0930a3a447f1e7ab63e956541984bce0e Closes-Bug: #1275007
This commit is contained in:
parent
0863f76f20
commit
2e87f67324
|
@ -68,7 +68,8 @@ Release notes
|
|||
0.5
|
||||
---
|
||||
|
||||
* Improve formatting of python command line clients
|
||||
* Test that resources in wadl files have an xml:id (lp:bug 1275007)
|
||||
* Improve formatting of python command line clients (lp:bug 1274699)
|
||||
|
||||
0.4
|
||||
---
|
||||
|
|
|
@ -146,6 +146,18 @@ def verify_section_tags_have_xmid(doc):
|
|||
node.sourceline)
|
||||
|
||||
|
||||
def verify_resources_tags_have_xmid(doc):
|
||||
"""Check that all resources tags have an xml:id attribute
|
||||
|
||||
Will throw an exception if there's at least one missing.
|
||||
"""
|
||||
ns = {"wadl": "http://wadl.dev.java.net/2009/02"}
|
||||
for node in doc.xpath('//wadl:resources', namespaces=ns):
|
||||
if "{http://www.w3.org/XML/1998/namespace}id" not in node.attrib:
|
||||
raise ValueError("resources missing xml:id attribute, line %d" %
|
||||
node.sourceline)
|
||||
|
||||
|
||||
def verify_attribute_profiling(doc, attribute, known_values):
|
||||
"""Check for elements with attribute profiling set that conflicts with
|
||||
the attribute profiling of nodes below them in the DOM
|
||||
|
@ -433,6 +445,8 @@ def validate_one_file(schema, rootdir, path, verbose,
|
|||
if validation_failed(schema, doc):
|
||||
any_failures = True
|
||||
print(error_message(schema.error_log))
|
||||
if is_wadl(path):
|
||||
verify_resources_tags_have_xmid(doc)
|
||||
verify_section_tags_have_xmid(doc)
|
||||
verify_profiling(doc)
|
||||
if check_niceness:
|
||||
|
|
Loading…
Reference in New Issue