Search code examples
pythonxmlspss

How to create an extension command with Python for SPSS?


I'm trying to create an extension command with Python for SPSS, but this is throwing me an error that I don't understand:

Warnings
This command should specify a valid subcommand at the beginning.
Execution of this command stops.

Here is my xml:

<Command
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www-01.ibm.com/software/analytics/spss/xml/extension-1.0.xsd"
Name="xxxRENAME TEST" Language="Python">
<Subcommand Name="OPTIONS" Occurrence="Optional" EqualsSign="None">
    <Parameter Name="TEST" EqualsSign="Required" ParameterType="Keyword">
        <EnumValue Name="A"/>
        <EnumValue Name="B"/>
    </Parameter>
    <Parameter Name="TEST1" EqualsSign="Required" ParameterType="Keyword">
        <EnumValue Name="C"/>
        <EnumValue Name="D"/>
    </Parameter>
    <Parameter Name="TEST2" EqualsSign="Required" ParameterType="Keyword">
        <EnumValue Name="E"/>
        <EnumValue Name="F"/>
    </Parameter>
</Subcommand>
</Command>

And my .py Run looks like that:

def Run (args):
    args=args[args.keys()[0]]
    oobj = Syntax([
        Template("TEST",subc="OPTIONS",ktype="str",var="test",vallist=["a","b"]),
        Template("TEST1",subc="OPTIONS",ktype="str",var="test1",vallist=["c","d"]),
        Template("TEST2",subc="OPTIONS",ktype="str",var="test2",vallist=["e","f"])
        ])
    processcmd(oobj,args,Renaming)

My renaming function in python was tested and works fine, so I guess the issue is in the XML or Run function? What is confusing me more is that I have an extension command with TEST and TEST1 which is working fine. If anyone has any clue...


Solution

  • Actually the name of the extension was conflicting with another one. So it was fixed by renaming it differently.