clish.xsd 18 KB

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