clish.xsd 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <?xml version="1.0"?>
  2. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://clish.sourceforge.net/XMLSchema" targetNamespace="http://clish.sourceforge.net/XMLSchema">
  3. <!--
  4. ***********************************************************
  5. * Forward declare the main element identifiers
  6. ***********************************************************
  7. -->
  8. <xs:element name="CLISH_MODULE" type="clish_module_t"/>
  9. <xs:element name="VIEW" type="view_t"/>
  10. <xs:element name="COMMAND" type="command_t"/>
  11. <xs:element name="STARTUP" type="startup_t"/>
  12. <xs:element name="ACTION" type="action_t"/>
  13. <xs:element name="OVERVIEW" type="overview_t"/>
  14. <xs:element name="DETAIL" type="detail_t"/>
  15. <xs:element name="PTYPE" type="ptype_t"/>
  16. <xs:element name="PARAM" type="param_t"/>
  17. <xs:element name="NAMESPACE" type="namespace_t"/>
  18. <xs:element name="CONFIG" type="config_t"/>
  19. <xs:element name="VAR" type="var_t"/>
  20. <!--
  21. ***********************************************************
  22. * The common simple types
  23. ***********************************************************
  24. -->
  25. <xs:simpleType name="bool_t">
  26. <xs:restriction base="xs:string">
  27. <xs:enumeration value="true"/>
  28. <xs:enumeration value="false"/>
  29. </xs:restriction>
  30. </xs:simpleType>
  31. <!--
  32. ***********************************************************
  33. * <CLISH_MODULE> is the top level container.
  34. * Any commands which are defined within this tag are global in scope
  35. * i.e. they are visible from all views.
  36. ***********************************************************
  37. -->
  38. <xs:complexType name="clish_module_t">
  39. <xs:sequence>
  40. <xs:element ref="OVERVIEW" minOccurs="0"/>
  41. <xs:element ref="STARTUP" minOccurs="0"/>
  42. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  43. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  44. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  45. <xs:element ref="NAMESPACE" minOccurs="0" maxOccurs="unbounded"/>
  46. <xs:element ref="VAR" minOccurs="0" maxOccurs="unbounded"/>
  47. </xs:sequence>
  48. </xs:complexType>
  49. <!--
  50. ***********************************************************
  51. * Identify some attribute groups
  52. ***********************************************************
  53. -->
  54. <xs:attributeGroup name="menu_item_g">
  55. <xs:attribute name="name" type="xs:string" use="required"/>
  56. <xs:attribute name="help" type="xs:string" use="required"/>
  57. </xs:attributeGroup>
  58. <!--
  59. *******************************************************
  60. * <PTYPE> is used to define the syntax for a parameter type.
  61. *
  62. * name - a textual name for this type. This name can be used to
  63. * reference this type within a <PARAM? ptype attribute.
  64. *
  65. * help - a textual string which describes the syntax of this type.
  66. * When a parameter is filled out incorrectly on the CLI, this
  67. * text will be used to prompt the user to fill out the value
  68. * correctly.
  69. *
  70. * pattern - A regular expression which defines the syntax of the type.
  71. *
  72. * method - The means by which the pattern is interpreted.
  73. *
  74. * "regexp" [default] - A POSIX regular expression.
  75. *
  76. * "integer" - A numeric definition "min..max"
  77. *
  78. * "select" - A list of possible values.
  79. * The syntax of the string is of the form:
  80. * "valueOne(ONE) valueTwo(TWO) valueThree(THREE)"
  81. * where the text before the parethesis defines the syntax
  82. * that the user must use, and the value within the parenthesis
  83. * is the result expanded as a parameter value.
  84. *
  85. * preprocess - An optional directive to process the value entered before
  86. * validating it. This can greatly simplify the regular expressions
  87. * needed to match case insensitive values.
  88. *
  89. * "none" [default] - do nothing
  90. *
  91. * "toupper" - before validation convert to uppercase.
  92. *
  93. * "tolower" - before validation convert to lowercase.
  94. *
  95. ********************************************************
  96. -->
  97. <xs:simpleType name="ptype_method_e">
  98. <xs:restriction base="xs:string">
  99. <xs:enumeration value="regexp"/>
  100. <xs:enumeration value="integer"/>
  101. <xs:enumeration value="select"/>
  102. <xs:enumeration value="choice"/>
  103. <xs:enumeration value="subcommand"/>
  104. </xs:restriction>
  105. </xs:simpleType>
  106. <xs:simpleType name="ptype_preprocess_e">
  107. <xs:restriction base="xs:string">
  108. <xs:enumeration value="none"/>
  109. <xs:enumeration value="toupper"/>
  110. <xs:enumeration value="tolower"/>
  111. </xs:restriction>
  112. </xs:simpleType>
  113. <xs:complexType name="ptype_t">
  114. <xs:attributeGroup ref="menu_item_g"/>
  115. <xs:attribute name="pattern" type="xs:string"/>
  116. <xs:attribute name="method" type="ptype_method_e" use="optional" default="regexp"/>
  117. <xs:attribute name="preprocess" type="ptype_preprocess_e" use="optional" default="none"/>
  118. </xs:complexType>
  119. <!--
  120. *******************************************************
  121. * <VIEW> defines the contents of a specific CLI view.
  122. *
  123. * name - a textual name for the view
  124. *
  125. * prompt - a textual definition of the prompt to be
  126. * used whilst in this view.
  127. * NB. The prompt may contain environment
  128. * or dynamic variables which are expanded
  129. * before display.
  130. *
  131. * [depth] - a depth of nested view (uses for config).
  132. *
  133. * [restore] - restore the depth or view of commands
  134. * contained by this view
  135. ********************************************************
  136. -->
  137. <xs:simpleType name="restore_t">
  138. <xs:restriction base="xs:string">
  139. <xs:enumeration value="none"/>
  140. <xs:enumeration value="depth"/>
  141. <xs:enumeration value="view"/>
  142. </xs:restriction>
  143. </xs:simpleType>
  144. <xs:complexType name="view_t">
  145. <xs:sequence>
  146. <xs:element ref="NAMESPACE" minOccurs="0" maxOccurs="unbounded"/>
  147. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  148. </xs:sequence>
  149. <xs:attribute name="name" type="xs:string" use="required"/>
  150. <xs:attribute name="prompt" type="xs:string" use="optional"/>
  151. <xs:attribute name="depth" type="xs:string" use="optional" default="0"/>
  152. <xs:attribute name="restore" type="restore_t" use="optional" default="none"/>
  153. </xs:complexType>
  154. <!--
  155. *******************************************************
  156. * <STARTUP> is used to define what happens when the CLI
  157. * is started. Any text held in a <DETAIL> sub-element will
  158. * be used as banner text, then any defined <ACTION> will be
  159. * executed. This action may provide Message Of The Day (MOTD)
  160. * type behaviour.
  161. *
  162. * view - defines the view which will be transitioned to, on
  163. * successful execution of any <ACTION> tag.
  164. *
  165. * [viewid] - defined the new value of the ${VIEWID} variable to
  166. * be used if a transition to a new view occurs.
  167. *
  168. * [default_shebang] - The default shebang for all commands.
  169. ********************************************************
  170. -->
  171. <xs:complexType name="startup_t">
  172. <xs:sequence>
  173. <xs:element ref="DETAIL" minOccurs="0"/>
  174. <xs:element ref="ACTION" minOccurs="0"/>
  175. </xs:sequence>
  176. <xs:attribute name="view" type="xs:string" use="required"/>
  177. <xs:attribute name="viewid" type="xs:string" use="optional"/>
  178. <xs:attribute name="default_shebang" type="xs:string" use="optional"/>
  179. </xs:complexType>
  180. <!--
  181. *******************************************************
  182. * <COMMAND> is used to define a command within the CLI.
  183. *
  184. * name - a textual name for this command. (This may contain
  185. * spaces e.g. "display acl")
  186. *
  187. * help - a textual string which describes the purpose of the
  188. * command.
  189. *
  190. * [view] - defines the view which will be transitioned to, on
  191. * successful execution of any <ACTION> tag. By default the
  192. * current view stays in scope.
  193. *
  194. * [viewid] - defined the new value of the ${VIEWID} variable to
  195. * be used if a transition to a new view occurs. By default
  196. * the viewid will retain it's current value.
  197. *
  198. * [access] - defines the user group/level to which execution of this
  199. * command is restricted. By default there is no restriction.
  200. * The exact interpretation of this field is dependant on the
  201. * client of libclish but for example the clish and tclish
  202. * applications map this to the UNIX user groups.
  203. *
  204. * [escape_chars] - defines the characters which will be escaped (e.g. \$) before
  205. * being expanded as a variable. By default the following
  206. * characters will be escaped `|$<>&()#
  207. *
  208. * [args] - defines a parameter name to be used to gather the rest of the
  209. * command line after the formally defined parameters
  210. * (PARAM elements). The formatting of this parameter is a raw
  211. * string containing as many words as there are on the rest of the
  212. * command line.
  213. *
  214. * [args_help] - a textual string which describes the purpose of the 'args'
  215. * parameter. If the "args" attribute is given then this MUST be
  216. * given also.
  217. *
  218. * [lock] - the boolean field that specify to lock lockfile while
  219. * command execution or not. Default is true.
  220. *
  221. ********************************************************
  222. -->
  223. <xs:complexType name="command_t">
  224. <xs:sequence>
  225. <xs:element ref="DETAIL" minOccurs="0"/>
  226. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  227. <xs:element ref="CONFIG" minOccurs="0"/>
  228. <xs:element ref="ACTION" minOccurs="0"/>
  229. </xs:sequence>
  230. <xs:attributeGroup ref="menu_item_g"/>
  231. <xs:attribute name="ref" type="xs:string" use="optional"/>
  232. <xs:attribute name="view" type="xs:string" use="optional"/>
  233. <xs:attribute name="viewid" type="xs:string" use="optional"/>
  234. <xs:attribute name="access" type="xs:string" use="optional"/>
  235. <xs:attribute name="args" type="xs:string" use="optional"/>
  236. <xs:attribute name="args_help" type="xs:string" use="optional"/>
  237. <xs:attribute name="escape_chars" type="xs:string" use="optional"/>
  238. <xs:attribute name="lock" type="bool_t" use="optional" default="true"/>
  239. <xs:attribute name="interrupt" type="bool_t" use="optional" default="false"/>
  240. </xs:complexType>
  241. <!--
  242. *******************************************************
  243. * <PARAM> This tag is used to define a parameter for a command.
  244. *
  245. * name - a textual name for this parameter.
  246. *
  247. * help - a textual string which describes the purpose of the
  248. * parameter.
  249. *
  250. * ptype - Reference to a PTYPE name. This parameter will be
  251. * validated against the syntax specified for that type.
  252. * The special value of "" indicates the parameter is a boolean flag.
  253. * The verbatim presence of the texual name on the command line
  254. * simply controls the conditional variable expansion for this
  255. * parameter.
  256. *
  257. * [mode] - Parameter mode. It can be "common", "switch" or
  258. * "subcommand".
  259. *
  260. * [prefix] - defines the prefix for an optional parameter. A prefix
  261. * with this value on the command line will signify the presence
  262. * of an additional argument which will be validated as the
  263. * value of this parameter.
  264. *
  265. * [optional]- Specify whether parameter is optional. The allowed values
  266. * is "true" or "false". It false by default.
  267. *
  268. * [default] - defines a default value for a parameter. Any parameters
  269. * at the end of command line which have default values need
  270. * not explicitly be entered.
  271. *
  272. * [value] - defines the user's value for subcommand. If this option
  273. * is defined the entered parameter will be compared to this
  274. * value instead the "name" field. If this field is defined
  275. * the mode of PARAM will be forced to "subcommand". The
  276. * feature is implemented to support subcommands with the
  277. * same names.
  278. *
  279. * [hidden] - define the visibility of the parameter while ${__line}
  280. * and ${__params} auto variables expanding. The allowed values
  281. * is "true" and "false".
  282. *
  283. * [test] - define the condition (see the description of 'test'
  284. * utility) to process this parameter.
  285. ********************************************************
  286. -->
  287. <xs:simpleType name="param_mode_t">
  288. <xs:restriction base="xs:string">
  289. <xs:enumeration value="common"/>
  290. <xs:enumeration value="switch"/>
  291. <xs:enumeration value="subcommand"/>
  292. </xs:restriction>
  293. </xs:simpleType>
  294. <xs:complexType name="param_t">
  295. <xs:sequence>
  296. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  297. </xs:sequence>
  298. <xs:attributeGroup ref="menu_item_g"/>
  299. <xs:attribute name="ptype" type="xs:string" use="required"/>
  300. <xs:attribute name="default" type="xs:string" use="optional"/>
  301. <xs:attribute name="prefix" type="xs:string" use="optional"/>
  302. <xs:attribute name="mode" type="param_mode_t" use="optional" default="common"/>
  303. <xs:attribute name="optional" type="bool_t" use="optional" default="false"/>
  304. <xs:attribute name="value" type="xs:string" use="optional"/>
  305. <xs:attribute name="hidden" type="bool_t" use="optional" default="false"/>
  306. <xs:attribute name="test" type="xs:string" use="optional"/>
  307. <xs:attribute name="completion" type="xs:string" use="optional"/>
  308. </xs:complexType>
  309. <!--
  310. ********************************************************
  311. * <ACTION> specifies the action to be taken for
  312. * a command.
  313. *
  314. * The textual contents of the tag are variable expanded
  315. * (environment, dynamic and parameter) the the resulting
  316. * text is interpreted by the client's script interpreter.
  317. *
  318. * In addition the optional 'builtin' attribute can specify
  319. * the name of an internal command which will be invoked
  320. * instead of the client's script handler.
  321. *
  322. * NB. for security reasons any special shell characters
  323. * (e.g. $|<>`) are escaped before evaluation.
  324. *
  325. * [builtin] - specify the name of an internally registered
  326. * function. The content of the ACTION tag is
  327. * taken as the arguments to this builtin function.
  328. *
  329. * [shebang] - specify the programm to execute the action
  330. * script.
  331. ********************************************************
  332. -->
  333. <xs:complexType name="action_t">
  334. <xs:simpleContent>
  335. <xs:extension base="xs:string">
  336. <xs:attribute name="builtin" type="xs:string" use="optional"/>
  337. <xs:attribute name="shebang" type="xs:string" use="optional"/>
  338. </xs:extension>
  339. </xs:simpleContent>
  340. </xs:complexType>
  341. <!--
  342. ********************************************************
  343. * <OVERVIEW> specifies a textual description of the shell.
  344. *
  345. * This should provide instructions about key bindings and
  346. * escape sequences which can be used in the CLI.
  347. *
  348. ********************************************************
  349. -->
  350. <xs:simpleType name="overview_t">
  351. <xs:restriction base="xs:string">
  352. <xs:whiteSpace value="preserve"/>
  353. </xs:restriction>
  354. </xs:simpleType>
  355. <!--
  356. ********************************************************
  357. * <DETAIL> specifies a textual description.
  358. *
  359. * This may be used within the scope of a <COMMAND>
  360. * element, in which case it would typically contain
  361. * detailed usage instructions including examples.
  362. *
  363. * This may also be used within the scope of a <STARTUP>
  364. * element, in which case the text is used as the banner
  365. * details which are displayed on shell startup. This is
  366. * shown before any specified <ACTION> is executed.
  367. *
  368. * This text may also be used in the production of user manuals.
  369. ********************************************************
  370. -->
  371. <xs:simpleType name="detail_t">
  372. <xs:restriction base="xs:string">
  373. <xs:whiteSpace value="preserve"/>
  374. </xs:restriction>
  375. </xs:simpleType>
  376. <!--
  377. *******************************************************
  378. * <NAMESPACE> import commands from specific view to current view.
  379. *
  380. * ref - the view to import commands from
  381. *
  382. * [prefix] - the prefix for imported commands
  383. *
  384. * [prefix_help] - the help for namespace prefix
  385. *
  386. * [help] - a boolean flag to use imported
  387. * commands while help
  388. *
  389. * [completion] - a boolean flag to use imported
  390. * commands while completion
  391. *
  392. * [context_help] - a boolean flag to use imported
  393. * commands while context help
  394. *
  395. * [inherit] - a boolean flag to inherit nested
  396. * namespace commands recursively
  397. ********************************************************
  398. -->
  399. <xs:complexType name="namespace_t">
  400. <xs:attribute name="ref" type="xs:string" use="required"/>
  401. <xs:attribute name="prefix" type="xs:string" use="optional"/>
  402. <xs:attribute name="prefix_help" type="xs:string" use="optional"/>
  403. <xs:attribute name="help" type="bool_t" use="optional" default="false"/>
  404. <xs:attribute name="completion" type="bool_t" use="optional" default="true"/>
  405. <xs:attribute name="context_help" type="bool_t" use="optional" default="false"/>
  406. <xs:attribute name="inherit" type="bool_t" use="optional" default="true"/>
  407. </xs:complexType>
  408. <!--
  409. *******************************************************
  410. * <CONFIG> Specify the config operation.
  411. *
  412. * operation - config operation to perform
  413. *
  414. ********************************************************
  415. -->
  416. <xs:simpleType name="operation_t">
  417. <xs:restriction base="xs:string">
  418. <xs:enumeration value="none"/>
  419. <xs:enumeration value="set"/>
  420. <xs:enumeration value="unset"/>
  421. <xs:enumeration value="dump"/>
  422. </xs:restriction>
  423. </xs:simpleType>
  424. <xs:complexType name="config_t">
  425. <xs:attribute name="operation" type="operation_t" use="optional" default="set"/>
  426. <xs:attribute name="priority" type="xs:string" use="optional" default="0x7f00"/>
  427. <xs:attribute name="pattern" type="xs:string" use="optional" default="^${__cmd}"/>
  428. <xs:attribute name="file" type="xs:string" use="optional" default="startup-config"/>
  429. <xs:attribute name="splitter" type="bool_t" use="optional" default="true"/>
  430. <xs:attribute name="sequence" type="xs:string" use="optional" default="0"/>
  431. <xs:attribute name="unique" type="bool_t" use="optional" default="true"/>
  432. <xs:attribute name="depth" type="xs:string" use="optional"/>
  433. </xs:complexType>
  434. <!--
  435. *******************************************************
  436. * <VAR> Specify the variable.
  437. *
  438. *
  439. *
  440. ********************************************************
  441. -->
  442. <xs:complexType name="var_t">
  443. <xs:sequence>
  444. <xs:element ref="ACTION" minOccurs="0"/>
  445. </xs:sequence>
  446. <xs:attributeGroup ref="menu_item_g"/>
  447. <xs:attribute name="value" type="xs:string" use="optional"/>
  448. <xs:attribute name="dynamic" type="bool_t" use="optional" default="false"/>
  449. </xs:complexType>
  450. </xs:schema>