Skip to content

Commit

Permalink
Add XML schema validation
Browse files Browse the repository at this point in the history
  • Loading branch information
falko committed Dec 13, 2023
1 parent e489782 commit 7085e19
Show file tree
Hide file tree
Showing 6 changed files with 1,853 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
xmllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Enable annotations for XML validation errors and warnings
uses: korelstar/xmllint-problem-matcher@v1
- name: Validate example.bpmn using BPMN20.xsd
id: xmllint
uses: ChristophWurst/[email protected]
with:
xml-file: example.bpmn
xml-schema-file: BPMN/BPMN20.xsd
37 changes: 37 additions & 0 deletions BPMN/BPMN20.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
targetNamespace="http://www.omg.org/spec/BPMN/20100524/MODEL">

<xsd:import namespace="http://www.omg.org/spec/BPMN/20100524/DI" schemaLocation="BPMNDI.xsd"/>
<xsd:include schemaLocation="Semantic.xsd"/>

<xsd:element name="definitions" type="tDefinitions"/>
<xsd:complexType name="tDefinitions">
<xsd:sequence>
<xsd:element ref="import" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="extension" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="rootElement" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="bpmndi:BPMNDiagram" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="relationship" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID" use="optional"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="targetNamespace" type="xsd:anyURI" use="required"/>
<xsd:attribute name="expressionLanguage" type="xsd:anyURI" use="optional" default="http://www.w3.org/1999/XPath"/>
<xsd:attribute name="typeLanguage" type="xsd:anyURI" use="optional" default="http://www.w3.org/2001/XMLSchema"/>
<xsd:attribute name="exporter" type="xsd:string"/>
<xsd:attribute name="exporterVersion" type="xsd:string"/>
<xsd:anyAttribute namespace="##other" processContents="lax"/>
</xsd:complexType>

<xsd:element name="import" type="tImport"/>
<xsd:complexType name="tImport">
<xsd:attribute name="namespace" type="xsd:anyURI" use="required"/>
<xsd:attribute name="location" type="xsd:string" use="required"/>
<xsd:attribute name="importType" type="xsd:anyURI" use="required"/>
</xsd:complexType>

</xsd:schema>
100 changes: 100 additions & 0 deletions BPMN/BPMNDI.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" targetNamespace="http://www.omg.org/spec/BPMN/20100524/DI" elementFormDefault="qualified" attributeFormDefault="unqualified">

<xsd:import namespace="http://www.omg.org/spec/DD/20100524/DC" schemaLocation="DC.xsd" />
<xsd:import namespace="http://www.omg.org/spec/DD/20100524/DI" schemaLocation="DI.xsd" />

<xsd:element name="BPMNDiagram" type="bpmndi:BPMNDiagram" />
<xsd:element name="BPMNPlane" type="bpmndi:BPMNPlane" />
<xsd:element name="BPMNLabelStyle" type="bpmndi:BPMNLabelStyle" />
<xsd:element name="BPMNShape" type="bpmndi:BPMNShape" substitutionGroup="di:DiagramElement" />
<xsd:element name="BPMNLabel" type="bpmndi:BPMNLabel" />
<xsd:element name="BPMNEdge" type="bpmndi:BPMNEdge" substitutionGroup="di:DiagramElement" />

<xsd:complexType name="BPMNDiagram">
<xsd:complexContent>
<xsd:extension base="di:Diagram">
<xsd:sequence>
<xsd:element ref="bpmndi:BPMNPlane" />
<xsd:element ref="bpmndi:BPMNLabelStyle" maxOccurs="unbounded" minOccurs="0" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="BPMNPlane">
<xsd:complexContent>
<xsd:extension base="di:Plane">
<xsd:attribute name="bpmnElement" type="xsd:QName" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="BPMNEdge">
<xsd:complexContent>
<xsd:extension base="di:LabeledEdge">
<xsd:sequence>
<xsd:element ref="bpmndi:BPMNLabel" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="bpmnElement" type="xsd:QName" />
<xsd:attribute name="sourceElement" type="xsd:QName" />
<xsd:attribute name="targetElement" type="xsd:QName" />
<xsd:attribute name="messageVisibleKind" type="bpmndi:MessageVisibleKind" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="BPMNShape">
<xsd:complexContent>
<xsd:extension base="di:LabeledShape">
<xsd:sequence>
<xsd:element ref="bpmndi:BPMNLabel" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="bpmnElement" type="xsd:QName" />
<xsd:attribute name="isHorizontal" type="xsd:boolean" />
<xsd:attribute name="isExpanded" type="xsd:boolean" />
<xsd:attribute name="isMarkerVisible" type="xsd:boolean" />
<xsd:attribute name="isMessageVisible" type="xsd:boolean" />
<xsd:attribute name="participantBandKind" type="bpmndi:ParticipantBandKind" />
<xsd:attribute name="choreographyActivityShape" type="xsd:QName"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="BPMNLabel">
<xsd:complexContent>
<xsd:extension base="di:Label">
<xsd:attribute name="labelStyle" type="xsd:QName" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="BPMNLabelStyle">
<xsd:complexContent>
<xsd:extension base="di:Style">
<xsd:sequence>
<xsd:element ref="dc:Font" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:simpleType name="ParticipantBandKind">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="top_initiating" />
<xsd:enumeration value="middle_initiating" />
<xsd:enumeration value="bottom_initiating" />
<xsd:enumeration value="top_non_initiating" />
<xsd:enumeration value="middle_non_initiating" />
<xsd:enumeration value="bottom_non_initiating" />
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="MessageVisibleKind">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="initiating" />
<xsd:enumeration value="non_initiating" />
</xsd:restriction>
</xsd:simpleType>

</xsd:schema>
29 changes: 29 additions & 0 deletions BPMN/DC.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" targetNamespace="http://www.omg.org/spec/DD/20100524/DC" elementFormDefault="qualified" attributeFormDefault="unqualified">

<xsd:element name="Font" type="dc:Font" />
<xsd:element name="Point" type="dc:Point" />
<xsd:element name="Bounds" type="dc:Bounds" />

<xsd:complexType name="Font">
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="size" type="xsd:double" />
<xsd:attribute name="isBold" type="xsd:boolean" />
<xsd:attribute name="isItalic" type="xsd:boolean" />
<xsd:attribute name="isUnderline" type="xsd:boolean" />
<xsd:attribute name="isStrikeThrough" type="xsd:boolean" />
</xsd:complexType>

<xsd:complexType name="Point">
<xsd:attribute name="x" type="xsd:double" use="required" />
<xsd:attribute name="y" type="xsd:double" use="required" />
</xsd:complexType>

<xsd:complexType name="Bounds">
<xsd:attribute name="x" type="xsd:double" use="required" />
<xsd:attribute name="y" type="xsd:double" use="required" />
<xsd:attribute name="width" type="xsd:double" use="required" />
<xsd:attribute name="height" type="xsd:double" use="required" />
</xsd:complexType>

</xsd:schema>
100 changes: 100 additions & 0 deletions BPMN/DI.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" targetNamespace="http://www.omg.org/spec/DD/20100524/DI" elementFormDefault="qualified" attributeFormDefault="unqualified">

<xsd:import namespace="http://www.omg.org/spec/DD/20100524/DC" schemaLocation="DC.xsd" />

<xsd:element name="DiagramElement" type="di:DiagramElement" />
<xsd:element name="Diagram" type="di:Diagram" />
<xsd:element name="Style" type="di:Style" />
<xsd:element name="Node" type="di:Node" />
<xsd:element name="Edge" type="di:Edge" />
<xsd:element name="Shape" type="di:Shape" />
<xsd:element name="Plane" type="di:Plane" />
<xsd:element name="LabeledEdge" type="di:LabeledEdge" />
<xsd:element name="Label" type="di:Label" />
<xsd:element name="LabeledShape" type="di:LabeledShape" />

<xsd:complexType abstract="true" name="DiagramElement">
<xsd:sequence>
<xsd:element name="extension" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID" />
<xsd:anyAttribute namespace="##other" processContents="lax" />
</xsd:complexType>

<xsd:complexType abstract="true" name="Diagram">
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="documentation" type="xsd:string" />
<xsd:attribute name="resolution" type="xsd:double" />
<xsd:attribute name="id" type="xsd:ID" />
</xsd:complexType>

<xsd:complexType abstract="true" name="Node">
<xsd:complexContent>
<xsd:extension base="di:DiagramElement" />
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType abstract="true" name="Edge">
<xsd:complexContent>
<xsd:extension base="di:DiagramElement">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="2" name="waypoint" type="dc:Point" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType abstract="true" name="LabeledEdge">
<xsd:complexContent>
<xsd:extension base="di:Edge" />
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType abstract="true" name="Shape">
<xsd:complexContent>
<xsd:extension base="di:Node">
<xsd:sequence>
<xsd:element ref="dc:Bounds" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType abstract="true" name="LabeledShape">
<xsd:complexContent>
<xsd:extension base="di:Shape" />
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType abstract="true" name="Label">
<xsd:complexContent>
<xsd:extension base="di:Node">
<xsd:sequence>
<xsd:element ref="dc:Bounds" minOccurs="0" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType abstract="true" name="Plane">
<xsd:complexContent>
<xsd:extension base="di:Node">
<xsd:sequence>
<xsd:element ref="di:DiagramElement" maxOccurs="unbounded" minOccurs="0" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType abstract="true" name="Style">
<xsd:attribute name="id" type="xsd:ID" />
</xsd:complexType>

</xsd:schema>
Loading

0 comments on commit 7085e19

Please sign in to comment.