add libsel4/tools/sel4_idl.xsd to replace dtd

No intended changes to the schema, just change
the schema from dtd to xsd, and update ci to use it.

Signed-off-by: matt rice <ratmice@gmail.com>
This commit is contained in:
matt rice 2022-02-27 03:02:34 -08:00 committed by Gerwin Klein
parent d14d6c2139
commit b0d70f1ebc
5 changed files with 143 additions and 67 deletions

View file

@ -12,11 +12,11 @@ on:
- master
paths:
- 'libsel4/**/sel4*.xml'
- 'libsel4/**/sel4*.dtd'
- 'libsel4/**/sel4*.xsd'
pull_request:
paths:
- 'libsel4/**/sel4*.xml'
- 'libsel4/**/sel4*.dtd'
- 'libsel4/**/sel4*.xsd'
jobs:
xmllint:
@ -29,4 +29,4 @@ jobs:
- name: run xmllint
run: |
find libsel4 -name "sel4*.xml" | \
xargs xmllint --dtdvalid libsel4/tools/sel4_idl.dtd --noout
xargs xmllint --schema libsel4/tools/sel4_idl.xsd --noout

View file

@ -1,62 +0,0 @@
<!--
Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
SPDX-License-Identifier: BSD-2-Clause
-->
<!ELEMENT api (struct*,interface*)>
<!ATTLIST api name CDATA #IMPLIED>
<!ATTLIST api label_prefix CDATA #IMPLIED>
<!ELEMENT struct (member*)>
<!ATTLIST struct name CDATA #REQUIRED>
<!ELEMENT member EMPTY>
<!ATTLIST member name CDATA #REQUIRED>
<!ELEMENT interface (method*)>
<!ATTLIST interface name CDATA #REQUIRED>
<!ATTLIST interface manual_name CDATA #IMPLIED>
<!ATTLIST interface cap_description CDATA #IMPLIED>
<!ELEMENT method (brief?,description?,return?,cap_param?,param*,error*)>
<!ATTLIST method name CDATA #REQUIRED>
<!ATTLIST method id CDATA #REQUIRED>
<!ATTLIST method condition CDATA #IMPLIED>
<!ATTLIST method manual_name CDATA #IMPLIED>
<!ATTLIST method manual_label CDATA #IMPLIED>
<!ELEMENT param (description?, error*)>
<!ATTLIST param type CDATA #REQUIRED>
<!ATTLIST param name CDATA #REQUIRED>
<!ATTLIST param dir CDATA #REQUIRED>
<!ATTLIST param description CDATA #IMPLIED>
<!ELEMENT error (description?)>
<!ATTLIST error name CDATA #REQUIRED>
<!ATTLIST error description CDATA #IMPLIED>
<!ELEMENT brief (#PCDATA|texttt|docref|shortref|autoref|obj)*>
<!ELEMENT description (#PCDATA|texttt|docref|shortref|autoref|obj)*>
<!ELEMENT return (#PCDATA|texttt|docref|shortref|autoref|obj|errorenumdesc)*>
<!ELEMENT docref (#PCDATA|texttt|shortref|autoref|obj)*>
<!ELEMENT texttt EMPTY>
<!ATTLIST texttt text CDATA #REQUIRED>
<!ELEMENT autoref EMPTY>
<!ATTLIST autoref label CDATA #REQUIRED>
<!ELEMENT shortref EMPTY>
<!ATTLIST shortref sec CDATA #REQUIRED>
<!ELEMENT obj EMPTY>
<!ATTLIST obj name CDATA #REQUIRED>
<!ELEMENT errorenumdesc EMPTY>
<!ELEMENT cap_param EMPTY>
<!ATTLIST cap_param append_description CDATA #IMPLIED>

138
libsel4/tools/sel4_idl.xsd Normal file
View file

@ -0,0 +1,138 @@
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--
Copyright 2022, seL4 Project a Series of LF Projects, LLC
SPDX-License-Identifier: BSD-2-Clause
-->
<xsd:annotation>
<xsd:documentation xml:lang="en">
seL4 api generator schema.
</xsd:documentation>
</xsd:annotation>
<xsd:element name="api" type="APIType"/>
<xsd:complexType name="APIType">
<xsd:sequence>
<xsd:element name="struct" minOccurs="0" maxOccurs="unbounded" type="StructType" />
<xsd:element name="interface" minOccurs="0" maxOccurs="unbounded" type="InterfaceType"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="optional" />
<xsd:attribute name="label_prefix" type="xsd:string" use="optional"/>
</xsd:complexType>
<xsd:complexType name="StructType">
<xsd:sequence>
<xsd:element name="member" minOccurs="0" maxOccurs="unbounded" type="StructMemberType" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="StructMemberType">
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="InterfaceType">
<xsd:sequence>
<xsd:element name="method" minOccurs="0" maxOccurs="unbounded" type="MethodType"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="manual_name" type="xsd:string" use="optional" />
<xsd:attribute name="cap_description" type="xsd:string" use="optional" />
</xsd:complexType>
<xsd:complexType name="MethodType">
<xsd:sequence>
<xsd:element name="brief" type="DescriptionType" minOccurs="0" maxOccurs="1" />
<xsd:element name="description" type="DescriptionType" minOccurs="0" maxOccurs="1" />
<xsd:element name="return" type="ReturnType" minOccurs="0" maxOccurs="1" />
<xsd:element name="cap_param" type="CapParamType" minOccurs="0" maxOccurs="1" />
<xsd:element name="param" type="ParamType" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="error" type="ErrorType" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="id" type="xsd:string" use="required" />
<xsd:attribute name="condition" type="xsd:string" use="optional" />
<xsd:attribute name="manual_name" type="xsd:string" use="optional" />
<xsd:attribute name="manual_label" type="xsd:string" use="optional" />
</xsd:complexType>
<xsd:group name="DocElements">
<xsd:choice>
<xsd:element name="texttt">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="text" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="shortref" type="ShortRefType"/>
<xsd:element name="obj" type="ObjType"/>
<xsd:element name="autoref" type="AutoRefType"/>
</xsd:choice>
</xsd:group>
<xsd:complexType name="DescriptionType" mixed="true">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:group ref="DocElements" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="docref" type="DocRefType"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="ReturnType" mixed="true">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:group ref="DocElements" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="docref" type="DocRefType"/>
<xsd:element name="errorenumdesc" type="ErrorEnumDescType"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="DocRefType" mixed="true">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:group ref="DocElements" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="CapParamType">
<xsd:attribute name="append_description" type="xsd:string" use="optional"/>
</xsd:complexType>
<xsd:complexType name="ParamType">
<xsd:sequence>
<xsd:element name="description" minOccurs="0" maxOccurs="1" type="DescriptionType"/>
<xsd:element name="error" minOccurs="0" maxOccurs="unbounded" type="ErrorType"/>
</xsd:sequence>
<xsd:attribute name="type" type="xsd:string" use="required"/>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="dir" type="xsd:string" use="required"/>
<xsd:attribute name="description" type="xsd:string" use="optional"/>
</xsd:complexType>
<xsd:complexType name="ErrorType">
<xsd:choice>
<xsd:element name="description" type="DescriptionType" minOccurs="0" maxOccurs="1"/>
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="description" type="xsd:string" use="optional"/>
</xsd:complexType>
<xsd:complexType name="ShortRefType">
<xsd:attribute name="sec" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="AutoRefType">
<xsd:attribute name="label" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="ObjType">
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="ErrorEnumDescType"/>
</xsd:schema>

View file

@ -86,7 +86,7 @@ GenerationTool = tools/parse_doxygen_xml.py
GenerateObjectInvocationTool = tools/gen_invocations.py
InterfaceDtd = $(Libsel4Dir)/tools/sel4_idl.dtd
InterfaceDtd = $(Libsel4Dir)/tools/sel4_idl.xsd
.PHONY: FORCE

View file

@ -123,7 +123,7 @@ def main():
args = parser.parse_args()
if args.dtd is not None:
dtd = etree.DTD(args.dtd)
dtd = etree.XMLSchema(etree.parse(args.dtd))
for f in args.files:
xml = etree.parse(f)
if not dtd.validate(xml):