Add XSD for tree output

This commit is contained in:
~lucidiot 2022-03-10 01:20:28 +01:00
parent 6a1490dd27
commit ecaf8aead5
2 changed files with 305 additions and 0 deletions

299
assets/xsd/tree.xsd Normal file
View File

@ -0,0 +1,299 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
tree XML output schema
Copyright (c) 2022 ~lucidiot
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<xs:schema
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:annotation>
<xs:documentation>
XML Schema Definition file for the XML output of the tree command.
</xs:documentation>
</xs:annotation>
<xs:simpleType name="OctalBinary">
<xs:annotation>
<xs:documentation>
A binary value represented in octal.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:hexBinary">
<xs:pattern value="[0-7]*" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PermissionOctal">
<xs:annotation>
<xs:documentation>
Permissions serialized as an octal number.
</xs:documentation>
</xs:annotation>
<xs:restriction base="OctalBinary">
<xs:length value="2" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PermissionString">
<xs:annotation>
<xs:documentation>
Item type and permissions described as a readable string.
The first character determines the item type, and the 9 other characters describe the read, write, execute permissions for the user, group and others, respectively.
The execute permission might be shown as various other characters to denote the set-user-ID, set-group-ID or sticky bits being used.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:length value="10" />
<xs:pattern value="[bcdDlMnpPs?-][r-][w-][sStTx-][r-][w-][sStTx-][r-][w-][sStTx-]" />
</xs:restriction>
</xs:simpleType>
<xs:attributeGroup name="NodeAttributes">
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>
Name of the item.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="mode" type="PermissionOctal" use="optional">
<xs:annotation>
<xs:documentation>
Read, write and execute permissions for the item.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="prot" type="PermissionString" use="optional">
<xs:annotation>
<xs:documentation>
Item type and permissions described as a readable string.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="size" type="xs:nonNegativeInteger" use="optional">
<xs:annotation>
<xs:documentation>
Size of the item.
For directories, this can also be the total size of the directory and its items if the --du option was used.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="user" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
Name of the user that owns this item.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="group" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
Name of the group that owns this item.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="time" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
Last modification time or last status change time for the item.
Can be formatted arbitrarily using the --timefmt argument.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="inode" type="xs:nonNegativeInteger" use="optional">
<xs:annotation>
<xs:documentation>
Inode number of the item.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="device" type="xs:nonNegativeInteger" use="optional">
<xs:annotation>
<xs:documentation>
Device number to which the item belongs.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="info" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
A comment added from a .info file. Since version 2.0.0.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:simpleType name="Error">
<xs:annotation>
<xs:documentation>
An error message.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string" />
</xs:simpleType>
<xs:complexType name="Item">
<xs:sequence>
<xs:element name="error" type="Error" minOccurs="0" />
</xs:sequence>
<xs:attributeGroup ref="NodeAttributes" />
</xs:complexType>
<xs:complexType name="Directory">
<xs:annotation>
<xs:documentation>
A directory.
If the directory contents have been listed, this may contain other items.
</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="Item">
<xs:sequence>
<xs:group ref="AnyItem" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="Link">
<xs:annotation>
<xs:documentation>
A symbolic link.
If the link has been followed, this may contain other items.
</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="Directory">
<xs:attribute name="target" type="xs:string">
<xs:annotation>
<xs:documentation>
Path to the target of the symbolic link.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:group name="AnyItem">
<xs:choice>
<xs:element name="file" type="Item">
<xs:annotation>
<xs:documentation>
A regular file.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="directory" type="Directory" />
<xs:element name="link" type="Link" />
<xs:element name="char" type="Item">
<xs:annotation>
<xs:documentation>
A character device.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="block" type="Item">
<xs:annotation>
<xs:documentation>
A block device.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="fifo" type="Item">
<xs:annotation>
<xs:documentation>
A named first-in first-out (FIFO) pipe.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="socket" type="Item">
<xs:annotation>
<xs:documentation>
A socket.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="door" type="Item">
<xs:annotation>
<xs:documentation>
A Solaris door.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="port" type="Item">
<xs:annotation>
<xs:documentation>
A Solaris port.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="unknown" type="Item">
<xs:annotation>
<xs:documentation>
An unknown item.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:group>
<xs:complexType name="Report">
<xs:annotation>
<xs:documentation>
Statistics over the whole tree.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="size" type="xs:nonNegativeInteger" minOccurs="0">
<xs:annotation>
<xs:documentation>
Total size of the tree, in bytes. Only included if the --du flag is set.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="directories" type="xs:nonNegativeInteger">
<xs:annotation>
<xs:documentation>
Total number of directories.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="files" type="xs:nonNegativeInteger" minOccurs="0">
<xs:annotation>
<xs:documentation>
Total number of files. Not included if tree was set to only include directories.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Tree">
<xs:annotation>
<xs:documentation>
XML output of the tree command, from the -X argument.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:group ref="AnyItem" maxOccurs="unbounded" />
<xs:element name="report" type="Report" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:element name="tree" type="Tree" />
</xs:schema>

View File

@ -125,3 +125,9 @@ wiki for various blog articles, books, etc. that I might stumble upon and find
interesting thoughts on, to reproduce the reference system mentioned in that
book. One blog post, for which I had written an incomplete two thousand word
draft, then gave up on it, could benefit from that.
## Implementation notes
This wiki has an [everything](./everything.html) page that gets generated from
the XML output mode of the `tree` command. I wrote an XSD for it to better
document the format: [tree XSD](./xsd/tree.xsd)