Package pywbem :: Module cim_xml |
[frames] | no frames]

# Source Code for Module pywbem.cim_xml

       1  #
       2  # (C) Copyright 2003-2006 Hewlett-Packard Development Company, L.P.
       3  # (C) Copyright 2006-2007 Novell, Inc.
       4  #
       5  # This library is free software; you can redistribute it and/or
       6  # modify it under the terms of the GNU Lesser General Public
       7  # License as published by the Free Software Foundation; either
       8  # version 2.1 of the License, or (at your option) any later version.
       9  #
      10  # This program is distributed in the hope that it will be useful, but
      11  # WITHOUT ANY WARRANTY; without even the implied warranty of
      12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13  # Lesser General Public License for more details.
      14  #
      15  # You should have received a copy of the GNU Lesser General Public
      16  # License along with this program; if not, write to the Free Software
      17  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
      18  #
      19  # Author: Tim Potter <tpot@hp.com>
      20  # Author: Bart Whiteley <bwhiteley@suse.de>
      21  #
      22
      23  """
      24
      25  Functions to create XML documens and elements conforming to the DMTF
      26  standard DSP0201, Representation of CIM in XML, v2.2.
      27
      28    http://www.dmtf.org/standards/wbem/DSP201.html
      29    http://www.dmtf.org/standards/published_documents/DSP201.pdf
      30
      31  Elements generated by this module should conform to version 2.2 of the
      32  DTD:
      33
      34    http://www.dmtf.org/standards/wbem/CIM_DTD_V22.dtd
      35
      36  There should be one class for each element described in the DTD.  The
      37  constructors take builtin Python types, or other cim_xml classes where
      38  child elements are required.
      39
      40  Every class is a subclass of the Element class and so shares the same
      41  attributes and methods, and can be used with the built-in Python XML
      42  handling routines.  In particular you can call the toxml() and
      43  toprettyxml() methods to generate XML.
      44
      45  Note that converting using toprettyxml() inserts whitespace which may
      46  corrupt the data in the XML (!!) so you should only do this when
      47  displaying to humans who can ignore it, and never for computers.  XML
      48  always passes through all non-markup whitespace.
      49
      50  """
      51
      52  import sys
      53  import xml.dom.minidom
      54  from xml.dom.minidom import Element
      55
      56  __all__ = ['CIMElement', 'CIM', 'DECLARATION', 'DECLGROUP',
      57             'DECLGROUP_WITHNAME', 'DECLGROUP_WITHPATH', 'QUALIFIER_DECLARATION',
      58             'SCOPE', 'VALUE', 'VALUE_ARRAY', 'VALUE_REFERENCE',
      59             'VALUE_REFARRAY', 'VALUE_OBJECT', 'VALUE_NAMEDINSTANCE',
      60             'VALUE_NAMEDOBJECT', 'VALUE_OBJECTWITHLOCALPATH',
      61             'VALUE_OBJECTWITHPATH', 'VALUE_NULL', 'NAMESPACEPATH',
      62             'LOCALNAMESPACEPATH', 'HOST', 'NAMESPACE', 'CLASSPATH',
      63             'LOCALCLASSPATH', 'CLASSNAME', 'INSTANCEPATH', 'LOCALINSTANCEPATH',
      64             'INSTANCENAME', 'OBJECTPATH', 'KEYBINDING', 'KEYVALUE', 'CLASS',
      65             'INSTANCE', 'QUALIFIER', 'PROPERTY', 'PROPERTY_ARRAY',
      66             'PROPERTY_REFERENCE', 'METHOD', 'PARAMETER', 'PARAMETER_REFERENCE',
      67             'PARAMETER_ARRAY', 'PARAMETER_REFARRAY',
      68             'TABLECELL_DECLARATION', 'TABLECELL_REFERENCE',
      69             'TABLEROW_DECLARATION', 'TABLE','TABLEROW',
      70             'MESSAGE', 'MULTIREQ', 'MULTIEXPREQ', 'SIMPLEREQ', 'SIMPLEEXPREQ',
      71             'IMETHODCALL', 'METHODCALL', 'EXPMETHODCALL', 'PARAMVALUE',
      72             'IPARAMVALUE', 'EXPPARAMVALUE', 'MULTIRSP', 'MULTIEXPRSP',
      73             'SIMPLERSP', 'SIMPLEEXPRSP', 'METHODRESPONSE', 'EXPMETHODRESPONSE',
      74             'IMETHODRESPONSE', 'ERROR', 'RETURNVALUE', 'IRETURNVALUE',
      75             'RESPONSEDESTINATION', 'SIMPLEREQACK']
      76
      77 -def _text(data):
      78      """Return a minidom text node with the specified data string.
      79
      80      When converting that node to an XML string using ``toxml()``, XML-escaping
      81      will be applied if needed (for example, ``_text('&').toxml() = '&amp;'``).
      82
      83      Note: The API for the minidom text node function has changed in
      84      Python 2.3.  The code for older Python versions has been removed from this
      85      function in PyWBEM 0.8.0; the Python version check is now done in
      86      __init__.py.
      87      """
      88
      89      # The following initialization approach requires Python 2.3 or higher.
      90      t = xml.dom.minidom.Text()
      91      t.data = data
      92
      93      return t
      94
      95  # Switch controlling whether the escaping of special XML characters in any
      96  # request messages sent to the WBEM server will be done using CDATA
      97  # sections (if True), or using XML entity references (e.g. &amp;) (if
      98  # False).
      99  # Using XML-based escaping generates a simpler CIM-XML payload.
     100  # Standards-conforming WBEM servers need to support both ways.
     101  # You only need to set this to True if the WBEM server has no support for
     102  # XML-based escaping, but does have support for CDATA-based escaping.
     103  _CDATA_ESCAPING = False
     104
     105 -def _pcdata_nodes(pcdata):
     106      """Return a list of minidom nodes with the properly escaped ``pcdata``
     107      inside.
     108
     109      The following special XML characters are escaped:
     110        * left angle bracket (<)
     111        * Right angle bracket (>)
     112        * Ampersand (&)
     113
     114      By default, XML-based escaping is used for these characters. XML-based
     115      escaping will cause the corresponding XML entity references to be used
     116      (for example, the ampersand character ``&`` will be represented as
     117      ``&amp;``, and the returned list contains one text node with the escaped
     118      pcdata string.
     119
     120      Nesting of escaped pcdata is naturally supported with XML-based escaping.
     121      For example, if the pcdata string is ``a&amp;b``, the XML-escaped string
     122      will be ``a&amp;amp;b``.
     123
     124      If the ``cim_xml._CDATA_ESCAPING`` switch is set to True, CDATA-based
     125      escaping is used instead. CDATA-based escaping will cause a CDATA section
     126      to be used for the entire string, or consecutive CDATA sequences (see
     127      discussion of nesting, below). The returned node list contains only CDATA
     128      section nodes. Example: The pcdata string ``a<b>c`` will become
     129      ``<![CDATA[a<b>]]>``, allowing the special XML characters to be used
     130      unchanged inside of the CDATA section.
     131
     132      Nesting of escaped pcdata is supported with CDATA-based escaping, by using
     133      the following approach: If the input pcdata string already contains CDATA
     134      sections, they are split into separate strings, splitting the CDATA end
     135      token string in the middle, and these part strings are CDATA-escaped
     136      separately. See http://en.wikipedia.org/wiki/CDATA#Nesting for details.
     137
     138      Escaping of already escaped pcdata is needed in support of nested embedded
     139      instances. That requires that each level of escaping can lateron be
     140      unescaped, one at a time.
     141      """
     142
     143      nodelist = []
     144
     145      if _CDATA_ESCAPING and type(pcdata) in (str,unicode) and \
     146         (pcdata.find("<") >= 0 or \
     147          pcdata.find(">") >= 0 or \
     148          pcdata.find("&") >= 0):
     149
     150          # In order to support nesting of CDATA sections, we represent pcdata
     151          # that already contains CDATA sections by multiple new CDATA sections
     152          # whose boundaries split the end marker of the already existing CDATA
     153          # sections.
     154
     155          pcdata_part_list = pcdata.split("]]>")
     156          # ']]>' is the complete CDATA section end marker
     157
     158          i = 0
     159          for pcdata_part in pcdata_part_list:
     160              i += 1
     161
     162              left = "" if i == 1 else "]>"
     163              # ']>' is right part of CDATA section end marker
     164
     165              right = "" if i == len(pcdata_part_list) else "]"
     166              # "]" is left part of CDATA section end marker
     167
     168              # The following initialization approach requires Python 2.3 or
     169              # higher.
     170              node = xml.dom.minidom.CDATASection()
     171              node.data = left + pcdata_part + right
     172
     173              nodelist.append(node)
     174
     175      else:
     176
     177          # The following automatically uses XML entity references for escaping.
     178          node = _text(pcdata)
     179
     180          nodelist.append(node)
     181
     182      return nodelist
     183
     184 -class CIMElement(Element):
     185      """A base class that has a few bonus helper methods."""
     186
     187 -    def setName(self, name):
     188          """Set the NAME attribute of the element."""
     189          self.setAttribute('NAME', name)
     190
     191 -    def setOptionalAttribute(self, name, value):
     192          """Set an attribute if the value parameter is not None."""
     193          if value is not None:
     194              self.setAttribute(name, value)
     195
     196 -    def appendOptionalChild(self, child):
     197          """Append a child element which can be None."""
     198          if child is not None:
     199              self.appendChild(child)
     200
     201 -    def appendChildren(self, children):
     202          """Append a list or tuple of children."""
     203          [self.appendChild(child) for child in children]
     204
     205  # Root element
     206
     207 -class CIM(CIMElement):
     208      """
     209      The CIM element is the root element of every XML Document that is
     210      valid with respect to this schema.
     211
     212      Each document takes one of two forms; it either contains a single
     213      MESSAGE element defining a CIM message (to be used in the HTTP
     214      mapping), or it contains a DECLARATION element used to declare a
     215      set of CIM objects.
     216
     217      <!ELEMENT CIM (MESSAGE | DECLARATION)>
     218      <!ATTLIST CIM
     219          CIMVERSION CDATA #REQUIRED
     220          DTDVERSION CDATA #REQUIRED>
     221      """
     222
     223 -    def __init__(self, data, cim_version, dtd_version):
     224          Element.__init__(self, 'CIM')
     225          self.setAttribute('CIMVERSION', cim_version)
     226          self.setAttribute('DTDVERSION', dtd_version)
     227          self.appendChild(data)
     228
     229  # Object declaration elements
     230
     231 -class DECLARATION(CIMElement):
     232      """
     233      The DECLARATION element defines a set of one or more declarations
     234      of CIM objects.  These are partitioned into logical declaration
     235      subsets.
     236
     237      <!ELEMENT DECLARATION (DECLGROUP | DECLGROUP.WITHNAME |
     238                             DECLGROUP.WITHPATH)+>
     239      """
     240
     241 -    def __init__(self, data):
     242          Element.__init__(self, 'DECLARATION')
     243          self.appendChildren(data)
     244
     245 -class DECLGROUP(CIMElement):
     246      """
     247      The DECLGROUP element defines a logical set of CIM Class, Instance
     248      and Qualifier declarations.  It MAY optionally include a
     249      NAMESPACEPATH or LOCALNAMESPACEPATH element which, if present,
     250      defines the common namespace in which all objects within the group
     251      are declared.
     252
     253      <!ELEMENT DECLGROUP ((LOCALNAMESPACEPATH | NAMESPACEPATH)?,
     254                           QUALIFIER.DECLARATION*, VALUE.OBJECT*)>
     255      """
     256
     257 -    def __init__(self, data):
     258          Element.__init__(self, 'DECLGROUP')
     259          self.appendChildren(data)
     260
     261 -class DECLGROUP_WITHNAME(CIMElement):
     262      # pylint: disable=invalid-name
     263      """
     264      The DECLGROUP.WITHNAME element defines a logical set of CIM Class,
     265      Instance and Qualifier declarations.  It MAY optionally include a
     266      NAMESPACEPATH or LOCALNAMESPACEPATH element which, if present,
     267      defines the common namespace in which all objects within the group
     268      are declared.
     269
     270      <!ELEMENT DECLGROUP.WITHNAME ((LOCALNAMESPACEPATH | NAMESPACEPATH)?,
     271                                     QUALIFIER.DECLARATION*, VALUE.NAMEDOBJECT*)>
     272      """
     273
     274 -    def __init__(self, data):
     275          Element.__init__(self, 'DECLGROUP.WITHNAME')
     276          self.appendChildren(data)
     277
     278 -class DECLGROUP_WITHPATH(CIMElement):
     279      # pylint: disable=invalid-name
     280      """
     281      The DECLGROUP.WITHPATH element defines a logical set of CIM Class
     282      and Instance declarations.  Each object is declared with its own
     283      independent naming and location information.
     284
     285      <!ELEMENT DECLGROUP.WITHPATH  (VALUE.OBJECTWITHPATH |
     286                                     VALUE.OBJECTWITHLOCALPATH)*>
     287      """
     288
     289 -    def __init__(self, data):
     290          Element.__init__(self, 'DECLGROUP.WITHPATH')
     291          self.appendChildren(data)
     292
     293 -class QUALIFIER_DECLARATION(CIMElement):
     294      # pylint: disable=invalid-name
     295      """
     296      The QUALIFIER.DECLARATION element defines a single CIM Qualifier
     297      declaration.
     298
     299      <!ELEMENT QUALIFIER.DECLARATION (SCOPE?, (VALUE | VALUE.ARRAY)?)>
     300      <!ATTLIST QUALIFIER.DECLARATION
     301           %CIMName;
     302           %CIMType;               #REQUIRED
     303           ISARRAY    (true|false) #IMPLIED
     304           %ArraySize;
     305           %QualifierFlavor;>
     306      """
     307
     308 -    def __init__(self, name, type, value, is_array=None,
     309                   array_size=None, qualifier_scopes={},
     310                   overridable=None, tosubclass=None,
     311                   toinstance=None, translatable=None):
     312
     313          Element.__init__(self, 'QUALIFIER.DECLARATION')
     314          self.setName(name)
     315          self.setAttribute('TYPE', type)
     316          if is_array is not None:
     317              self.setOptionalAttribute('ISARRAY', str(is_array).lower())
     318          if array_size is not None:
     319              self.setAttribute('ARRAYSIZE', str(array_size))
     320          if overridable is not None:
     321              self.setAttribute('OVERRIDABLE', str(overridable).lower())
     322          if tosubclass is not None:
     323              self.setAttribute('TOSUBCLASS', str(tosubclass).lower())
     324          if toinstance is not None:
     325              self.setAttribute('TOINSTANCE', str(toinstance).lower())
     326          if translatable is not None:
     327              self.setAttribute('TRANSLATABLE', str(translatable).lower())
     328
     329          if qualifier_scopes:
     330              scope = SCOPE(qualifier_scopes)
     331              self.appendOptionalChild(scope)
     332          if value is not None:
     333              if is_array:
     334                  xval = VALUE_ARRAY(value)
     335              else:
     336                  xval = VALUE(value)
     337              self.appendOptionalChild(xval)
     338
     339 -class SCOPE(CIMElement):
     340      """
     341      The SCOPE element defines the scope of a QUALIFIER.DECLARATION in
     342      the case that there are restrictions on the scope of the Qualifier
     343      declaration.
     344
     345      <!ELEMENT SCOPE EMPTY>
     346      <!ATTLIST SCOPE
     347           CLASS        (true|false)      'false'
     348           ASSOCIATION  (true|false)      'false'
     349           REFERENCE    (true|false)      'false'
     350           PROPERTY     (true|false)      'false'
     351           METHOD       (true|false)      'false'
     352           PARAMETER    (true|false)      'false'
     353           INDICATION   (true|false)      'false'>
     354      """
     355
     356 -    def __init__(self, scopes={}):
     357          Element.__init__(self, 'SCOPE')
     358          if 'any' in scopes and scopes['any']:
     359              scopes = {'CLASS': True,
     360                        'ASSOCIATION': True,
     361                        'REFERENCE': True,
     362                        'PROPERTY': True,
     363                        'METHOD': True,
     364                        'PARAMETER': True,
     365                        'INDICATION': True}
     366          for k, v in scopes.items():
     367              self.setOptionalAttribute(k, str(v).lower())
     368
     369  # Object value elements
     370
     371 -class VALUE(CIMElement):
     372      """
     373      The VALUE element is used to define a single (non-array and
     374      non-reference) CIM Property value, CIM Qualifier value, or a CIM
     375      Method Parameter value.
     376
     377      <!ELEMENT VALUE (#PCDATA)>
     378      """
     379
     380 -    def __init__(self, pcdata):
     381          Element.__init__(self, 'VALUE')
     382          if pcdata is not None:
     383              self.appendChildren(_pcdata_nodes(pcdata))
     384
     385 -class VALUE_ARRAY(CIMElement):
     386      # pylint: disable=invalid-name
     387      """
     388      The VALUE.ARRAY element is used to represent the value of a CIM
     389      Property or Qualifier that has an array type.
     390
     391      <!ELEMENT VALUE.ARRAY (VALUE*)>
     392      """
     393
     394 -    def __init__(self, values):
     395          Element.__init__(self, 'VALUE.ARRAY')
     396          self.appendChildren(values)
     397
     398 -class VALUE_REFERENCE(CIMElement):
     399      # pylint: disable=invalid-name
     400      """
     401      The VALUE.REFERENCE element is used to define a single CIM
     402      reference Property value.
     403
     404      <!ELEMENT VALUE.REFERENCE (CLASSPATH | LOCALCLASSPATH | CLASSNAME |
     405                                 INSTANCEPATH | LOCALINSTANCEPATH |
     406                                 INSTANCENAME)>
     407      """
     408
     409 -    def __init__(self, data):
     410          Element.__init__(self, 'VALUE.REFERENCE')
     411          self.appendChild(data)
     412
     413 -class VALUE_REFARRAY(CIMElement):
     414      # pylint: disable=invalid-name
     415      """
     416      The VALUE.REFARRAY element is used to represent the value of an
     417      array of CIM references.
     418
     419      <!ELEMENT VALUE.REFARRAY (VALUE.REFERENCE*)>
     420      """
     421
     422 -    def __init__(self, data):
     423          Element.__init__(self, 'VALUE.REFARRAY')
     424          self.appendChildren(data)
     425
     426 -class VALUE_OBJECT(CIMElement):
     427      # pylint: disable=invalid-name
     428      """
     429      The VALUE.OBJECT element is used to define a value which is
     430      comprised of a single CIM Class or Instance definition.
     431
     432      <!ELEMENT VALUE.OBJECT (CLASS | INSTANCE)>
     433      """
     434
     435 -    def __init__(self, data):
     436          Element.__init__(self, 'VALUE.OBJECT')
     437          self.appendChild(data)
     438
     439 -class VALUE_NAMEDINSTANCE(CIMElement):
     440      # pylint: disable=invalid-name
     441      """
     442      The VALUE.NAMEDINSTANCE element is used to define a value which
     443      is comprised of a single named CIM Instance definition.
     444
     445      <!ELEMENT VALUE.NAMEDINSTANCE (INSTANCENAME, INSTANCE)>
     446      """
     447
     448 -    def __init__(self, instancename, instance):
     449          Element.__init__(self, 'VALUE.NAMEDINSTANCE')
     450          self.appendChild(instancename)
     451          self.appendChild(instance)
     452
     453 -class VALUE_NAMEDOBJECT(CIMElement):
     454      # pylint: disable=invalid-name
     455      """
     456      The VALUE.NAMEDOBJECT element is used to define a value which
     457      is comprised of a single named CIM Class or Instance definition.
     458
     459      <!ELEMENT VALUE.NAMEDOBJECT (CLASS | (INSTANCENAME, INSTANCE))>
     460      """
     461
     462 -    def __init__(self, data):
     463          Element.__init__(self, 'VALUE.NAMEDOBJECT')
     464          if type(data) == tuple or type(data) == list:
     465              self.appendChildren(data)
     466          else:
     467              self.appendChild(data)
     468
     469 -class VALUE_OBJECTWITHLOCALPATH(CIMElement):
     470      # pylint: disable=invalid-name
     471      """
     472      The VALUE.OBJECTWITHLOCALPATH element is used to define a value
     473      which is comprised of a single CIM Object (Class or Instance)
     474      definition with additional information that defines the local path
     475      to that Object.
     476
     477      <!ELEMENT VALUE.OBJECTWITHLOCALPATH ((LOCALCLASSPATH, CLASS) |
     478                                           (LOCALINSTANCEPATH, INSTANCE))>
     479      """
     480
     481 -    def __init__(self, data1, data2):
     482          Element.__init__(self, 'VALUE.OBJECTWITHLOCALPATH')
     483          self.appendChild(data1)
     484          self.appendChild(data2)
     485
     486 -class VALUE_OBJECTWITHPATH(CIMElement):
     487      # pylint: disable=invalid-name
     488      """
     489      The VALUE.OBJECTWITHPATH element is used to define a value
     490      which is comprised of a single CIM Object (Class or Instance)
     491      definition with additional information that defines the absolute
     492      path to that Object.
     493
     494      <!ELEMENT VALUE.OBJECTWITHPATH ((CLASSPATH, CLASS) |
     495                                      (INSTANCEPATH, INSTANCE))>
     496      """
     497
     498 -    def __init__(self, data1, data2):
     499          Element.__init__(self, 'VALUE.OBJECTWITHPATH')
     500          self.appendChild(data1)
     501          self.appendChild(data2)
     502
     503 -class VALUE_NULL(CIMElement):
     504      # pylint: disable=invalid-name
     505      """
     506      The VALUE.NULL element is used to represent a TABLECELL that has
     507      no assigned value.
     508
     509      <!ELEMENT VALUE.NULL EMPTY>
     510      """
     511
     512 -    def __init__(self):
     513          Element.__init__(self, 'VALUE.NULL')
     514
     515  # Object naming and location elements
     516
     517 -class NAMESPACEPATH(CIMElement):
     518      # pylint: disable=invalid-name
     519      """
     520      The NAMESPACEPATH element is used to define a Namespace Path. It
     521      consists of a HOST element and a LOCALNAMESPACE element.
     522
     523      <!ELEMENT NAMESPACEPATH (HOST, LOCALNAMESPACEPATH)>
     524      """
     525
     526 -    def __init__(self, host, localnamespacepath):
     527          Element.__init__(self, 'NAMESPACEPATH')
     528          self.appendChild(host)
     529          self.appendChild(localnamespacepath)
     530
     531 -class LOCALNAMESPACEPATH(CIMElement):
     532      # pylint: disable=invalid-name
     533      """
     534      The LOCALNAMESPACEPATH element is used to define a local Namespace
     535      path (one without a Host component). It consists of one or more
     536      NAMESPACE elements (one for each namespace in the path).
     537
     538      <!ELEMENT LOCALNAMESPACEPATH (NAMESPACE+)>
     539      """
     540
     541 -    def __init__(self, namespaces):
     542          Element.__init__(self, 'LOCALNAMESPACEPATH')
     543          self.appendChildren(namespaces)
     544
     545 -class HOST(CIMElement):
     546      # pylint: disable=invalid-name
     547      """
     548      The HOST element is used to define a single Host. The element
     549      content MUST specify a legal value for a hostname in accordance
     550      with the CIM specification.
     551
     552      <!ELEMENT HOST (#PCDATA)>
     553      """
     554
     555 -    def __init__(self, pcdata):
     556          Element.__init__(self, 'HOST')
     557          self.appendChild(_text(pcdata))
     558
     559 -class NAMESPACE(CIMElement):
     560      # pylint: disable=invalid-name
     561      """
     562      The NAMESPACE element is used to define a single Namespace
     563      component of a Namespace path.
     564
     565      <!ELEMENT NAMESPACE EMPTY>
     566      <!ATTLIST NAMESPACE
     567          %CIMName;>
     568      """
     569
     570 -    def __init__(self, name):
     571          Element.__init__(self, 'NAMESPACE')
     572          self.setName(name)
     573
     574 -class CLASSPATH(CIMElement):
     575      # pylint: disable=invalid-name
     576      """
     577      The CLASSPATH element defines the absolute path to a CIM Class. It
     578      is formed from a namespace path and Class name.
     579
     580      <!ELEMENT CLASSPATH (NAMESPACEPATH, CLASSNAME)>
     581      """
     582
     583 -    def __init__(self, namespacepath, classname):
     584          Element.__init__(self, 'CLASSPATH')
     585          self.appendChild(namespacepath)
     586          self.appendChild(classname)
     587
     588
     589 -class LOCALCLASSPATH(CIMElement):
     590      # pylint: disable=invalid-name
     591      """
     592      The LOCALCLASSPATH element defines the a local path to a CIM
     593      Class. It is formed from a local namespace path and Class name.
     594
     595      <!ELEMENT LOCALCLASSPATH (LOCALNAMESPACEPATH, CLASSNAME)>
     596      """
     597
     598 -    def __init__(self, localnamespacepath, classname):
     599          Element.__init__(self, 'LOCALCLASSPATH')
     600          self.appendChild(localnamespacepath)
     601          self.appendChild(classname)
     602
     603 -class CLASSNAME(CIMElement):
     604      # pylint: disable=invalid-name
     605      """
     606      The CLASSNAME element defines the qualifying name of a CIM Class.
     607
     608      <!ELEMENT CLASSNAME EMPTY>
     609      <!ATTLIST CLASSNAME
     610          %CIMName;>
     611      """
     612
     613 -    def __init__(self, classname):
     614          Element.__init__(self, 'CLASSNAME')
     615          self.setName(classname)
     616
     617 -class INSTANCEPATH(CIMElement):
     618      # pylint: disable=invalid-name
     619      """
     620      The INSTANCEPATH element defines the absolute path to a CIM
     621      Instance. It is comprised of a Namespace path and an Instance Name
     622      (model path).
     623
     624      <!ELEMENT INSTANCEPATH (NAMESPACEPATH, INSTANCENAME)>
     625      """
     626
     627 -    def __init__(self, namespacepath, instancename):
     628          Element.__init__(self, 'INSTANCEPATH')
     629          self.appendChild(namespacepath)
     630          self.appendChild(instancename)
     631
     632 -class LOCALINSTANCEPATH(CIMElement):
     633      # pylint: disable=invalid-name
     634      """
     635      The LOCALINSTANCEPATH element defines the local path to a CIM
     636      Instance. It is comprised of a local Namespace path and an
     637      Instance Name (model path).
     638
     639      <!ELEMENT LOCALINSTANCEPATH (LOCALNAMESPACEPATH, INSTANCENAME)>
     640      """
     641
     642 -    def __init__(self, localpath, instancename):
     643          Element.__init__(self, 'LOCALINSTANCEPATH')
     644          self.appendChild(localpath)
     645          self.appendChild(instancename)
     646
     647 -class INSTANCENAME(CIMElement):
     648      # pylint: disable=invalid-name
     649      """
     650      The INSTANCENAME element defines the location of a CIM Instance
     651      within a Namespace (it is referred to in the CIM Specification
     652      as a Model Path). It is comprised of a class name and a key
     653      binding information.
     654
     655      If the Class has a single key property, then a single KEYVALUE or
     656      VALUE.REFERENCE subelement may be used to describe the
     657      (necessarily) unique key value without a key name. Alternatively a
     658      single KEYBINDING subelement may be used instead.
     659
     660      If the Class has more than one key property, then a KEYBINDING
     661      subelement MUST appear for each key.
     662
     663      If there are no key-bindings specified, the instance is assumed to
     664      be a singleton instance of a keyless Class.
     665
     666      <!ELEMENT INSTANCENAME (KEYBINDING* | KEYVALUE? | VALUE.REFERENCE?)>
     667      <!ATTLIST INSTANCENAME
     668          %ClassName;>
     669      """
     670
     671 -    def __init__(self, classname, data):
     672          Element.__init__(self, 'INSTANCENAME')
     673          self.setAttribute('CLASSNAME', classname)
     674          if data is not None:
     675              if type(data) == list:
     676                  self.appendChildren(data)
     677              else:
     678                  self.appendChild(data)
     679
     680 -class OBJECTPATH(CIMElement):
     681      # pylint: disable=invalid-name
     682      """
     683      The OBJECTPATH element is used to define a full path to a single
     684      CIM Object (Class or Instance).
     685
     686      <!ELEMENT OBJECTPATH (INSTANCEPATH | CLASSPATH)>
     687      """
     688
     689 -    def __init__(self, data):
     690          Element.__init__(self, 'OBJECTPATH')
     691          self.appendChild(data)
     692
     693 -class KEYBINDING(CIMElement):
     694      # pylint: disable=invalid-name
     695      """
     696      The KEYBINDING element defines a single key property value binding.
     697
     698      <!ELEMENT KEYBINDING (KEYVALUE | VALUE.REFERENCE)>
     699      <!ATTLIST KEYBINDING
     700          %CIMName;>
     701      """
     702
     703 -    def __init__(self, name, data):
     704          Element.__init__(self, 'KEYBINDING')
     705          self.setName(name)
     706          self.appendChild(data)
     707
     708 -class KEYVALUE(CIMElement):
     709      # pylint: disable=invalid-name
     710      """
     711      The KEYVALUE element defines a single property key value when the
     712      key property is a non-reference type.
     713
     714      <!ELEMENT KEYVALUE (#PCDATA)>
     715      <!ATTLIST KEYVALUE
     716          VALUETYPE    (string|boolean|numeric)  'string'
     717          %CIMType;    #IMPLIED>
     718      """
     719
     720 -    def __init__(self, data, value_type=None, cim_type=None):
     721
     722          Element.__init__(self, 'KEYVALUE')
     723
     724          if value_type is None:
     725              self.setAttribute('VALUETYPE', 'string')
     726          else:
     727              self.setAttribute('VALUETYPE', value_type)
     728
     729          self.setOptionalAttribute('TYPE', cim_type)
     730
     731          if data != None:
     732              self.appendChild(_text(data))
     733
     734  # Object definition elements
     735
     736 -class CLASS(CIMElement):
     737      # pylint: disable=invalid-name
     738      """
     739      The CLASS element defines a single CIM Class.
     740
     741      <!ELEMENT CLASS (QUALIFIER*, (PROPERTY | PROPERTY.ARRAY |
     742                       PROPERTY.REFERENCE)*, METHOD*)>
     743      <!ATTLIST CLASS
     744          %CIMName;
     745          %SuperClass;>
     746      """
     747
     748 -    def __init__(self, classname, properties=[], methods=[],
     749                   qualifiers=[], superclass=None):
     750          Element.__init__(self, 'CLASS')
     751          self.setName(classname)
     752          self.setOptionalAttribute('SUPERCLASS', superclass)
     753          self.appendChildren(qualifiers + properties + methods)
     754
     755 -class INSTANCE(CIMElement):
     756      # pylint: disable=invalid-name
     757      """
     758      The INSTANCE element defines a single CIM Instance of a CIM Class.
     759
     760      <!ELEMENT INSTANCE (QUALIFIER*, (PROPERTY | PROPERTY.ARRAY |
     761                                       PROPERTY.REFERENCE)*)>
     762      <!ATTLIST INSTANCE
     763           %ClassName;
     764           xml:lang   NMTOKEN  #IMPLIED>
     765      """
     766 -    def __init__(self, classname, properties=[], qualifiers=[],
     767                   xml_lang=None):
     768          Element.__init__(self, 'INSTANCE')
     769          self.setAttribute('CLASSNAME', classname)
     770          self.setOptionalAttribute('xml:lang', xml_lang)
     771          self.appendChildren(qualifiers + properties)
     772
     773 -class QUALIFIER(CIMElement):
     774      # pylint: disable=invalid-name
     775      """
     776      The QUALIFIER element defines a single CIM Qualifier. If the
     777      Qualifier has a non-array type, it contains a single VALUE element
     778      representing the value of the Qualifier. If the Qualifier has an
     779      array type, it contains a single VALUE.ARRAY element to represent
     780      the value.
     781
     782      If the Qualifier has no assigned value then the VALUE element MUST
     783      be absent.
     784
     785      <!ELEMENT QUALIFIER ((VALUE | VALUE.ARRAY)?)>
     786      <!ATTLIST QUALIFIER
     787          %CIMName;
     788          %CIMType;               #REQUIRED
     789          %Propagated;
     790          %QualifierFlavor;
     791          xml:lang  NMTOKEN  #IMPLIED>
     792      """
     793
     794 -    def __init__(self, name, type, value=None, propagated=None,
     795                   overridable=None, tosubclass=None, toinstance=None,
     796                   translatable=None, xml_lang=None):
     797
     798          Element.__init__(self, 'QUALIFIER')
     799
     800          self.setName(name)
     801          self.setAttribute('TYPE', type)
     802
     803          if propagated is not None:
     804              self.setAttribute('PROPAGATED', str(propagated).lower())
     805
     806          if overridable is not None:
     807              self.setAttribute('OVERRIDABLE', str(overridable).lower())
     808          if tosubclass is not None:
     809              self.setAttribute('TOSUBCLASS', str(tosubclass).lower())
     810          if toinstance is not None:
     811              self.setAttribute('TOINSTANCE', str(toinstance).lower())
     812          if translatable is not None:
     813              self.setAttribute('TRANSLATABLE', str(translatable).lower())
     814
     815          self.setOptionalAttribute('xml:lang', xml_lang)
     816
     817          self.appendOptionalChild(value)
     818
     819 -class PROPERTY(CIMElement):
     820      # pylint: disable=invalid-name
     821      """
     822      The PROPERTY element defines a single (non-array) CIM Property
     823      that is not a reference. It contains a single VALUE element
     824      representing the value of the Property.
     825
     826      If the Property has no assigned value then the VALUE element MUST be
     827      absent.
     828
     829      CIM Reference Properties are described using the
     830      PROPERTY.REFERENCE element.
     831
     832      <!ELEMENT PROPERTY (QUALIFIER*, VALUE?)>
     833      <!ATTLIST PROPERTY
     834          %CIMName;
     835          %ClassOrigin;
     836          %Propagated;
     837          %CIMType;           #REQUIRED
     838          xml:lang   NMTOKEN  #IMPLIED>
     839      """
     840
     841 -    def __init__(self, name, type, value=None, class_origin=None,
     842                   propagated=None, qualifiers=[], xml_lang=None,
     843                   embedded_object=None):
     844
     845          Element.__init__(self, 'PROPERTY')
     846
     847          self.setName(name)
     848          self.setAttribute('TYPE', type)
     849
     850          self.setOptionalAttribute('CLASSORIGIN', class_origin)
     851
     852          if propagated is not None:
     853              self.setAttribute('PROPAGATED', str(propagated).lower())
     854
     855          self.setOptionalAttribute('xml:lang', xml_lang)
     856
     857          self.setOptionalAttribute('EmbeddedObject', embedded_object)
     858          # Note on EmbeddedObject:
     859          # The CIM-XML standard requires the mixed case form, 'EmbeddedObject'.
     860          # Given that all other attributes are in upper case, this is an
     861          # inconsistency in the standard that cannot be fixed for backwards
     862          # compatibility reasons.
     863          # OpenPegasus 2.6 supported only the upper case form 'EMBEDDEDOBJECT'.
     864          # Later OpenPegasus versions fixed that by using 'EmbeddedObject' in
     865          # any responses and by accepting both 'EMBEDDEDOBJECT' and
     866          # 'EmbeddedObject' in any requests.
     867          # Adding the 'EMBEDDEDOBJECT' attribute to any requests (that is, in
     868          # this code here) in order to support the old OpenPegasus 2.6 does not
     869          # work unfortunately, because SFCB supports either form but not both
     870          # attributes in the same request.
     871          # As a result, the best choice is to use only the standards-conforming
     872          # mixed case form in any requests sent by PyWBEM.
     873
     874          self.appendChildren(qualifiers)
     875          self.appendOptionalChild(value)
     876
     877 -class PROPERTY_ARRAY(CIMElement):
     878      # pylint: disable=invalid-name
     879      """
     880      The PROPERTY.ARRAY element defines a single CIM Property with an
     881      array type. It contains a single VALUE.ARRAY element  representing
     882      the value of the Property.
     883
     884      If the Property has no assigned value then the VALUE.ARRAY element
     885      MUST be absent.
     886
     887      There is no element to model a Property that contains an array of
     888      references as this is not a valid Property type according to CIM.
     889
     890      <!ELEMENT PROPERTY.ARRAY (QUALIFIER*, VALUE.ARRAY?)>
     891      <!ATTLIST PROPERTY.ARRAY
     892         %CIMName;
     893         %CIMType;           #REQUIRED
     894         %ArraySize;
     895         %ClassOrigin;
     896         %Propagated;
     897         xml:lang   NMTOKEN  #IMPLIED>
     898      """
     899
     900 -    def __init__(self, name, type, value_array=None, array_size=None,
     901                   class_origin=None, propagated=None, qualifiers=[],
     902                   xml_lang=None, embedded_object=None):
     903
     904          Element.__init__(self, 'PROPERTY.ARRAY')
     905
     906          self.setName(name)
     907          self.setAttribute('TYPE', type)
     908
     909          if array_size is not None:
     910              self.setAttribute('ARRAYSIZE', str(array_size))
     911          self.setOptionalAttribute('CLASSORIGIN', class_origin)
     912          self.setOptionalAttribute('EmbeddedObject', embedded_object)
     913          # See the note on EmbeddedObject in PROPERTY().
     914
     915          if propagated is not None:
     916              self.setAttribute('PROPAGATED', str(propagated).lower())
     917
     918          self.setOptionalAttribute('xml:lang', xml_lang)
     919
     920          self.appendChildren(qualifiers)
     921          self.appendOptionalChild(value_array)
     922
     923 -class PROPERTY_REFERENCE(CIMElement):
     924      # pylint: disable=invalid-name
     925      """
     926      The PROPERTY.REFERENCE element models a single CIM Property with
     927      reference semantics. In future the features of XML Linking may
     928      be used to identify linking elements within the XML Document; as
     929      XML Linking is currently only at Working Draft status no explicit
     930      dependencies have been made at this point.
     931
     932      <!ELEMENT PROPERTY.REFERENCE (QUALIFIER*, VALUE.REFERENCE?)>
     933      <!ATTLIST PROPERTY.REFERENCE
     934          %CIMName;
     935          %ReferenceClass;
     936          %ClassOrigin;
     937          %Propagated;>
     938      """
     939
     940 -    def __init__(self, name, value_reference=None, reference_class=None,
     941                   class_origin=None, propagated=None, qualifiers=[]):
     942
     943          Element.__init__(self, 'PROPERTY.REFERENCE')
     944
     945          self.setName(name)
     946
     947          self.setOptionalAttribute('REFERENCECLASS', reference_class)
     948          self.setOptionalAttribute('CLASSORIGIN', class_origin)
     949
     950          if propagated is not None:
     951              self.setAttribute('PROPAGATED', str(propagated).lower());
     952
     953          self.appendChildren(qualifiers)
     954          self.appendOptionalChild(value_reference)
     955
     956 -class METHOD(CIMElement):
     957      # pylint: disable=invalid-name
     958      """
     959      The METHOD element defines a single CIM Method. It may have
     960      Qualifiers, and zero or more parameters.
     961
     962      The order of the PARAMETER, PARAMETER.REFERENCE, PARAMETER.ARRAY
     963      and PARAMETER.REFARRAY subelements is not significant.
     964
     965      <!ELEMENT METHOD (QUALIFIER*, (PARAMETER | PARAMETER.REFERENCE |
     966                                     PARAMETER.ARRAY | PARAMETER.REFARRAY)*)>
     967      <!ATTLIST METHOD
     968          %CIMName;
     969          %CIMType;          #IMPLIED
     970          %ClassOrigin;
     971          %Propagated;>
     972      """
     973
     974 -    def __init__(self, name, parameters=[], return_type=None,
     975                   class_origin=None, propagated=None, qualifiers=[]):
     976
     977          Element.__init__(self, 'METHOD')
     978
     979          self.setName(name)
     980
     981          self.setOptionalAttribute('TYPE', return_type)
     982          self.setOptionalAttribute('CLASSORIGIN', class_origin)
     983
     984          if propagated is not None:
     985              self.setAttribute('PROPAGATED', str(propagated).lower())
     986
     987          self.appendChildren(qualifiers + parameters)
     988
     989 -class PARAMETER(CIMElement):
     990      # pylint: disable=invalid-name
     991      """
     992      The PARAMETER element defines a single (non-array, non-reference)
     993      Parameter to a CIM Method. The parameter MAY have zero or more
     994      Qualifiers.
     995
     996      <!ELEMENT PARAMETER (QUALIFIER*)>
     997      <!ATTLIST PARAMETER
     998          %CIMName;
     999          %CIMType;      #REQUIRED>
    1000      """
    1001
    1002 -    def __init__(self, name, type, qualifiers=[]):
    1003          Element.__init__(self, 'PARAMETER')
    1004          self.setName(name)
    1005          self.setAttribute('TYPE', type)
    1006          self.appendChildren(qualifiers)
    1007
    1008 -class PARAMETER_REFERENCE(CIMElement):
    1009      # pylint: disable=invalid-name
    1010      """
    1011      The PARAMETER.REFERENCE element defines a single reference
    1012      Parameter to a CIM Method. The parameter MAY have zero or more
    1013      Qualifiers.
    1014
    1015      <!ELEMENT PARAMETER.REFERENCE (QUALIFIER*)>
    1016      <!ATTLIST PARAMETER.REFERENCE
    1017          %CIMName;
    1018          %ReferenceClass;>
    1019      """
    1020
    1021 -    def __init__(self, name, reference_class=None, qualifiers=[]):
    1022          Element.__init__(self, 'PARAMETER.REFERENCE')
    1023          self.setName(name)
    1024          self.setOptionalAttribute('REFERENCECLASS', reference_class)
    1025          self.appendChildren(qualifiers)
    1026
    1027 -class PARAMETER_ARRAY(CIMElement):
    1028      # pylint: disable=invalid-name
    1029      """
    1030      The PARAMETER.ARRAY element defines a single Parameter to a CIM
    1031      Method that has an array type. The parameter MAY have zero or more
    1032      Qualifiers.
    1033
    1034      <!ELEMENT PARAMETER.ARRAY (QUALIFIER*)>
    1035      <!ATTLIST PARAMETER.ARRAY
    1036          %CIMName;
    1037          %CIMType;           #REQUIRED
    1038          %ArraySize;>
    1039      """
    1040
    1041 -    def __init__(self, name, type, array_size=None, qualifiers=[]):
    1042          Element.__init__(self, 'PARAMETER.ARRAY')
    1043          self.setName(name)
    1044          self.setAttribute('TYPE', type)
    1045          if array_size is not None:
    1046              self.setAttribute('ARRAYSIZE', str(array_size))
    1047          self.appendChildren(qualifiers)
    1048
    1049 -class PARAMETER_REFARRAY(CIMElement):
    1050      # pylint: disable=invalid-name
    1051      """
    1052      The PARAMETER.REFARRAY element defines a single Parameter to a CIM
    1053      Method that has an array of references type. The parameter MAY
    1054      have zero or more Qualifiers.
    1055
    1056      <!ELEMENT PARAMETER.REFARRAY (QUALIFIER*)>
    1057      <!ATTLIST PARAMETER.REFARRAY
    1058          %CIMName;
    1059          %ReferenceClass;
    1060          %ArraySize;>
    1061      """
    1062
    1063 -    def __init__(self, name, reference_class=None, array_size=None,
    1064                   qualifiers=[]):
    1065          Element.__init__(self, 'PARAMETER.REFARRAY')
    1066          self.setName(name)
    1067          self.setOptionalAttribute('REFERENCECLASS', reference_class)
    1068          if array_size is not None:
    1069              self.setAttribute('ARRAYSIZE', str(array_size))
    1070          self.appendChildren(qualifiers)
    1071
    1072 -class TABLECELL_DECLARATION(CIMElement):
    1073      # pylint: disable=invalid-name
    1074      """
    1075      The TABLECELL.DECLARATION element describes a TABLECELL that is
    1076      not a reference or an array of references.
    1077
    1078
    1079      <!ELEMENT TABLECELL.DECLARATION EMPTY>
    1080      <!ATTLIST TABLECELL.DECLARATION
    1081          %CIMName;
    1082          %CIMType;                    #REQUIRED
    1083          ISARRAY         (true|false) "false"
    1084          %ARRAYSIZE;
    1085          CELLPOS          CDATA       #REQUIRED
    1086          SORTPOS          CDATA       #IMPLIED
    1087          SORTDIR        (ASC|DESC)    #IMPLIED>
    1088      """
    1089
    1090 -class TABLECELL_REFERENCE(CIMElement):
    1091      # pylint: disable=invalid-name
    1092      """
    1093
    1094      The TABLECELL.REFERENCE element defines a TABLECELL that contains
    1095      reference or reference array values.
    1096
    1097      <!ELEMENT TABLECELL.REFERENCE EMPTY>
    1098      <!ATTLIST TABLECELL.REFERENCE
    1099          %CIMName;
    1100          %ReferenceClass;             #REQUIRED
    1101          ISARRAY        (true|false)  "false"
    1102          %ARRAYSIZE;
    1103          CELLPOS         CDATA        #REQUIRED
    1104          SORTPOS          CDATA       #IMPLIED
    1105          SORTDIR         (ASC|DESC)   #IMPLIED>
    1106       """
    1107
    1108 -class TABLEROW_DECLARATION(CIMElement):
    1109      # pylint: disable=invalid-name
    1110      """
    1111
    1112      The TABLEROW.DECLARATION element contains a definition for each
    1113      TABLECELL in the TABLEROW.
    1114
    1115      <!ELEMENT TABLEROW.DECLARATION (TABLECELL.DECLARATION
    1116                                      | TABLECELL.REFERENCE)*>
    1117      """
    1118
    1119 -class TABLE(CIMElement):
    1120      # pylint: disable=invalid-name
    1121      """
    1122      The TABLE element defines the result of a CIM Query.  A TABLE
    1123      element consists of a TABLEROW.DECLARATION followed by 0 or more
    1124      rows.
    1125
    1126      <!ELEMENT TABLE(TABLEROW.DECLARATION,(TABLEROW)*)>
    1127      """
    1128
    1129 -class TABLEROW(CIMElement):
    1130      # pylint: disable=invalid-name
    1131      """
    1132
    1133      The TABLEROW element defines the values for a single row of a
    1134      table.  A value for each cell of the row MUST be specified.  If a
    1135      value has no assigned value, the VALUE.NULL element MUST be used.
    1136
    1137      <!ELEMENT TABLEROW (VALUE | VALUE.ARRAY | VALUE.REFERENCE |
    1138                          VALUE.REFARRAY | VALUE.NULL)*>
    1139      """
    1140
    1141  # Message elements
    1142
    1143 -class MESSAGE(CIMElement):
    1144      # pylint: disable=invalid-name
    1145      """
    1146      The MESSAGE element models a single CIM message.  This element is
    1147      used as the basis for CIM Operation Messages and CIM Export
    1148      Messages.
    1149
    1150      <!ELEMENT MESSAGE (SIMPLEREQ | MULTIREQ | SIMPLERSP | MULTIRSP |
    1151                         SIMPLEEXPREQ | MULTIEXPREQ | SIMPLEEXPRSP |
    1152                         MULTIEXPRSP)>
    1153      <!ATTLIST MESSAGE
    1154          ID CDATA #REQUIRED
    1155          PROTOCOLVERSION CDATA #REQUIRED>
    1156      """
    1157
    1158 -    def __init__(self, data, message_id, protocol_version):
    1159          Element.__init__(self, 'MESSAGE')
    1160          self.setAttribute('ID', message_id)
    1161          self.setAttribute('PROTOCOLVERSION', protocol_version)
    1162          self.appendChild(data)
    1163
    1164 -class MULTIREQ(CIMElement):
    1165      # pylint: disable=invalid-name
    1166      """
    1167      The MULTIREQ element defines a Multiple CIM Operation request.  It
    1168      contains two or more subelements defining the SIMPLEREQ elements
    1169      that make up this multiple request.
    1170
    1171      <!ELEMENT MULTIREQ (SIMPLEREQ, SIMPLEREQ+)>
    1172      """
    1173
    1174 -    def __init__(self, data):
    1175          Element.__init__(self, 'MULTIREQ')
    1176          self.appendChildren(data)
    1177
    1178 -class MULTIEXPREQ(CIMElement):
    1179      # pylint: disable=invalid-name
    1180      """
    1181      The MULTIEXPREQ element defines a Multiple CIM Export request.  It
    1182      contains two or more subelements defining the SIMPLEEXPREQ
    1183      elements that make up this multiple request.
    1184
    1185      <!ELEMENT MULTIEXPREQ (SIMPLEEXPREQ, SIMPLEEXPREQ+)>
    1186      """
    1187
    1188 -    def __init__(self, data):
    1189          Element.__init__(self, 'MULTIEXPREQ')
    1190          self.appendChildren(data)
    1191
    1192 -class SIMPLEREQ(CIMElement):
    1193      # pylint: disable=invalid-name
    1194      """
    1195      The SIMPLEREQ element defines a Simple CIM Operation request.  It
    1196      contains either a METHODCALL (extrinsic method) element or an
    1197      IMETHODCALL (intrinsic method) element.
    1198
    1199      <!ELEMENT SIMPLEREQ (IMETHODCALL | METHODCALL)>
    1200      """
    1201
    1202 -    def __init__(self, data):
    1203          Element.__init__(self, 'SIMPLEREQ')
    1204          self.appendChild(data)
    1205
    1206 -class SIMPLEEXPREQ(CIMElement):
    1207      # pylint: disable=invalid-name
    1208      """
    1209      The SIMPLEEXPREQ element defines a Simple CIM Export request.  It
    1210      contains an EXPMETHODCALL (export method).
    1211
    1212      <!ELEMENT SIMPLEEXPREQ (EXPMETHODCALL)>
    1213      """
    1214
    1215 -    def __init__(self, data):
    1216          Element.__init__(self, 'SIMPLEEXPREQ')
    1217          self.appendChild(data)
    1218
    1219 -class IMETHODCALL(CIMElement):
    1220      # pylint: disable=invalid-name
    1221      """
    1222      The IMETHODCALL element defines a single intrinsic method
    1223      invocation.  It specifies the target local namespace, followed by
    1224      zero or more IPARAMVALUE subelements as the parameter values to be
    1225      passed to the method. If the RESPONSEDESTINATION element is
    1226      specified, the intrinsic method call MUST be interpreted as an
    1227      asynchronous method call.
    1228
    1229      <!ELEMENT IMETHODCALL (LOCALNAMESPACEPATH, IPARAMVALUE*,
    1230                             RESPONSEDESTINATION?)>
    1231      <!ATTLIST IMETHODCALL
    1232          %CIMName;>
    1233      """
    1234
    1235 -    def __init__(self, name, localnamespacepath, iparamvalues=[],
    1236                   responsedestination=None):
    1237          Element.__init__(self, 'IMETHODCALL')
    1238          self.setName(name)
    1239          self.appendChild(localnamespacepath)
    1240          self.appendChildren(iparamvalues)
    1241          self.appendOptionalChild(responsedestination)
    1242
    1243 -class METHODCALL(CIMElement):
    1244      # pylint: disable=invalid-name
    1245      """
    1246      The METHODCALL element defines a single method invocation on a
    1247      Class or Instance.  It specifies the local path of the target
    1248      Class or Instance, followed by zero or more PARAMVALUE subelements
    1249      as the parameter values to be passed to the method. If the
    1250      RESPONSEDESTINATION element is specified, the method call MUST be
    1251      interpreted as an asynchronous method call.
    1252
    1253      <!ELEMENT METHODCALL ((LOCALINSTANCEPATH | LOCALCLASSPATH), PARAMVALUE*,
    1254                            RESPONSEDESTINATION?)>
    1255      <!ATTLIST METHODCALL
    1256          %CIMName;>
    1257      """
    1258
    1259 -    def __init__(self, name, localpath, paramvalues=[],
    1260                   responsedestination=None):
    1261          Element.__init__(self, 'METHODCALL')
    1262          self.setName(name)
    1263          self.appendChild(localpath)
    1264          self.appendChildren(paramvalues)
    1265          self.appendOptionalChild(responsedestination)
    1266
    1267 -class EXPMETHODCALL(CIMElement):
    1268      # pylint: disable=invalid-name
    1269      """
    1270      The EXPMETHODCALL element defines a single export method
    1271      invocation.  It specifies zero or more  <EXPPARAMVALUE>
    1272      subelements as the parameter values to be passed to the method.
    1273
    1274      <!ELEMENT EXPMETHODCALL (EXPPARAMVALUE*)>
    1275      <!ATTLIST EXPMETHODCALL
    1276          %CIMName;>
    1277      """
    1278
    1279 -    def __init__(self, name, params=[]):
    1280          Element.__init__(self, 'EXPMETHODCALL')
    1281          self.setName(name)
    1282          self.appendChildren(params)
    1283
    1284 -class PARAMVALUE(CIMElement):
    1285      # pylint: disable=invalid-name
    1286      """
    1287      The PARAMVALUE element defines a single extrinsic method named
    1288      parameter value. If no subelement is present this indicates that
    1289      no value has been supplied for this parameter.
    1290
    1291      <!ELEMENT PARAMVALUE (VALUE | VALUE.REFERENCE | VALUE.ARRAY |
    1292                            VALUE.REFARRAY)?>
    1293      <!ATTLIST PARAMVALUE
    1294          %CIMName;
    1295          %ParamType;    #IMPLIED>
    1296      """
    1297
    1298 -    def __init__(self, name, data=None, paramtype=None,
    1299                   embedded_object=None):
    1300          Element.__init__(self, 'PARAMVALUE')
    1301          self.setName(name)
    1302          self.setOptionalAttribute('PARAMTYPE', paramtype)
    1303          self.setOptionalAttribute('EmbeddedObject', embedded_object)
    1304          # See the note on EmbeddedObject in PROPERTY().
    1305          self.appendOptionalChild(data)
    1306
    1307 -class IPARAMVALUE(CIMElement):
    1308      # pylint: disable=invalid-name
    1309      """
    1310      The IPARAMVALUE element defines a single intrinsic method named
    1311      parameter value. If no subelement is present this indicates that
    1312      no value has been supplied for this parameter.
    1313
    1314      <!ELEMENT IPARAMVALUE (VALUE | VALUE.ARRAY | VALUE.REFERENCE |
    1315                             INSTANCENAME | CLASSNAME | QUALIFIER.DECLARATION |
    1316                             CLASS | INSTANCE | VALUE.NAMEDINSTANCE)?>
    1317      <!ATTLIST IPARAMVALUE
    1318          %CIMName;>
    1319      """
    1320
    1321 -    def __init__(self, name, data=None):
    1322          Element.__init__(self, 'IPARAMVALUE')
    1323          self.setName(name)
    1324          self.appendOptionalChild(data)
    1325
    1326 -class EXPPARAMVALUE(CIMElement):
    1327      # pylint: disable=invalid-name
    1328      """
    1329      The EXPPARAMVALUE element defines a single export method named
    1330      parameter value.  If no subelement is present this indicates that
    1331      no value has been supplied for this parameter.
    1332
    1333      <!ELEMENT EXPPARAMVALUE (INSTANCE? | VALUE? | METHODRESPONSE? |
    1334                               IMETHODRESPONSE?)>
    1335      <!ATTLIST EXPPARAMVALUE
    1336          %CIMName;
    1337          %ParamType;  #IMPLIED>
    1338      """
    1339
    1340 -    def __init__(self, name, data=None, param_type=None):
    1341          Element.__init__(self, 'EXPPARAMVALUE')
    1342          self.setName(name)
    1343          self.setOptionalAttribute('PARAMTYPE', param_type)
    1344          self.appendOptionalChild(data)
    1345
    1346 -class MULTIRSP(CIMElement):
    1347      # pylint: disable=invalid-name
    1348      """
    1349      The MULTIRSP element defines a Multiple CIM Operation response.
    1350      It contains two or more subelements defining the SIMPLERSP
    1351      elements that make up this multiple response.
    1352
    1353      <!ELEMENT MULTIRSP (SIMPLERSP, SIMPLERSP+)>
    1354      """
    1355
    1356 -    def __init__(self, data):
    1357          Element.__init__(self, 'MULTIRSP')
    1358          self.appendChildren(data)
    1359
    1360 -class MULTIEXPRSP(CIMElement):
    1361      # pylint: disable=invalid-name
    1362      """
    1363      The MULTIEXPRSP element defines a Multiple CIM Export response.
    1364      It contains two or more subelements defining the SIMPLEEXPRSP
    1365      elements that make up this multiple response.
    1366
    1367      <!ELEMENT MULTIEXPRSP (SIMPLEEXPRSP, SIMPLEEXPRSP+)>
    1368      """
    1369
    1370 -    def __init__(self, data):
    1371          Element.__init__(self, 'MULTIEXPRSP')
    1372          self.appendChildren(data)
    1373
    1374 -class SIMPLERSP(CIMElement):
    1375      # pylint: disable=invalid-name
    1376      """
    1377      The SIMPLERSP element defines a Simple CIM Operation response.  It
    1378      contains either a METHODRESPONSE (for extrinsic methods),
    1379      IMETHODRESPONSE (for intrinsic methods) or a SIMPLEREQACK
    1380      subelement.
    1381
    1382      <!ELEMENT SIMPLERSP (METHODRESPONSE | IMETHODRESPONSE | SIMPLEREQACK)>
    1383      """
    1384
    1385 -    def __init__(self, data):
    1386          Element.__init__(self, 'SIMPLERSP')
    1387          self.appendChild(data)
    1388
    1389 -class SIMPLEEXPRSP(CIMElement):
    1390      # pylint: disable=invalid-name
    1391      """
    1392      The SIMPLEEXPRSP element defines a Simple CIM Export response.  It
    1393      contains either a EXPMETHODRESPONSE (for export methods)
    1394      subelement.
    1395
    1396      <!ELEMENT SIMPLEEXPRSP (EXPMETHODRESPONSE)>
    1397      """
    1398
    1399 -    def __init__(self, data):
    1400          Element.__init__(self, 'SIMPLEEXPRSP')
    1401          self.appendChild(data)
    1402
    1403 -class METHODRESPONSE(CIMElement):
    1404      # pylint: disable=invalid-name
    1405      """
    1406      The METHODRESPONSE defines the response to a single CIM extrinsic
    1407      method invocation.  It contains either an ERROR subelement (to
    1408      report a fundamental error which prevented the method from
    1409      executing), or a combination of an optional return value and zero
    1410      or more out parameter values.
    1411
    1412      <!ELEMENT METHODRESPONSE (ERROR | (RETURNVALUE?, PARAMVALUE*))>
    1413      <!ATTLIST METHODRESPONSE
    1414          %CIMName;>
    1415      """
    1416
    1417 -    def __init__(self, name, data=None):
    1418          Element.__init__(self, 'METHODRESPONSE')
    1419          self.setName(name)
    1420          if data is not None:
    1421              if type(data) == tuple or type(data) == list:
    1422                  self.appendChildren(data)
    1423              else:
    1424                  self.appendChild(data)
    1425
    1426 -class EXPMETHODRESPONSE(CIMElement):
    1427      # pylint: disable=invalid-name
    1428      """
    1429      The EXPMETHODRESPONSE defines the response to a single export
    1430      method invocation.  It contains either an ERROR subelement (to
    1431      report a fundamental error which prevented the method from
    1432      executing), or an optional return value.
    1433
    1434      <!ELEMENT EXPMETHODRESPONSE (ERROR | IRETURNVALUE?)>
    1435      <!ATTLIST EXPMETHODRESPONSE
    1436          %CIMName;>
    1437      """
    1438
    1439 -    def __init__(self, name, data=None):
    1440          Element.__init__(self, 'EXPMETHODRESPONSE')
    1441          self.setName(name)
    1442          self.appendOptionalChild(data)
    1443
    1444 -class IMETHODRESPONSE(CIMElement):
    1445      # pylint: disable=invalid-name
    1446      """
    1447      The IMETHODRESPONSE defines the response to a single intrinsic CIM
    1448      method invocation.  It contains either an ERROR subelement (to
    1449      report a fundamental error which prevented the method from
    1450      executing), or an optional return value.
    1451
    1452      <!ELEMENT IMETHODRESPONSE (ERROR | IRETURNVALUE?)>
    1453      <!ATTLIST IMETHODRESPONSE
    1454          %CIMName;>
    1455      """
    1456
    1457 -    def __init__(self, name, data=None):
    1458          Element.__init__(self, 'IMETHODRESPONSE')
    1459          self.setName(name)
    1460          self.appendOptionalChild(data)
    1461
    1462 -class ERROR(CIMElement):
    1463      # pylint: disable=invalid-name
    1464      """
    1465      The ERROR element is used to define a fundamental error which
    1466      prevented a method from executing normally. It consists of a
    1467      status code, an optional description and zero or more instances
    1468      containing detailed information about the error.
    1469
    1470      <!ELEMENT ERROR (INSTANCE*)>
    1471      <!ATTLIST ERROR
    1472          CODE CDATA #REQUIRED
    1473          DESCRIPTION CDATA #IMPLIED>
    1474      """
    1475
    1476 -    def __init__(self, code, description=None, instances=[]):
    1477          Element.__init__(self, 'ERROR')
    1478          self.setAttribute('CODE', code)
    1479          self.setOptionalAttribute('DESCRIPTION', description)
    1480          self.appendChildren(instances)
    1481
    1482 -class RETURNVALUE(CIMElement):
    1483      # pylint: disable=invalid-name
    1484      """
    1485      The RETURNVALUE element specifies the value returned from an
    1486      extrinsic method call.
    1487
    1488      <!ELEMENT RETURNVALUE (VALUE | VALUE.REFERENCE)>
    1489      <!ATTLIST RETURNVALUE
    1490          %ParamType;     #IMPLIED>
    1491      """
    1492
    1493 -    def __init__(self, data, param_type=None):
    1494          Element.__init__(self, 'RETURNVALUE')
    1495          self.setOptionalAttribute('PARAMTYPE', param_type)
    1496          self.appendChild(data)
    1497
    1498 -class IRETURNVALUE(CIMElement):
    1499      # pylint: disable=invalid-name
    1500      """
    1501      The IRETURNVALUE element specifies the value returned from an
    1502      intrinsic method call.
    1503
    1504      <!ELEMENT IRETURNVALUE (CLASSNAME* | INSTANCENAME* | VALUE* |
    1505                              VALUE.OBJECTWITHPATH* |
    1506                              VALUE.OBJECTWITHLOCALPATH* | VALUE.OBJECT* |
    1507                              OBJECTPATH* | QUALIFIER.DECLARATION* |
    1508                              VALUE.ARRAY? | VALUE.REFERENCE? | CLASS* |
    1509                              INSTANCE* | VALUE.NAMEDINSTANCE*)>
    1510      """
    1511
    1512 -    def __init__(self, data):
    1513          Element.__init__(self, 'IRETURNVALUE')
    1514          self.appendOptionalChild(data)
    1515
    1516 -class RESPONSEDESTINATION(CIMElement):
    1517      # pylint: disable=invalid-name
    1518      """
    1519      The RESPONSEDESTINATION element contains an instance that
    1520      describes the desired destination for the response.
    1521
    1522      <!ELEMENT RESPONSEDESTINATON (INSTANCE)>
    1523      """
    1524
    1525 -    def __init__(self, data):
    1526          Element.__init__(self, 'RESPONSEDESTINATON')
    1527          self.appendChild(data);
    1528
    1529 -class SIMPLEREQACK(CIMElement):
    1530      # pylint: disable=invalid-name
    1531      """
    1532      The SIMPLEREQACK defines the acknowledgement response to a Simple
    1533      CIM Operation asynchronous request. The ERROR subelement is used
    1534      to report a fundamental error which prevented the asynchronous
    1535      request from being initiated.
    1536
    1537      <!ELEMENT SIMPLEREQACK (ERROR?)>
    1538      <!ATTLIST SIMPLEREQACK
    1539          INSTANCEID CDATA     #REQUIRED>
    1540      """
    1541
    1542 -    def __init__(self, instanceid, data):
    1543          Element.__init__(self, 'SIMPLEREQACK')
    1544          self.setOptionalAttribute('INSTANCEID', instanceid)
    1545          self.appendOptionalChild(data)
    1546