Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Schema for connectorio thing/item/link providers #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions bundles/org.connectorio.addons.managed.item/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<executions>
<execution>
<id>validate</id>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<items>
<items xmlns="https://connectorio.com/xmlns/managed/items/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
https://connectorio.com/xmlns/managed/items/1.0.0
https://connectorio.com/xmlns/managed/items-1.0.0.xsd
">

<item name="Foo" label="Custom item" category="Test">
<type>Number:Energy</type>
<tag>Measurement</tag>
<tag>Energy</tag>
<group>A</group>
<group>B</group>
<metadata>
<state-description>
<pattern>%d</pattern>
Expand All @@ -19,8 +27,6 @@
<label>y</label>
</co7io-abc>
</metadata>
<group>A</group>
<group>B</group>
<link>
<channel>foo:bar:baz</channel>
<config>
Expand All @@ -29,7 +35,10 @@
</config>
</link>
</item>

<group name="y">
<type>Group</type>
<member>Foo</member>
</group>

</items>
12 changes: 12 additions & 0 deletions bundles/org.connectorio.addons.managed.link/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<executions>
<execution>
<id>validate</id>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<links>
<links xmlns="https://connectorio.com/xmlns/managed/links/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
https://connectorio.com/xmlns/managed/links/1.0.0
https://connectorio.com/xmlns/managed/links-1.0.0.xsd
">
<link item="Foo">
<channel>modbus:data:heatpump:flow_temperature:number</channel>
<config>
Expand Down
12 changes: 12 additions & 0 deletions bundles/org.connectorio.addons.managed.thing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<executions>
<execution>
<id>validate</id>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<things>
<thing id="foo" label="Custom thing" type="a:b:c">
<things xmlns="https://connectorio.com/xmlns/managed/things/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
https://connectorio.com/xmlns/managed/things/1.0.0
https://connectorio.com/xmlns/managed/things-1.0.0.xsd
">
<thing label="Custom thing" type="a:b:c">
<id>foo:thing</id>
<bridge>foo:bridge:instance</bridge>
<config>
<foo>bar</foo>
<baz>foo</baz>
</config>
<channel id="asf" type="foo:bar">
<channel>
<id>foo:abc</id>
<type>foo:bar:channel-kindX</type>
<label>Test</label>
<config>
<a>d</a>
<b>e</b>
</config>
</channel>
</thing>
<bridge id="bar" label="Custom thing" type="a:b:d">
<bridge label="Custom thing" type="a:b:d">
<id>foo:bridge:instance</id>
</bridge>
</things>
12 changes: 10 additions & 2 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1391,16 +1391,24 @@
<configuration>
<validationSets>
<validationSet>
<dir>src/main/resources/OH-INF/</dir>
<dir>src</dir>
<includes>
<include>**/*.xml</include>
<include>main/resources/OH-INF/**/*.xml</include>
</includes>
<validating>true</validating>
</validationSet>
<validationSet>
<dir>src</dir>
<includes>
<include>test/resources/**/*.xml</include>
</includes>
<validating>true</validating>
</validationSet>
</validationSets>
<catalogHadling>strict</catalogHadling>
<catalogs>
<catalog>file:${project.basedir}/../../xsd/org.connectorio.xsd.openhab/src/main/resources/openhab-catalog.xml</catalog>
<catalog>file:${project.basedir}/../../xsd/org.connectorio.xsd.managed/src/main/resources/co7io-catalog.xml</catalog>
</catalogs>
</configuration>
<executions>
Expand Down
35 changes: 35 additions & 0 deletions xsd/org.connectorio.xsd.managed/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (C) 2019-2021 ConnectorIO Sp. z o.o.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- SPDX-License-Identifier: Apache-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.connectorio.addons</groupId>
<artifactId>xsd</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>org.connectorio.xsd.managed</artifactId>
<packaging>bundle</packaging>

<name>ConnectorIO - Addons - XSD - Managed</name>
<description>Schema resources needed for validation of connectorio's XML format for provisioning of things, items and links.</description>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (C) 2023-2023 ConnectorIO Sp. z o.o.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- SPDX-License-Identifier: Apache-2.0
-->
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<system systemId="https://connectorio.com/xmlns/managed/items-1.0.0.xsd" uri="./xsd/co7io/items-1.0.0.xsd" />
<system systemId="https://connectorio.com/xmlns/managed/links-1.0.0.xsd" uri="./xsd/co7io/links-1.0.0.xsd" />
<system systemId="https://connectorio.com/xmlns/managed/things-1.0.0.xsd" uri="./xsd/co7io/things-1.0.0.xsd" />
<system systemId="./common-1.0.0.xsd" uri="./xsd/co7io/common-1.0.0.xsd" />
</catalog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (C) 2023-2023 ConnectorIO Sp. z o.o.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- SPDX-License-Identifier: Apache-2.0
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:annotation>
<xs:documentation>This schema defines .
</xs:documentation>
</xs:annotation>

<xs:complexType name="typedReference">
<xs:simpleContent>
<xs:extension base="typedId-2s" />
</xs:simpleContent>
</xs:complexType>

<xs:simpleType name="typedId-2s">
<xs:annotation>
<xs:documentation>Typed identifier with at least two segments.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Za-z_][A-Za-z0-9\-_]*(:[A-Za-z_][A-Za-z0-9\-_]*)+" />
</xs:restriction>
</xs:simpleType>

<xs:complexType name="reference">
<xs:simpleContent>
<xs:extension base="id" />
</xs:simpleContent>
</xs:complexType>

<xs:simpleType name="id">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Za-z_][A-Za-z0-9_]*" />
</xs:restriction>
</xs:simpleType>

<xs:complexType name="config">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:any processContents="lax" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="metadata">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:any processContents="lax" />
</xs:sequence>
</xs:complexType>

</xs:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (C) 2023-2023 ConnectorIO Sp. z o.o.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- SPDX-License-Identifier: Apache-2.0
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
xmlns:tns="https://connectorio.com/xmlns/managed/items/1.0.0"
targetNamespace="https://connectorio.com/xmlns/managed/items/1.0.0">

<xs:include schemaLocation="./common-1.0.0.xsd" />

<xs:complexType name="items">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="item" type="tns:item" />
<xs:element name="group" type="tns:group" />
</xs:choice>
</xs:complexType>

<xs:complexType name="item">
<xs:sequence>
<xs:element name="type" type="xs:string" />
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="group" type="tns:reference" />
<xs:element name="tag" type="tns:id" />
</xs:choice>
<xs:element name="metadata" type="tns:metadata" minOccurs="0" />
<xs:element name="link" type="tns:embeddedLink" minOccurs="0" />
</xs:sequence>
<xs:attribute name="name" type="tns:id" use="required" />
<xs:attribute name="label" type="xs:string" />
<xs:attribute name="category" type="tns:id" />
</xs:complexType>

<xs:complexType name="group">
<xs:sequence>
<xs:element name="type" type="xs:string" fixed="Group" />
<xs:element name="group" type="tns:reference" minOccurs="0" />
<xs:element name="tag" type="tns:id" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="metadata" type="tns:metadata" minOccurs="0" />
<xs:element name="member" type="tns:reference" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="name" type="tns:id" use="required" />
<xs:attribute name="label" type="xs:string" />
<xs:attribute name="category" type="tns:id" />
</xs:complexType>

<xs:complexType name="embeddedLink">
<xs:sequence>
<xs:element name="channel" type="tns:typedReference" />
<xs:element name="config" type="tns:config" minOccurs="0" />
</xs:sequence>
</xs:complexType>

<xs:element name="items" type="tns:items" />

</xs:schema>
Loading