1
0

klish.xsd 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://clish.sourceforge.net/XMLSchema" targetNamespace="http://clish.sourceforge.net/XMLSchema">
  3. <xs:annotation>
  4. <xs:appinfo>XML schema for klish configuration files</xs:appinfo>
  5. <xs:documentation xml:lang="en">
  6. The klish utility uses XML files for configuration. This schema
  7. allows to validate klish XML files. To check XML files use the
  8. following command:
  9. 'xmllint --schema /path/to/klish.xsd --noout *.xml'
  10. </xs:documentation>
  11. <xs:documentation xml:lang="ru">
  12. Утилита klish использует формат XML для своих конфигурационных
  13. файлов. Схема позволяет проверить эти конфигурационные XML файлы
  14. на правильность. Следующая команда выполнит проверку:
  15. 'xmllint --schema /path/to/klish.xsd --noout *.xml'
  16. </xs:documentation>
  17. </xs:annotation>
  18. <xs:element name="KLISH" type="klish_t"/>
  19. <xs:element name="PLUGIN" type="plugin_t"/>
  20. <xs:element name="HOTKEY" type="hotkey_t"/>
  21. <xs:element name="ACTION" type="action_t"/>
  22. <xs:element name="ENTRY" type="entry_t"/>
  23. <xs:element name="VIEW" type="view_t"/> <!-- Wrapper -->
  24. <xs:element name="COMMAND" type="command_t"/> <!-- Wrapper -->
  25. <xs:element name="FILTER" type="command_t"/> <!-- Wrapper -->
  26. <xs:element name="COND" type="command_t"/> <!-- Wrapper -->
  27. <xs:element name="COMPL" type="command_t"/> <!-- Wrapper -->
  28. <xs:element name="HELP" type="command_t"/> <!-- Wrapper -->
  29. <xs:element name="PROMPT" type="command_t"/> <!-- Wrapper -->
  30. <xs:element name="PTYPE" type="ptype_t"/> <!-- Wrapper -->
  31. <xs:element name="PARAM" type="param_t"/> <!-- Wrapper -->
  32. <xs:element name="SWITCH" type="param_t"/> <!-- Wrapper -->
  33. <xs:element name="SEQ" type="param_t"/> <!-- Wrapper -->
  34. <!--
  35. *******************************************************
  36. * <KLISH> is a top level container.
  37. ********************************************************
  38. -->
  39. <xs:group name="klish_group_t">
  40. <xs:choice>
  41. <xs:element ref="PLUGIN" minOccurs="0" maxOccurs="unbounded"/>
  42. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  43. <xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
  44. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  45. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  46. </xs:choice>
  47. </xs:group>
  48. <xs:complexType name="klish_t">
  49. <xs:annotation>
  50. <xs:documentation xml:lang="en">
  51. 'KLISH' is the top level container.
  52. </xs:documentation>
  53. <xs:documentation xml:lang="ru">
  54. Тег 'KLISH' - контейнер верхнего уровня. Все остальные
  55. теги должны быть вложенными.
  56. </xs:documentation>
  57. </xs:annotation>
  58. <!-- Any order of tags and any number -->
  59. <xs:sequence>
  60. <xs:group ref="klish_group_t" minOccurs="0" maxOccurs="unbounded"/>
  61. </xs:sequence>
  62. </xs:complexType>
  63. <!--
  64. *******************************************************
  65. * <PLUGIN> is used to dynamically load plugins.
  66. * Plugin contains symbols that can be used for ACTIONs.
  67. *
  68. * name - Plugin name. If "file" attribute is not specified then plugin's
  69. * filename is autogenerated as "kplugin-<name>.so".
  70. *
  71. * [id] - Internal plugin name for references. Can be the same as "name".
  72. *
  73. * [file] - File name to use if standard autogenerated filename (using "name"
  74. * field) is not appropriate.
  75. *
  76. * The content of PLUGIN tag can be used as a config file for this plugin.
  77. * Parsing of this content must be implemented within plugin's init.
  78. *
  79. ********************************************************
  80. -->
  81. <xs:complexType name="plugin_t">
  82. <xs:annotation>
  83. <xs:documentation xml:lang="en">
  84. Load plugin with symbols (functions).
  85. </xs:documentation>
  86. <xs:documentation xml:lang="ru">
  87. Загружает плугин для использования определяемых в нем
  88. символов (функций).
  89. </xs:documentation>
  90. </xs:annotation>
  91. <xs:simpleContent>
  92. <xs:extension base="xs:string">
  93. <xs:attribute name="name" type="xs:string" use="required"/>
  94. <xs:attribute name="id" type="xs:string" use="optional"/>
  95. <xs:attribute name="file" type="xs:string" use="optional"/>
  96. </xs:extension>
  97. </xs:simpleContent>
  98. </xs:complexType>
  99. <!--
  100. *******************************************************
  101. * <HOTKEY> is used to define hotkey actions
  102. *
  103. * key - Hot-key
  104. *
  105. * cmd - Text string defines command to execute on pressing hot-key. It's like
  106. * a common user CLI input. This string will be interpreted by CLI engine.
  107. *
  108. ********************************************************
  109. -->
  110. <xs:complexType name="hotkey_t">
  111. <xs:attribute name="key" type="xs:string" use="required"/>
  112. <xs:attribute name="cmd" type="xs:string" use="required"/>
  113. </xs:complexType>
  114. <!--
  115. ********************************************************
  116. * <ACTION> specifies the action to be taken for
  117. * a command.
  118. *
  119. * In addition the optional 'sym' attribute can specify
  120. * the name of an internal command which will be invoked
  121. * to handle script.
  122. *
  123. * [sym="<symbol>"] - specify the name of an internally registered
  124. * function (symbol). The content of the ACTION tag is
  125. * taken as the arguments to this function. Plugins can define
  126. * these symbols. The "<symbol>" can be defined as "sym@plugin" i.e.
  127. * parental plugin can be defined explicitly.
  128. *
  129. * [lock="<name>"] - Named lock. It will use special lockfile while
  130. * action execution.
  131. *
  132. * [interrupt="true/false"] - The boolean field that specify that action can be
  133. * be interrupted by Ctrl^C. Default is false. Ignored for non-interactive
  134. * actions.
  135. *
  136. * [interactive="true/false"] - Is action interactive.
  137. *
  138. * [exec_on="fail/success/always/never"] - ACTION's execution depends on
  139. * return code of previous elements of ACTION chain. If the
  140. * condition is not met then ACTION will not be executed. The "always"
  141. * value means that ACTION will be always executed and chain return
  142. * code will be ignored. Default is "success".
  143. *
  144. * [update_retcode="true/false"] - The chain return value can be updated
  145. * by current ACTION's return code or ACTION's return code can be ignored.
  146. * Default is "true".
  147. *
  148. * [permanent="true/false"] - The klish can be invoked with dry-run option. In
  149. * this case all ACTIONs will be not actually executed but will always
  150. * return success. But some actions like navigation is necessary to be
  151. * executed in any case. Permanent flag will inform engine to always
  152. * execute ACTION.
  153. *
  154. * [sync="true/false"] - Common behaviour is to fork() process before ACTION
  155. * execution. But ACTION may be executed in-place (without fork()) if sync
  156. * flag is set to true. It's not recommended to use sync ACTIONs widely.
  157. * It's usefull for small fast functions only.
  158. *
  159. ********************************************************
  160. -->
  161. <xs:simpleType name="action_cond_t">
  162. <xs:restriction base="xs:string">
  163. <xs:enumeration value="fail"/>
  164. <xs:enumeration value="success"/>
  165. <xs:enumeration value="always"/>
  166. <xs:enumeration value="never"/>
  167. </xs:restriction>
  168. </xs:simpleType>
  169. <xs:complexType name="action_t">
  170. <xs:simpleContent>
  171. <xs:extension base="xs:string">
  172. <xs:attribute name="sym" type="xs:string" use="optional"/>
  173. <xs:attribute name="lock" type="xs:string" use="optional"/>
  174. <xs:attribute name="interrupt" type="xs:boolean" use="optional" default="false"/>
  175. <xs:attribute name="interactive" type="xs:boolean" use="optional" default="false"/>
  176. <xs:attribute name="exec_on" type="action_cond_t" use="optional" default="success"/>
  177. <xs:attribute name="update_retcode" type="xs:boolean" use="optional" default="true"/>
  178. <xs:attribute name="permanent" type="xs:boolean" use="optional" default="false"/>
  179. <xs:attribute name="sync" type="xs:boolean" use="optional" default="false"/>
  180. </xs:extension>
  181. </xs:simpleContent>
  182. </xs:complexType>
  183. <!--
  184. *******************************************************
  185. * <ENTRY> This tag is used to define wide class of elements.
  186. *
  187. * name - A text name for entry.
  188. *
  189. * [help] - A text string which describes the purpose of the entry.
  190. *
  191. * [container="true/false"] - If entry is container. Container entry can't
  192. * have parsable argument i.e. only container's children can be considered
  193. * as a candidates to be a appropriate instance for parsed argument.
  194. * For example VIEW is a container. It just structurizes commands but
  195. * are not commands itself. Another example of container is a SWITCH.
  196. * It describes parsing of child elements but has no special keyword
  197. * while user typing.
  198. *
  199. * [mode] - Entry mode. It can be "sequence", "switch", "empty". Default is
  200. * "sequence".
  201. *
  202. * [purpose] - Purpose of entry. It can be "common", "ptype", "prompt", "cond",
  203. * "completion", "help". Default is "common". Another "purposes" are
  204. * processed in a special ways.
  205. *
  206. * [min="<num>"] - Min number of entry occurence while user input parsing.
  207. * Default is 1.
  208. *
  209. * [max="<num>"] - Max number of entry occurence while user input parsing.
  210. * Default is 1.
  211. *
  212. * [ref="<reference>"] - Entry can reference another entry.
  213. *
  214. * [value="<val>"] - defines the user's value for subcommand. If this option
  215. * is defined the entered parameter will be compared to this
  216. * value instead the "name" field. If this field is defined
  217. * the mode of PARAM will be forced to "subcommand". The
  218. * feature is implemented to support subcommands with the
  219. * same names.
  220. *
  221. * [restore="true/false"] - Restore (or not) hierarchy level of executed
  222. * entry. Default is "false".
  223. *
  224. * [order="true/false"] - If order="true" then user can't enter previously declared
  225. * optional parameters after current validated parameter.
  226. * The allowed values is "true" or "false". It's false by default.
  227. *
  228. * [filter="true/false"] - Developer can define 'filter' command to filter stdout
  229. * of piped ("|") commands. Filter can't contain 'sync' ACTIONs. It will be
  230. * always fork()-ed. Only filters can be on the right hand to pipe "|".
  231. * Consider filters as a special type of commands.
  232. *
  233. ********************************************************
  234. -->
  235. <xs:simpleType name="entry_mode_t">
  236. <xs:restriction base="xs:string">
  237. <xs:enumeration value="sequence"/>
  238. <xs:enumeration value="switch"/>
  239. <xs:enumeration value="empty"/>
  240. </xs:restriction>
  241. </xs:simpleType>
  242. <xs:simpleType name="entry_purpose_t">
  243. <xs:restriction base="xs:string">
  244. <xs:enumeration value="common"/>
  245. <xs:enumeration value="ptype"/>
  246. <xs:enumeration value="prompt"/>
  247. <xs:enumeration value="cond"/>
  248. <xs:enumeration value="completion"/>
  249. <xs:enumeration value="help"/>
  250. </xs:restriction>
  251. </xs:simpleType>
  252. <xs:group name="entry_group_t">
  253. <xs:choice>
  254. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  255. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  256. <xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
  257. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  258. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  259. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  260. <xs:element ref="FILTER" minOccurs="0" maxOccurs="unbounded"/>
  261. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  262. <xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
  263. <xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
  264. <xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
  265. <xs:element ref="PROMPT" minOccurs="0" maxOccurs="unbounded"/>
  266. <xs:element ref="SWITCH" minOccurs="0" maxOccurs="unbounded"/>
  267. <xs:element ref="SEQ" minOccurs="0" maxOccurs="unbounded"/>
  268. </xs:choice>
  269. </xs:group>
  270. <xs:complexType name="entry_t">
  271. <!-- Any order of tags and any number -->
  272. <xs:sequence>
  273. <xs:group ref="entry_group_t" minOccurs="0" maxOccurs="unbounded"/>
  274. </xs:sequence>
  275. <xs:attribute name="name" type="xs:string" use="required"/>
  276. <xs:attribute name="help" type="xs:string" use="optional"/>
  277. <xs:attribute name="container" type="xs:boolean" use="optional" default="false"/>
  278. <xs:attribute name="mode" type="entry_mode_t" use="optional" default="switch"/>
  279. <xs:attribute name="purpose" type="entry_purpose_t" use="optional" default="common"/>
  280. <xs:attribute name="min" type="xs:string" use="optional" default="1"/>
  281. <xs:attribute name="max" type="xs:string" use="optional" default="1"/>
  282. <xs:attribute name="ref" type="xs:string" use="optional"/>
  283. <xs:attribute name="value" type="xs:string" use="optional"/>
  284. <xs:attribute name="restore" type="xs:boolean" use="optional" default="false"/>
  285. <xs:attribute name="order" type="xs:boolean" use="optional" default="false"/>
  286. <xs:attribute name="filter" type="xs:boolean" use="optional" default="false"/>
  287. </xs:complexType>
  288. <!--
  289. *******************************************************
  290. * <PTYPE> is used to define the syntax for a parameter type.
  291. *
  292. * See ENTRY tag for attributes description.
  293. *
  294. ********************************************************
  295. -->
  296. <xs:group name="ptype_group_t">
  297. <xs:choice>
  298. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  299. <xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
  300. <xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
  301. <xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
  302. <xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
  303. </xs:choice>
  304. </xs:group>
  305. <xs:complexType name="ptype_t">
  306. <xs:sequence>
  307. <xs:group ref="ptype_group_t" minOccurs="0" maxOccurs="unbounded"/>
  308. </xs:sequence>
  309. <xs:attribute name="name" type="xs:string" use="optional"/>
  310. <xs:attribute name="help" type="xs:string" use="optional"/>
  311. <xs:attribute name="ref" type="xs:string" use="optional"/>
  312. <xs:attribute name="value" type="xs:string" use="optional"/>
  313. </xs:complexType>
  314. <!--
  315. *******************************************************
  316. * <VIEW> defines the contents of a specific CLI view.
  317. *
  318. * See ENTRY tag for attributes description.
  319. *
  320. ********************************************************
  321. -->
  322. <xs:group name="view_group_t">
  323. <xs:choice>
  324. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  325. <xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
  326. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  327. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  328. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  329. <xs:element ref="FILTER" minOccurs="0" maxOccurs="unbounded"/>
  330. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  331. <xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
  332. <xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
  333. <xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
  334. <xs:element ref="PROMPT" minOccurs="0" maxOccurs="unbounded"/>
  335. <xs:element ref="SWITCH" minOccurs="0" maxOccurs="unbounded"/>
  336. <xs:element ref="SEQ" minOccurs="0" maxOccurs="unbounded"/>
  337. </xs:choice>
  338. </xs:group>
  339. <xs:complexType name="view_t">
  340. <xs:sequence>
  341. <xs:group ref="view_group_t" minOccurs="0" maxOccurs="unbounded"/>
  342. </xs:sequence>
  343. <xs:attribute name="name" type="xs:string" use="required"/>
  344. <xs:attribute name="help" type="xs:string" use="optional"/>
  345. <xs:attribute name="ref" type="xs:string" use="optional"/>
  346. </xs:complexType>
  347. <!--
  348. *******************************************************
  349. * <PARAM> This tag is used to define a parameter for a command.
  350. *
  351. * See ENTRY tag for attributes description.
  352. *
  353. ********************************************************
  354. -->
  355. <xs:group name="param_group_t">
  356. <xs:choice>
  357. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  358. <xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
  359. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  360. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  361. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  362. <xs:element ref="FILTER" minOccurs="0" maxOccurs="unbounded"/>
  363. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  364. <xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
  365. <xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
  366. <xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
  367. <xs:element ref="SWITCH" minOccurs="0" maxOccurs="unbounded"/>
  368. <xs:element ref="SEQ" minOccurs="0" maxOccurs="unbounded"/>
  369. </xs:choice>
  370. </xs:group>
  371. <xs:complexType name="param_t">
  372. <!-- Any order of tags and any number -->
  373. <xs:sequence>
  374. <xs:group ref="param_group_t" minOccurs="0" maxOccurs="unbounded"/>
  375. </xs:sequence>
  376. <xs:attribute name="name" type="xs:string" use="required"/>
  377. <xs:attribute name="help" type="xs:string" use="optional"/>
  378. <xs:attribute name="ptype" type="xs:string" use="optional"/>
  379. <xs:attribute name="mode" type="entry_mode_t" use="optional" default="sequence"/>
  380. <xs:attribute name="min" type="xs:string" use="optional" default="1"/>
  381. <xs:attribute name="max" type="xs:string" use="optional" default="1"/>
  382. <xs:attribute name="ref" type="xs:string" use="optional"/>
  383. <xs:attribute name="value" type="xs:string" use="optional"/>
  384. <xs:attribute name="order" type="xs:boolean" use="optional" default="false"/>
  385. </xs:complexType>
  386. <!--
  387. *******************************************************
  388. * <COMMAND> is used to define a command within the CLI.
  389. *
  390. * See ENTRY tag for attributes description.
  391. *
  392. ********************************************************
  393. -->
  394. <xs:complexType name="command_t">
  395. <!-- Any order of tags and any number -->
  396. <xs:sequence>
  397. <xs:group ref="entry_group_t" minOccurs="0" maxOccurs="unbounded"/>
  398. </xs:sequence>
  399. <xs:attribute name="name" type="xs:string" use="optional"/>
  400. <xs:attribute name="help" type="xs:string" use="optional"/>
  401. <xs:attribute name="mode" type="entry_mode_t" use="optional" default="sequence"/>
  402. <xs:attribute name="ref" type="xs:string" use="optional"/>
  403. <xs:attribute name="value" type="xs:string" use="optional"/>
  404. <xs:attribute name="restore" type="xs:boolean" use="optional" default="false"/>
  405. </xs:complexType>
  406. </xs:schema>