clish.xsd 20 KB

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