XML Specification of the Syntax Diagram
Once you have created a syntax diagram for your extension command, you translate the diagram into an XML specification of the syntax.
<Command xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="extension.xsd"
Name="SPSSINC RASCH DEMO" Language="R" Mode="Source">
<Subcommand Name="VARIABLES">
<Parameter Name="ITEMS" ParameterType="VariableNameList"/>
</Subcommand>
<Subcommand Name="OPTIONS">
<Parameter Name="MISSING" ParameterType="Keyword">
<EnumValue Name="LISTWISE"/>
<EnumValue Name="ALLAVAILABLE"/>
</Parameter>
</Subcommand>
<Subcommand Name="HELP" Occurrence="Optional"/>
</Command>
The XML specification for the SPSSINC RASCH DEMO
command is shown here.
The top level element Command
specifies
the name of the extension command as well as the implementation language, R, Python or Java.
The command name can consist of up to three words separated by spaces and is not case sensitive, although uppercase is the convention. To reduce the risk of creating extension commands that conflict with built-in commands or commands created by other users, you should use two- or three-word command names, using the first word to specify your organization, as done here.
The Mode
attribute on the Command
element
only applies to extension commands implemented in R and specifies
whether the implementation code is contained in an R source file or
an R package. The value Source specifies the source file method and is recommended because it greatly
simplifies the distribution of an extension command to other users.
Each subcommand is specified with
a Subcommand
element. The Occurrence
attribute is optional and specifies
whether the subcommand is required. By default, subcommands are optional.
Parameter
elements describe the keywords associated with a subcommand. There
are many types of parameters, such as VariableNameList
for specifying a list of IBM® SPSS® Statistics variable names. Values specified for parameters are checked to
ensure they are valid for the particular parameter type. For instance,
values specified for a VariableNameList parameter will be checked to be sure they represent syntactically
valid IBM SPSS Statistics variable names (the
existence of the variables is not checked).
EnumValue
elements specify allowed values for a keyword, such as the values LISTWISE and ALLAVAILABLE for the MISSING
keyword in
this example.
The optional subcommand HELP
will display help for the extension command. This
is a recommended convention for extension commands. The help is provided in a separate HTML file,
which is displayed when the user specifies the HELP
subcommand.
There are no restrictions on the name of the XML specification file, although a useful convention is to use the name of the extension command in uppercase, with spaces replaced by underscores. The XML specification for the current example can be found in the file SPSSINC_RASCH_DEMO.xml, available in the Samples directory (under the installation directory).