clish.xsd 18 KB

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