From d6e3621d7cb2664b92edc3653823d56cfe4b719b Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Fri, 15 Nov 2024 14:46:06 +0000 Subject: [PATCH 01/15] First draft WIP XSD --- xml-schemas/dapt-all.xsd | 18 + xml-schemas/dapt-datatypes.xsd | 23 + xml-schemas/dapt-metadata.xsd | 40 ++ xml-schemas/dapt.xsd | 41 ++ xml-schemas/ttml2-animation.xsd | 58 ++ xml-schemas/ttml2-audio-attribs.xsd | 19 + xml-schemas/ttml2-content.xsd | 137 ++++ xml-schemas/ttml2-core-attribs.xsd | 27 + xml-schemas/ttml2-datatypes.xsd | 803 ++++++++++++++++++++++++ xml-schemas/ttml2-embedded.xsd | 163 +++++ xml-schemas/ttml2-head.xsd | 27 + xml-schemas/ttml2-metadata-attribs.xsd | 14 + xml-schemas/ttml2-metadata-items.xsd | 92 +++ xml-schemas/ttml2-metadata.xsd | 31 + xml-schemas/ttml2-parameter-attribs.xsd | 46 ++ xml-schemas/ttml2-parameter-items.xsd | 97 +++ xml-schemas/ttml2-parameters.xsd | 14 + xml-schemas/ttml2-styling-attribs.xsd | 114 ++++ xml-schemas/ttml2-styling.xsd | 62 ++ xml-schemas/ttml2-timing-attribs.xsd | 19 + xml-schemas/xlink.xsd | 270 ++++++++ xml-schemas/xml.xsd | 216 +++++++ 22 files changed, 2331 insertions(+) create mode 100644 xml-schemas/dapt-all.xsd create mode 100644 xml-schemas/dapt-datatypes.xsd create mode 100644 xml-schemas/dapt-metadata.xsd create mode 100644 xml-schemas/dapt.xsd create mode 100644 xml-schemas/ttml2-animation.xsd create mode 100644 xml-schemas/ttml2-audio-attribs.xsd create mode 100644 xml-schemas/ttml2-content.xsd create mode 100644 xml-schemas/ttml2-core-attribs.xsd create mode 100644 xml-schemas/ttml2-datatypes.xsd create mode 100644 xml-schemas/ttml2-embedded.xsd create mode 100644 xml-schemas/ttml2-head.xsd create mode 100644 xml-schemas/ttml2-metadata-attribs.xsd create mode 100644 xml-schemas/ttml2-metadata-items.xsd create mode 100644 xml-schemas/ttml2-metadata.xsd create mode 100644 xml-schemas/ttml2-parameter-attribs.xsd create mode 100755 xml-schemas/ttml2-parameter-items.xsd create mode 100755 xml-schemas/ttml2-parameters.xsd create mode 100644 xml-schemas/ttml2-styling-attribs.xsd create mode 100644 xml-schemas/ttml2-styling.xsd create mode 100644 xml-schemas/ttml2-timing-attribs.xsd create mode 100644 xml-schemas/xlink.xsd create mode 100644 xml-schemas/xml.xsd diff --git a/xml-schemas/dapt-all.xsd b/xml-schemas/dapt-all.xsd new file mode 100644 index 0000000..bf81711 --- /dev/null +++ b/xml-schemas/dapt-all.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/dapt-datatypes.xsd b/xml-schemas/dapt-datatypes.xsd new file mode 100644 index 0000000..67aa1d1 --- /dev/null +++ b/xml-schemas/dapt-datatypes.xsd @@ -0,0 +1,23 @@ + + + + + + descriptor-token ( descriptor-delimiter descriptor-token )* + + descriptor-token + : (descriptorTokenChar)+ + + descriptorTokenChar # xsd:NMtoken without the "." + : NameStartChar | "-" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] + + descriptor-delimiter + : "." # FULL STOP U+002E + + + + + + diff --git a/xml-schemas/dapt-metadata.xsd b/xml-schemas/dapt-metadata.xsd new file mode 100644 index 0000000..3f0d0fe --- /dev/null +++ b/xml-schemas/dapt-metadata.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/dapt.xsd b/xml-schemas/dapt.xsd new file mode 100644 index 0000000..5df5ff7 --- /dev/null +++ b/xml-schemas/dapt.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-animation.xsd b/xml-schemas/ttml2-animation.xsd new file mode 100644 index 0000000..4619cf2 --- /dev/null +++ b/xml-schemas/ttml2-animation.xsd @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-audio-attribs.xsd b/xml-schemas/ttml2-audio-attribs.xsd new file mode 100644 index 0000000..587096c --- /dev/null +++ b/xml-schemas/ttml2-audio-attribs.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-content.xsd b/xml-schemas/ttml2-content.xsd new file mode 100644 index 0000000..103784c --- /dev/null +++ b/xml-schemas/ttml2-content.xsd @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-core-attribs.xsd b/xml-schemas/ttml2-core-attribs.xsd new file mode 100644 index 0000000..bc9ab35 --- /dev/null +++ b/xml-schemas/ttml2-core-attribs.xsd @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-datatypes.xsd b/xml-schemas/ttml2-datatypes.xsd new file mode 100644 index 0000000..f872dcb --- /dev/null +++ b/xml-schemas/ttml2-datatypes.xsd @@ -0,0 +1,803 @@ + + + + + + + + + + + + + + animationValue [ ";" animationValue ]* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [ borderThickness || borderStyle || borderColor ] + + + + + + + + + + + + + + non-negative-integer non-negative-integer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + non-negative-integer + + + + + + + + + + + + + + + + + + + + length + + + + + + + + + + + + + + + + + + + + + non-negative-integer non-negative-integer + + + + + + + + + + + + + + + + + + + + + + auto | contain | cover | measure measure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + length | length length + + + + + + + + + + + + + normal | [ super | sub ] || [ full | half ] || ruby + + + + + + + + + + + + + fragmentIdentifier + : "#" fragment + + fragment + : uric+ + + uric + : reserved + | unreserved + | escaped + + reserved + : [;/?:@&=+$,] + + unreserved + : [a-zA-Z] + | [0-9] + | [-_.!~*'()] + + escaped + : "%" hex hex + + hex + : [0-9a-fA-F] + + + + + + + non-negative-integer + + + + + + + + non-negative-integer non-negative-integer + + + + + + + + number + + + + + + + + + + + + + + + + + + + keySplines + : control [ lwsp? ";" lwsp? control ]* + + control + : x1 comma? y1 comma? x2 comma? y2 + + x1, x2, y1, y2 + : coordinate + + coordinate // 0 ≥ value ≥ 1 + : whole + | whole "." fraction + | "." fraction + + whole, fraction + : non-negative-integer + + comma + : "," + + lwsp + : ( ' ' | '\t' | '\n' | '\r' )+ + + + + + + + + keyTimes + : time [ lwsp? ";" lwsp? time ]* + + time // 0 ≥ value ≥ 1 + : whole + | whole "." fraction + | "." fraction + + whole, fraction + : non-negative-integer + + lwsp + : ( ' ' | '\t' | '\n' | '\r' )+ + + + + + + + normal | length + + + + + + normal | length + + + + + + string + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + alpha + + + + + + auto | length length + + + + + + + + + + + + length length | length length length | length length length length + + + + + + number + + + + + + + + + + pitch + : percentage + | number pitch-units? + + pitch-units + : "hz" | "st" + + + + + + + non-negative-integer non-negative-integer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + repeatCount + : count // value > 0 + | "indefinite" + + count: + : whole + | whole "." fraction + | "." fraction + + whole, fraction + : non-negative-integer + + + + + + + + + + + + + + + + + metadataRoleBaseType | "x-"string + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + percentage + + + + + + + + + + + + non-negative-integer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + none | [ [ underline | noUnderline ] || [ lineThrough | noLineThrough ] || [ overline | noOverline ] ] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [ emphasisStyle || emphasisColor || emphasisPosition ] + + + + + + + + + + + + + none | length | length length | color length | color length length + + + + + + none | ( shadow )+ + + + + + + non-negative-integer + + + + + + + + + + + + + timeExpression + + + + + + timeExpression + + + + + + + + + + + + + + + + + + + + + + + + + + + + + non-negative-integer // value > 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + auto | integer + + + + diff --git a/xml-schemas/ttml2-embedded.xsd b/xml-schemas/ttml2-embedded.xsd new file mode 100644 index 0000000..d0fb705 --- /dev/null +++ b/xml-schemas/ttml2-embedded.xsd @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #PCDATA | (Metadata.class*) | (Metadata.class*, chunk+) | (Metadata.class*, source+) + The following is an over-generalization of the above content model. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-head.xsd b/xml-schemas/ttml2-head.xsd new file mode 100644 index 0000000..b30caf8 --- /dev/null +++ b/xml-schemas/ttml2-head.xsd @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-metadata-attribs.xsd b/xml-schemas/ttml2-metadata-attribs.xsd new file mode 100644 index 0000000..07cfe0b --- /dev/null +++ b/xml-schemas/ttml2-metadata-attribs.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/xml-schemas/ttml2-metadata-items.xsd b/xml-schemas/ttml2-metadata-items.xsd new file mode 100644 index 0000000..f568651 --- /dev/null +++ b/xml-schemas/ttml2-metadata-items.xsd @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-metadata.xsd b/xml-schemas/ttml2-metadata.xsd new file mode 100644 index 0000000..ba055cd --- /dev/null +++ b/xml-schemas/ttml2-metadata.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-parameter-attribs.xsd b/xml-schemas/ttml2-parameter-attribs.xsd new file mode 100644 index 0000000..ece3bf7 --- /dev/null +++ b/xml-schemas/ttml2-parameter-attribs.xsd @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-parameter-items.xsd b/xml-schemas/ttml2-parameter-items.xsd new file mode 100755 index 0000000..76e7fbf --- /dev/null +++ b/xml-schemas/ttml2-parameter-items.xsd @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-parameters.xsd b/xml-schemas/ttml2-parameters.xsd new file mode 100755 index 0000000..b8e0538 --- /dev/null +++ b/xml-schemas/ttml2-parameters.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/xml-schemas/ttml2-styling-attribs.xsd b/xml-schemas/ttml2-styling-attribs.xsd new file mode 100644 index 0000000..3feb2c1 --- /dev/null +++ b/xml-schemas/ttml2-styling-attribs.xsd @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-styling.xsd b/xml-schemas/ttml2-styling.xsd new file mode 100644 index 0000000..8fb28ea --- /dev/null +++ b/xml-schemas/ttml2-styling.xsd @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-timing-attribs.xsd b/xml-schemas/ttml2-timing-attribs.xsd new file mode 100644 index 0000000..cd9a34b --- /dev/null +++ b/xml-schemas/ttml2-timing-attribs.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/xml-schemas/xlink.xsd b/xml-schemas/xlink.xsd new file mode 100644 index 0000000..bfd01f9 --- /dev/null +++ b/xml-schemas/xlink.xsd @@ -0,0 +1,270 @@ + + + + + This schema document provides attribute declarations and + attribute group, complex type and simple type definitions which can be used in + the construction of user schemas to define the structure of particular linking + constructs, e.g. + + + + + + + ... + + ... + + + ... +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Intended for use as the type of user-declared elements to make them + simple links. + + + + + + + + + + + + + + + + + + + + + + + + + Intended for use as the type of user-declared elements to make them + extended links. + Note that the elements referenced in the content model are all abstract. + The intention is that by simply declaring elements with these as their + substitutionGroup, all the right things will happen. + + + + + + + + + + + + + + xml:lang is not required, but provides much of the + motivation for title elements in addition to attributes, and so + is provided here for convenience. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + label is not required, but locators have no particular + XLink function if they are not labeled. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + from and to have default behavior when values are missing + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/xml.xsd b/xml-schemas/xml.xsd new file mode 100644 index 0000000..f3c7201 --- /dev/null +++ b/xml-schemas/xml.xsd @@ -0,0 +1,216 @@ + + + + +
+

About the XML namespace

+
+

This schema document describes the XML namespace, in a form suitable for + import by other schema documents.

+

See + http://www.w3.org/XML/1998/namespace.html and http://www.w3.org/TR/REC-xml + for information about this namespace.

+

Note that local names in this namespace are intended to be defined only by + the World Wide Web Consortium or its subgroups. The names currently defined + in this namespace are listed below. They should not be used with conflicting + semantics by any Working Group, specification, or document instance.

+

See further below in this document for more information about how to refer to this schema document from your own XSD + schema documents and about the + namespace-versioning policy governing this schema document.

+
+
+
+
+ + + +
+

lang (as an attribute name)

+

denotes an attribute whose value is a language code for the natural language + of the content of any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification.

+
+
+

Notes

+

Attempting to install the relevant ISO 2- and 3-letter codes as the + enumerated possible values is probably never going to be a realistic + possibility.

+

See BCP 47 at + http://www.rfc-editor.org/rfc/bcp/bcp47.txt and the IANA language + subtag registry at + http://www.iana.org/assignments/language-subtag-registry for further + information.

+

The union allows for the 'un-declaration' of xml:lang with the empty string. +

+
+
+
+ + + + + + + + + +
+ + + +
+

space (as an attribute name)

+

denotes an attribute whose value is a keyword indicating what whitespace + processing discipline is intended for the content of the element; its value + is inherited. This name is reserved by virtue of its definition in the XML + specification.

+
+
+
+ + + + + + +
+ + + +
+

base (as an attribute name)

+

denotes an attribute whose value provides a URI to be used as the base for + interpreting any relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved by virtue of its + definition in the XML Base specification.

+

See http://www.w3.org/TR/xmlbase/ for information about this attribute. +

+
+
+
+
+ + + +
+

id (as an attribute name)

+

denotes an attribute whose value should be interpreted as if declared to be + of type ID. This name is reserved by virtue of its definition in the xml:id + specification.

+

See http://www.w3.org/TR/xml-id/ + for information about this attribute.

+
+
+
+
+ + + + + + + + +
+

Father (in any context at all)

+
+

denotes Jon Bosak, the chair of the original XML Working Group. This name is + reserved by the following decision of the W3C XML Plenary and XML + Coordination groups:

+
+

In appreciation for his vision, leadership and dedication the W3C XML + Plenary on this 10th day of February, 2000, reserves for Jon Bosak in + perpetuity the XML name "xml:Father".

+
+
+
+
+
+ + +
+

+ About this schema document +

+
+

This schema defines attributes and an attribute group suitable for use by + schemas wishing to allow xml:base, xml:lang, + xml:space or xml:id attributes on elements + they define.

+

To enable this, such a schema must import this schema for the XML namespace, + e.g. as follows:

+
+          <schema . . .>
+           . . .
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+     
+

or

+
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
+     
+

Subsequently, qualified reference to any of the attributes or the group + defined below will have the desired effect, e.g.

+
+          <type . . .>
+           . . .
+           <attributeGroup ref="xml:specialAttrs"/>
+     
+

will define a type which will schema-validate an instance element with any + of those attributes.

+
+
+
+
+ + +
+

+ Versioning policy for this schema document +

+
+

In keeping with the XML Schema WG's standard versioning policy, this schema + document will persist at + http://www.w3.org/2009/01/xml.xsd.

+

At the date of issue it can also be found at + http://www.w3.org/2001/xml.xsd.

+

The schema document at that URI may however change in the future, in order + to remain compatible with the latest version of XML Schema itself, or with + the XML namespace itself. In other words, if the XML Schema or XML + namespaces change, the version of this document at http://www.w3.org/2001/xml.xsd + will change accordingly; the version at + http://www.w3.org/2009/01/xml.xsd will not change.

+

Previous dated (and unchanging) versions of this schema document are at:

+ +
+
+
+
+
From 7b31417c147d3f98ed17f6f7876fa543ab3cb4cc Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Fri, 15 Nov 2024 18:50:58 +0000 Subject: [PATCH 02/15] Update XSD to make fewer changes to TTML2 source Also define restrictions (prohibited and required attributes) properly. --- xml-schemas/dapt.xsd | 22 ++++++++++++--- xml-schemas/ttml2-content.xsd | 19 +++++++++++-- xml-schemas/ttml2-datatypes.xsd | 36 +++++++++++++++++++++++++ xml-schemas/ttml2-embedded.xsd | 2 +- xml-schemas/ttml2-parameter-attribs.xsd | 10 ++++++- 5 files changed, 82 insertions(+), 7 deletions(-) diff --git a/xml-schemas/dapt.xsd b/xml-schemas/dapt.xsd index 5df5ff7..c1f8819 100644 --- a/xml-schemas/dapt.xsd +++ b/xml-schemas/dapt.xsd @@ -34,8 +34,24 @@ - - - + + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/ttml2-content.xsd b/xml-schemas/ttml2-content.xsd index 103784c..7cfbc21 100644 --- a/xml-schemas/ttml2-content.xsd +++ b/xml-schemas/ttml2-content.xsd @@ -4,7 +4,8 @@ xmlns:tt="http://www.w3.org/ns/ttml" xmlns:ttm="http://www.w3.org/ns/ttml#metadata" xmlns:tts="http://www.w3.org/ns/ttml#styling" - xmlns:xlink="http://www.w3.org/1999/xlink"> + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:xml="http://www.w3.org/XML/1998/namespace"> @@ -15,6 +16,8 @@ schemaLocation="ttml2-metadata-attribs.xsd"/> + @@ -66,6 +69,18 @@ + + + + + + + + + + + + @@ -90,7 +105,7 @@ - + diff --git a/xml-schemas/ttml2-datatypes.xsd b/xml-schemas/ttml2-datatypes.xsd index f872dcb..e0cd84c 100644 --- a/xml-schemas/ttml2-datatypes.xsd +++ b/xml-schemas/ttml2-datatypes.xsd @@ -73,6 +73,13 @@ + + + + + + + @@ -147,6 +154,13 @@ + + + + + + + @@ -359,6 +373,12 @@ + + + + + + @@ -595,6 +615,14 @@ + + + non-negative-integer + + + + + @@ -725,6 +753,14 @@ + + + + + + + diff --git a/xml-schemas/ttml2-embedded.xsd b/xml-schemas/ttml2-embedded.xsd index d0fb705..32c69fc 100644 --- a/xml-schemas/ttml2-embedded.xsd +++ b/xml-schemas/ttml2-embedded.xsd @@ -87,7 +87,7 @@ - + diff --git a/xml-schemas/ttml2-parameter-attribs.xsd b/xml-schemas/ttml2-parameter-attribs.xsd index ece3bf7..f344763 100644 --- a/xml-schemas/ttml2-parameter-attribs.xsd +++ b/xml-schemas/ttml2-parameter-attribs.xsd @@ -6,38 +6,46 @@ + + + + - + + + + + From 5f2f44b0c0d9d81b45de41bc58495b149139d9dc Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Fri, 15 Nov 2024 19:05:36 +0000 Subject: [PATCH 03/15] Allow langSrc and represents --- xml-schemas/dapt.xsd | 2 ++ xml-schemas/ttml2-content.xsd | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/xml-schemas/dapt.xsd b/xml-schemas/dapt.xsd index c1f8819..d23ab24 100644 --- a/xml-schemas/dapt.xsd +++ b/xml-schemas/dapt.xsd @@ -48,6 +48,8 @@ + + diff --git a/xml-schemas/ttml2-content.xsd b/xml-schemas/ttml2-content.xsd index 7cfbc21..b3cc123 100644 --- a/xml-schemas/ttml2-content.xsd +++ b/xml-schemas/ttml2-content.xsd @@ -1,6 +1,7 @@ + + + @@ -89,6 +94,13 @@ + + + + + + + From 6255cc56b45f1815954d93424a1dcd8f9c53e395 Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Mon, 18 Nov 2024 10:34:37 +0000 Subject: [PATCH 04/15] Re-permit layout and region Was too heavy handed before in removing them, I think they are permitted in DAPT. But out of line animation still isn't allowed! --- xml-schemas/ttml2-head.xsd | 7 ++++-- xml-schemas/ttml2-layout.xsd | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 xml-schemas/ttml2-layout.xsd diff --git a/xml-schemas/ttml2-head.xsd b/xml-schemas/ttml2-head.xsd index b30caf8..4fd706f 100644 --- a/xml-schemas/ttml2-head.xsd +++ b/xml-schemas/ttml2-head.xsd @@ -10,18 +10,21 @@ + - + + + - + diff --git a/xml-schemas/ttml2-layout.xsd b/xml-schemas/ttml2-layout.xsd new file mode 100644 index 0000000..4509aa6 --- /dev/null +++ b/xml-schemas/ttml2-layout.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 6bdaffd3d3ec0db173f82d67527e111dee677b65 Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Mon, 18 Nov 2024 14:29:10 +0000 Subject: [PATCH 05/15] Create README.md Explain the structure of the XSD, and how to use it. --- xml-schemas/README.md | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 xml-schemas/README.md diff --git a/xml-schemas/README.md b/xml-schemas/README.md new file mode 100644 index 0000000..83995e0 --- /dev/null +++ b/xml-schemas/README.md @@ -0,0 +1,45 @@ +# DAPT XSD Readme + +The [DAPT](https://www.w3.org/TR/dapt/) XML Schema is provided as an informative (i.e. non-normative) addition +to the specification as an aid to implementers. + +The XML Schema is provided as an [XSD 1](https://www.w3.org/TR/xmlschema-1/) (XML Schema definition language) document. + +## Usage + +An XSD 1 conformant XML validator should be able to validate a DAPT document against the top level [`dapt.xsd`](dapt.xsd) +schema document. + +## Design + +The DAPT XSD is designed to be inclusive, rather than defining attributes and elements from the DAPT specification +and relying on external XSDs for other namespace vocabulary. +This is so that DAPT-specific constraints, such as the prohibition of the `` element, +or the requirement for the `daptm:scriptRepresents` attribute on the root `` element, +can be applied. + +### Sources + +Structurally, much of the XSD consists of a copy of the [TTML2 XSD](https://github.com/w3c/ttml2/tree/main/spec/xsd), though in some cases changes have been +made to represent those additional DAPT constraints. +This means that if the TTML2 XSD changes, there could be a maintenance task to update the DAPT XSD. +However it also simplifies usage. + +Additionally, DAPT namespaces and DAPT-specific data types are defined in imported files whose name is prefixed `dapt-`. + +### Implicit (namespace-based) references to dependent XSDs + +A [`dapt-all.xsd`](dapt-all.xsd) is provided for XSD tools that allow for implicit references to schema documents +based on namespace, but this is not tested and may generate naming clash errors. + +### Type restrictions + +Two mechanisms are used to enforce DAPT-specific type restrictions: + +1. DAPT-specific complex type definitions with `xs:complexContent` containing `xs:restriction` based on the TTML2 type. +This method is used where attributes permitted on the TTML2 type are prohibited in DAPT, and/or when additional +DAPT-specific attributes need to be permitted as extensions to the TTML2 element. +The relevant element definitions then point to the restricted DAPT type rather than the base TTML2 type. +2. Edits to remove DAPT-prohibited elements or attribute groups from TTML2 types - where this +pattern is used, XML comments highlight the change in the XSD file. + From b871960a1830c026d1e1a178be8be092c783da7d Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Mon, 18 Nov 2024 16:58:38 +0000 Subject: [PATCH 06/15] Add daptOriginTimecode and EBU-TT Metadata Also sort DAPT metadata by attributes and then elements , each alphabetically. EBU-TT Metadata is imported by git submodule. --- .gitmodules | 3 +++ xml-schemas/README.md | 8 ++++++-- xml-schemas/dapt-metadata.xsd | 37 +++++++++++++++++++++++------------ xml-schemas/dapt.xsd | 3 +++ xml-schemas/ebu-tt-m-xsd | 1 + 5 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 .gitmodules create mode 160000 xml-schemas/ebu-tt-m-xsd diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..18171b9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "xml-schemas/ebu-tt-m-xsd"] + path = xml-schemas/ebu-tt-m-xsd + url = https://github.com/ebu/ebu-tt-m-xsd.git diff --git a/xml-schemas/README.md b/xml-schemas/README.md index 83995e0..9a99faf 100644 --- a/xml-schemas/README.md +++ b/xml-schemas/README.md @@ -12,9 +12,10 @@ schema document. ## Design -The DAPT XSD is designed to be inclusive, rather than defining attributes and elements from the DAPT specification +The DAPT XSD is designed to be inclusive of all content predicted from the DAPT specification, +rather than defining attributes and elements from the DAPT specification and relying on external XSDs for other namespace vocabulary. -This is so that DAPT-specific constraints, such as the prohibition of the `` element, +This also permits DAPT-specific constraints, such as the prohibition of the `` element, or the requirement for the `daptm:scriptRepresents` attribute on the root `` element, can be applied. @@ -27,6 +28,9 @@ However it also simplifies usage. Additionally, DAPT namespaces and DAPT-specific data types are defined in imported files whose name is prefixed `dapt-`. +EBU-TT Metadata is imported via a git submodule pointed at the XSD 1 version of the +[EBU-TT Metadata schema](https://github.com/ebu/ebu-tt-m-xsd/tree/issue-0030-schema-v1). + ### Implicit (namespace-based) references to dependent XSDs A [`dapt-all.xsd`](dapt-all.xsd) is provided for XSD tools that allow for implicit references to schema documents diff --git a/xml-schemas/dapt-metadata.xsd b/xml-schemas/dapt-metadata.xsd index 3f0d0fe..09b0892 100644 --- a/xml-schemas/dapt-metadata.xsd +++ b/xml-schemas/dapt-metadata.xsd @@ -2,21 +2,15 @@ + xmlns:daptd="http://www.w3.org/ns/ttml/profile/dapt#datatype" + xmlns:daptm="http://www.w3.org/ns/ttml/profile/dapt#metadata"> - + - - - - - - + - - @@ -32,9 +26,28 @@ - + + + - + + + + + + + + + + + + + + + + + + diff --git a/xml-schemas/dapt.xsd b/xml-schemas/dapt.xsd index d23ab24..90e0fc2 100644 --- a/xml-schemas/dapt.xsd +++ b/xml-schemas/dapt.xsd @@ -4,6 +4,7 @@ xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:daptm="http://www.w3.org/ns/ttml/profile/dapt#metadata" + xmlns:ebuttm="urn:ebu:tt:metadata" xmlns:tt="http://www.w3.org/ns/ttml" xmlns:ttm="http://www.w3.org/ns/ttml#metadata" xmlns:ttp="http://www.w3.org/ns/ttml#parameter" @@ -14,6 +15,8 @@ schemaLocation="ttml2-metadata-items.xsd"/> + Date: Mon, 18 Nov 2024 17:07:35 +0000 Subject: [PATCH 07/15] Require xml:id on ttm:agent --- xml-schemas/ttml2-metadata-items.xsd | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/xml-schemas/ttml2-metadata-items.xsd b/xml-schemas/ttml2-metadata-items.xsd index f568651..6024290 100644 --- a/xml-schemas/ttml2-metadata-items.xsd +++ b/xml-schemas/ttml2-metadata-items.xsd @@ -1,6 +1,7 @@ + @@ -55,6 +58,17 @@ + + + + + + + + + + + @@ -74,7 +88,7 @@ - + From d05ca6fdda140c9e71ff96cda2581cf9ed3af1ec Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Mon, 18 Nov 2024 17:09:33 +0000 Subject: [PATCH 08/15] Require ttm:name child of ttm:agent --- xml-schemas/ttml2-metadata-items.xsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml-schemas/ttml2-metadata-items.xsd b/xml-schemas/ttml2-metadata-items.xsd index 6024290..0606d24 100644 --- a/xml-schemas/ttml2-metadata-items.xsd +++ b/xml-schemas/ttml2-metadata-items.xsd @@ -62,7 +62,7 @@ - + From ff2d5cadaf3234dc9ed74bf47448680061b85634 Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Tue, 3 Dec 2024 09:55:22 +0000 Subject: [PATCH 09/15] Restore region binding, add onScreen to div --- xml-schemas/ttml2-content.xsd | 5 +++++ xml-schemas/ttml2-layout.xsd | 1 + 2 files changed, 6 insertions(+) diff --git a/xml-schemas/ttml2-content.xsd b/xml-schemas/ttml2-content.xsd index b3cc123..e7721a0 100644 --- a/xml-schemas/ttml2-content.xsd +++ b/xml-schemas/ttml2-content.xsd @@ -25,6 +25,7 @@ + @@ -32,6 +33,7 @@ + @@ -39,6 +41,7 @@ + @@ -46,6 +49,7 @@ + @@ -82,6 +86,7 @@ + diff --git a/xml-schemas/ttml2-layout.xsd b/xml-schemas/ttml2-layout.xsd index 4509aa6..65961b0 100644 --- a/xml-schemas/ttml2-layout.xsd +++ b/xml-schemas/ttml2-layout.xsd @@ -8,6 +8,7 @@ + From c28244206f964f6d4fc9aeeabb82511db3908c33 Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Thu, 5 Dec 2024 17:40:35 +0000 Subject: [PATCH 10/15] Remove dapt-all As discussed in today's TTWG meeting - notes via w3c/ttwg#296 --- xml-schemas/README.md | 5 ----- xml-schemas/dapt-all.xsd | 18 ------------------ 2 files changed, 23 deletions(-) delete mode 100644 xml-schemas/dapt-all.xsd diff --git a/xml-schemas/README.md b/xml-schemas/README.md index 9a99faf..5bccf22 100644 --- a/xml-schemas/README.md +++ b/xml-schemas/README.md @@ -31,11 +31,6 @@ Additionally, DAPT namespaces and DAPT-specific data types are defined in import EBU-TT Metadata is imported via a git submodule pointed at the XSD 1 version of the [EBU-TT Metadata schema](https://github.com/ebu/ebu-tt-m-xsd/tree/issue-0030-schema-v1). -### Implicit (namespace-based) references to dependent XSDs - -A [`dapt-all.xsd`](dapt-all.xsd) is provided for XSD tools that allow for implicit references to schema documents -based on namespace, but this is not tested and may generate naming clash errors. - ### Type restrictions Two mechanisms are used to enforce DAPT-specific type restrictions: diff --git a/xml-schemas/dapt-all.xsd b/xml-schemas/dapt-all.xsd deleted file mode 100644 index bf81711..0000000 --- a/xml-schemas/dapt-all.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - From a3c0d89b77af5eb43a4c7ee85a0b9d44ca1ef7fb Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Fri, 28 Feb 2025 17:34:19 +0000 Subject: [PATCH 11/15] Add a validator script and test file --- schema-validator/README.md | 29 ++++++ schema-validator/poetry.lock | 98 +++++++++++++++++++ schema-validator/pyproject.toml | 25 +++++ schema-validator/src/__init__.py | 0 schema-validator/src/validate.py | 51 ++++++++++ schema-validator/test/__init__.py | 0 .../test/fixtures/valid_dapt.ttml | 31 ++++++ schema-validator/test/test_validate.py | 21 ++++ xml-schemas/ttml2-metadata-items.xsd | 2 +- xml-schemas/ttml2-metadata.xsd | 2 +- 10 files changed, 257 insertions(+), 2 deletions(-) create mode 100644 schema-validator/README.md create mode 100644 schema-validator/poetry.lock create mode 100644 schema-validator/pyproject.toml create mode 100644 schema-validator/src/__init__.py create mode 100644 schema-validator/src/validate.py create mode 100644 schema-validator/test/__init__.py create mode 100644 schema-validator/test/fixtures/valid_dapt.ttml create mode 100644 schema-validator/test/test_validate.py diff --git a/schema-validator/README.md b/schema-validator/README.md new file mode 100644 index 0000000..51766a4 --- /dev/null +++ b/schema-validator/README.md @@ -0,0 +1,29 @@ +# DAPT XSD Validator + +Basic command line utility for validating DAPT documents using +the XML Schema Definition in the w3c/dapt repository. + +## Build + +1. Install poetry - [installation instructions](https://python-poetry.org/docs/#installing-with-the-official-installer) +2. Ensure you have a version of Python greater than or equal to 3.11 available +for example with the command `poetry env use 3.11` +3. Install the dependencies by running `poetry install` + +## Usage + +```sh +poetry run validate -dapt_in path/to/dapt_file.ttml +``` + +or pass the document for validating in via stdin, e.g.: + +```sh +poetry run validate < path/to/dapt_file.ttml +``` + +## Tests + +```sh +poetry run python -m unittest +``` diff --git a/schema-validator/poetry.lock b/schema-validator/poetry.lock new file mode 100644 index 0000000..5a08718 --- /dev/null +++ b/schema-validator/poetry.lock @@ -0,0 +1,98 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + +[[package]] +name = "elementpath" +version = "4.7.0" +description = "XPath 1.0/2.0/3.0/3.1 parsers and selectors for ElementTree and lxml" +optional = false +python-versions = ">=3.8" +files = [ + {file = "elementpath-4.7.0-py3-none-any.whl", hash = "sha256:607804a1b4250ac448c1e2bfaec4ee1c980b0a07cfdb0d9057b57102038ed480"}, + {file = "elementpath-4.7.0.tar.gz", hash = "sha256:a2029dc8752fcfec49663d1ed1b412c6daf278c0c91938f50f63c4fe9ed1848e"}, +] + +[package.extras] +dev = ["Sphinx", "coverage", "flake8", "lxml", "lxml-stubs", "memory-profiler", "memray", "mypy", "tox", "xmlschema (>=3.3.2)"] + +[[package]] +name = "flake8" +version = "7.1.2" +description = "the modular source code checker: pep8 pyflakes and co" +optional = false +python-versions = ">=3.8.1" +files = [ + {file = "flake8-7.1.2-py2.py3-none-any.whl", hash = "sha256:1cbc62e65536f65e6d754dfe6f1bada7f5cf392d6f5db3c2b85892466c3e7c1a"}, + {file = "flake8-7.1.2.tar.gz", hash = "sha256:c586ffd0b41540951ae41af572e6790dbd49fc12b3aa2541685d253d9bd504bd"}, +] + +[package.dependencies] +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.12.0,<2.13.0" +pyflakes = ">=3.2.0,<3.3.0" + +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +optional = false +python-versions = ">=3.6" +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + +[[package]] +name = "pycodestyle" +version = "2.12.1" +description = "Python style guide checker" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pycodestyle-2.12.1-py2.py3-none-any.whl", hash = "sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3"}, + {file = "pycodestyle-2.12.1.tar.gz", hash = "sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521"}, +] + +[[package]] +name = "pyflakes" +version = "3.2.0" +description = "passive checker of Python programs" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, + {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, +] + +[[package]] +name = "xmlschema" +version = "3.4.3" +description = "An XML Schema validator and decoder" +optional = false +python-versions = ">=3.8" +files = [ + {file = "xmlschema-3.4.3-py3-none-any.whl", hash = "sha256:eea4e5a1aac041b546ebe7b2eb68eb5eaebf5c5258e573cfc182375676b2e4e3"}, + {file = "xmlschema-3.4.3.tar.gz", hash = "sha256:0c638dac81c7d6c9da9a8d7544402c48cffe7ee0e13cc47fc0c18794d1395dfb"}, +] + +[package.dependencies] +elementpath = ">=4.4.0,<5.0.0" + +[package.extras] +codegen = ["elementpath (>=4.4.0,<5.0.0)", "jinja2"] +dev = ["Sphinx", "coverage", "elementpath (>=4.4.0,<5.0.0)", "flake8", "jinja2", "lxml", "lxml-stubs", "memory-profiler", "mypy", "sphinx-rtd-theme", "tox"] +docs = ["Sphinx", "elementpath (>=4.4.0,<5.0.0)", "jinja2", "sphinx-rtd-theme"] + +[[package]] +name = "xsd-validator" +version = "0.0.3" +description = "Validates XML file against XSD, supporting XSD versionj 1.1" +optional = false +python-versions = ">=3.6" +files = [ + {file = "xsd_validator-0.0.3-py3-none-any.whl", hash = "sha256:dbc1407f8b747610a60570d19edc848b1d8e9ed3dbc955e02aee5e7db84aded1"}, +] + +[metadata] +lock-version = "2.0" +python-versions = ">=3.11" +content-hash = "64a3e147865b54d9bdc938d3d1046b5602577a9474c0768899cb75ad8742c7ef" diff --git a/schema-validator/pyproject.toml b/schema-validator/pyproject.toml new file mode 100644 index 0000000..b9f1c80 --- /dev/null +++ b/schema-validator/pyproject.toml @@ -0,0 +1,25 @@ +[tool.poetry] +name = "dapt-xsd-val" +version = "0.1.0" +description = "Thin wrapper around xmlschema to support XSD validation using the supplied DAPT XSD" +authors = ["Nigel Megitt "] +readme = "README.md" +packages = [ + { include = "src" }, + { include = "test" }, +] + +[tool.poetry.dependencies] +python = ">=3.11" +xmlschema = "^3.4.3" +xsd-validator = "^0.0.3" + +[tool.poetry.group.dev.dependencies] +flake8 = "^7.1.2" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.poetry.scripts] +validate = "src.validate:main" diff --git a/schema-validator/src/__init__.py b/schema-validator/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/schema-validator/src/validate.py b/schema-validator/src/validate.py new file mode 100644 index 0000000..12340e6 --- /dev/null +++ b/schema-validator/src/validate.py @@ -0,0 +1,51 @@ +import os +import sys +import argparse +import xmlschema + + +schema_path = os.path.normpath( + os.path.join( + os.path.dirname(__file__), + '../../xml-schemas/dapt.xsd') +) +metadata_items_schema_path = os.path.normpath( + os.path.join( + os.path.dirname(__file__), + '../../xml-schemas/ttml2-metadata-items.xsd') +) + + +def validate_dapt(args): + # xmlschema gets baffled following the import of metadata_items, + # so make it load it explicitly instead, which seems to work. + schema = xmlschema.XMLSchema([schema_path, metadata_items_schema_path]) + schema.build() + + try: + schema.validate(args.dapt_in) + except xmlschema.XMLSchemaValidationError as valex: + print(str(valex)) + return -1 + + return 0 + + +def main(): + parser = argparse.ArgumentParser() + + parser.add_argument( + '-dapt_in', + type=argparse.FileType('rb'), + default=sys.stdin, nargs='?', + help='Input DAPT file to validate', + action='store') + parser.set_defaults(func=validate_dapt) + + args = parser.parse_args() + return args.func(args) + + +if __name__ == "__main__": + # execute only if run as a script + sys.exit(main()) diff --git a/schema-validator/test/__init__.py b/schema-validator/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/schema-validator/test/fixtures/valid_dapt.ttml b/schema-validator/test/fixtures/valid_dapt.ttml new file mode 100644 index 0000000..a58ab95 --- /dev/null +++ b/schema-validator/test/fixtures/valid_dapt.ttml @@ -0,0 +1,31 @@ + + + + + + Matthias Schoenaerts + + + BOOKER + + + + + +
+ high mountain valley + +

Look at this beautiful valley.

+
+ +
\ No newline at end of file diff --git a/schema-validator/test/test_validate.py b/schema-validator/test/test_validate.py new file mode 100644 index 0000000..f20e364 --- /dev/null +++ b/schema-validator/test/test_validate.py @@ -0,0 +1,21 @@ +import os +import unittest +from argparse import Namespace +from src.validate import validate_dapt + +fixture_dur = \ + os.path.join( + os.path.dirname(__file__), + 'fixtures') + + +class testValidate(unittest.TestCase): + maxDiff = None + + def testValidFile(self): + with open( + os.path.join(fixture_dur, 'valid_dapt.ttml'), newline='') \ + as dapt_file: + result = validate_dapt(args=Namespace(dapt_in=dapt_file)) + + self.assertEqual(result, 0) diff --git a/xml-schemas/ttml2-metadata-items.xsd b/xml-schemas/ttml2-metadata-items.xsd index 0606d24..7ece8fd 100644 --- a/xml-schemas/ttml2-metadata-items.xsd +++ b/xml-schemas/ttml2-metadata-items.xsd @@ -1,5 +1,5 @@ - + xmlns:ttm="http://www.w3.org/ns/ttml#metadata" elementFormDefault="qualified"> From 29d172ff8370e9cde14fa6ea59b51cacc8398143 Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Mon, 3 Mar 2025 10:38:33 +0000 Subject: [PATCH 12/15] Add logging output --- schema-validator/src/validate.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/schema-validator/src/validate.py b/schema-validator/src/validate.py index 12340e6..4e71f1a 100644 --- a/schema-validator/src/validate.py +++ b/schema-validator/src/validate.py @@ -2,6 +2,9 @@ import sys import argparse import xmlschema +import logging + +logging.getLogger().setLevel(logging.INFO) schema_path = os.path.normpath( @@ -19,15 +22,25 @@ def validate_dapt(args): # xmlschema gets baffled following the import of metadata_items, # so make it load it explicitly instead, which seems to work. - schema = xmlschema.XMLSchema([schema_path, metadata_items_schema_path]) + schema_paths = [schema_path, metadata_items_schema_path] + logging.info('Creating schema from XSDs at {}'.format(schema_paths)) + schema = xmlschema.XMLSchema(schema_paths) schema.build() + if schema.validity: + logging.info('Schemas are valid') + else: + logging.error('Schemas are not valid, exiting early') + return -1 try: + logging.info('Validating document at {}'.format(args.dapt_in.name)) schema.validate(args.dapt_in) except xmlschema.XMLSchemaValidationError as valex: - print(str(valex)) + logging.error(str(valex)) + logging.error('Document is not valid.') return -1 + logging.info('Document is valid') return 0 From 3b55509356e6c8b251900f60d46b3623f4085730 Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Mon, 3 Mar 2025 11:21:17 +0000 Subject: [PATCH 13/15] Remove unused xsd-validator library --- schema-validator/poetry.lock | 12 +----------- schema-validator/pyproject.toml | 1 - xml-schemas/README.md | 3 +++ 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/schema-validator/poetry.lock b/schema-validator/poetry.lock index 5a08718..aea010e 100644 --- a/schema-validator/poetry.lock +++ b/schema-validator/poetry.lock @@ -82,17 +82,7 @@ codegen = ["elementpath (>=4.4.0,<5.0.0)", "jinja2"] dev = ["Sphinx", "coverage", "elementpath (>=4.4.0,<5.0.0)", "flake8", "jinja2", "lxml", "lxml-stubs", "memory-profiler", "mypy", "sphinx-rtd-theme", "tox"] docs = ["Sphinx", "elementpath (>=4.4.0,<5.0.0)", "jinja2", "sphinx-rtd-theme"] -[[package]] -name = "xsd-validator" -version = "0.0.3" -description = "Validates XML file against XSD, supporting XSD versionj 1.1" -optional = false -python-versions = ">=3.6" -files = [ - {file = "xsd_validator-0.0.3-py3-none-any.whl", hash = "sha256:dbc1407f8b747610a60570d19edc848b1d8e9ed3dbc955e02aee5e7db84aded1"}, -] - [metadata] lock-version = "2.0" python-versions = ">=3.11" -content-hash = "64a3e147865b54d9bdc938d3d1046b5602577a9474c0768899cb75ad8742c7ef" +content-hash = "a6d74d71acfdd39d86fa00bb5c576c716bfdfa94dfc9e49ad24ea0e73ccd81fe" diff --git a/schema-validator/pyproject.toml b/schema-validator/pyproject.toml index b9f1c80..5baf9f0 100644 --- a/schema-validator/pyproject.toml +++ b/schema-validator/pyproject.toml @@ -12,7 +12,6 @@ packages = [ [tool.poetry.dependencies] python = ">=3.11" xmlschema = "^3.4.3" -xsd-validator = "^0.0.3" [tool.poetry.group.dev.dependencies] flake8 = "^7.1.2" diff --git a/xml-schemas/README.md b/xml-schemas/README.md index 5bccf22..736b1dd 100644 --- a/xml-schemas/README.md +++ b/xml-schemas/README.md @@ -10,6 +10,9 @@ The XML Schema is provided as an [XSD 1](https://www.w3.org/TR/xmlschema-1/) (XM An XSD 1 conformant XML validator should be able to validate a DAPT document against the top level [`dapt.xsd`](dapt.xsd) schema document. +As a convenience, a Python script is provided to allow use of the XSDs to validate +a DAPT document using only open source libraries. + ## Design The DAPT XSD is designed to be inclusive of all content predicted from the DAPT specification, From 864078d67a4332af05993fb304e15048ac0cc875 Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Mon, 3 Mar 2025 11:21:41 +0000 Subject: [PATCH 14/15] Clarify licensing for schema-validator --- schema-validator/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/schema-validator/README.md b/schema-validator/README.md index 51766a4..6d355d2 100644 --- a/schema-validator/README.md +++ b/schema-validator/README.md @@ -3,6 +3,12 @@ Basic command line utility for validating DAPT documents using the XML Schema Definition in the w3c/dapt repository. +This script uses the MIT licensed [`xmlschema`](https://github.com/sissaschool/xmlschema) library. + +This script is provided as-is with no warranties of any kind. +The repository's `LICENSE.md` applies, with the contents of this folder +being considered a _code example_. + ## Build 1. Install poetry - [installation instructions](https://python-poetry.org/docs/#installing-with-the-official-installer) From 9ae9908813b9ce79e7db50d56e8f61e177eb28a3 Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Mon, 3 Mar 2025 11:26:10 +0000 Subject: [PATCH 15/15] Clarify that XSD validation is not complete validation --- schema-validator/src/validate.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/schema-validator/src/validate.py b/schema-validator/src/validate.py index 4e71f1a..ee36a32 100644 --- a/schema-validator/src/validate.py +++ b/schema-validator/src/validate.py @@ -40,7 +40,11 @@ def validate_dapt(args): logging.error('Document is not valid.') return -1 - logging.info('Document is valid') + logging.info( + 'Document is syntactically valid with respect to the ' + 'DAPT XML Schema Definition; ' + 'this does not check all semantic requirements of the ' + 'DAPT specification.') return 0