diff --git a/docs/changes.rst b/docs/changes.rst index 50b160553..35383ea0d 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -478,6 +478,10 @@ Bug fixes in the `array_size` attribute of the returned `CIMProperty` objects. (Issue #1031). +* Fixed the issue that the `xml:lang` attributes that are allowed on some + CIM-XML elements have been rejected by raising `ParseError`. They are now + tolerated but ignored (Issue #1033). + Cleanup ^^^^^^^ diff --git a/docs/intro.rst b/docs/intro.rst index 8de9cba38..cb850b4e6 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -516,6 +516,13 @@ specified when following the links to the standards: * The CIM-XML representation of :ref:`CIM objects` as produced by their ``tocimxml()`` and ``tocimxmlstr()`` methods conforms to :term:`DSP0201`. + Limitations: + + - The `xml:lang` attribute supported by :term:`DSP0201` on some CIM-XML + elements that can have string values is tolerated in the CIM-XML received + by pywbem, but is ignored and is not represented on the corresponding + :ref:`CIM objects`. + * The MOF as produced by the ``tomof()`` methods on :ref:`CIM objects` and as parsed by the MOF compiler conforms to :term:`DSP0004`. diff --git a/pywbem/tupleparse.py b/pywbem/tupleparse.py index a334bfd26..a02e86acb 100644 --- a/pywbem/tupleparse.py +++ b/pywbem/tupleparse.py @@ -1029,13 +1029,16 @@ def parse_instance(tup_tree): + %ClassName; + xml:lang NMTOKEN #IMPLIED> """ - check_node(tup_tree, 'INSTANCE', ['CLASSNAME'], [], + check_node(tup_tree, 'INSTANCE', ['CLASSNAME'], ['xml:lang'], ['QUALIFIER', 'PROPERTY', 'PROPERTY.ARRAY', 'PROPERTY.REFERENCE']) + # The 'xml:lang' attribute is tolerated but ignored. + # Note: The check above does not enforce the ordering constraint in the DTD # that QUALIFIER elements must appear before PROPERTY* elements. @@ -1165,14 +1168,17 @@ def parse_qualifier(tup_tree): %CIMName; %CIMType; #REQUIRED %Propagated; - %QualifierFlavor;> + %QualifierFlavor; + xml:lang NMTOKEN #IMPLIED> """ check_node(tup_tree, 'QUALIFIER', ['NAME', 'TYPE'], ['OVERRIDABLE', 'TOSUBCLASS', 'TOINSTANCE', - 'TRANSLATABLE', 'PROPAGATED'], + 'TRANSLATABLE', 'PROPAGATED', 'xml:lang'], ['VALUE', 'VALUE.ARRAY']) + # The 'xml:lang' attribute is tolerated but ignored. + attrl = attrs(tup_tree) val = unpack_value(tup_tree) @@ -1224,14 +1230,17 @@ def parse_property(tup_tree): %CIMType; #REQUIRED %ClassOrigin; %Propagated; - %EmbeddedObject;> + %EmbeddedObject; + xml:lang NMTOKEN #IMPLIED> """ check_node(tup_tree, 'PROPERTY', ['TYPE', 'NAME'], ['CLASSORIGIN', 'PROPAGATED', 'EmbeddedObject', - 'EMBEDDEDOBJECT'], + 'EMBEDDEDOBJECT', 'xml:lang'], ['QUALIFIER', 'VALUE']) + # The 'xml:lang' attribute is tolerated but ignored. + attrl = attrs(tup_tree) try: val = unpack_value(tup_tree) @@ -1273,15 +1282,18 @@ def parse_property_array(tup_tree): %ArraySize; %ClassOrigin; %Propagated; - %EmbeddedObject;> + %EmbeddedObject; + xml:lang NMTOKEN #IMPLIED> """ check_node(tup_tree, 'PROPERTY.ARRAY', ['NAME', 'TYPE'], ['REFERENCECLASS', 'CLASSORIGIN', 'PROPAGATED', - 'ARRAYSIZE', 'EmbeddedObject', 'EMBEDDEDOBJECT'], + 'ARRAYSIZE', 'EmbeddedObject', 'EMBEDDEDOBJECT', 'xml:lang'], ['QUALIFIER', 'VALUE.ARRAY']) # TODO: Remove 'REFERENCECLASS' from attrs list, above. + # The 'xml:lang' attribute is tolerated but ignored. + values = unpack_value(tup_tree) attrl = attrs(tup_tree) diff --git a/testsuite/test_tupleparse.py b/testsuite/test_tupleparse.py index c0e8520f2..2f70ad891 100755 --- a/testsuite/test_tupleparse.py +++ b/testsuite/test_tupleparse.py @@ -4767,7 +4767,7 @@ def test_tupleparse_roundtrip( '', exp_result=CIMInstance('CIM_Foo'), ), - None, None, False # TODO 1/18 AM #1033: Enable once xml:lang supported + None, None, True ), ( "INSTANCE with properties", @@ -5147,6 +5147,16 @@ def test_tupleparse_roundtrip( ), None, None, True ), + ( + "PROPERTY with xml:lang attribute", + dict( + xml_str='' + '', + exp_result=CIMProperty('Foo', value=None, type='string', + propagated=False), + ), + None, None, True + ), ( "PROPERTY with CLASSORIGIN and PROPAGATED attributes", dict( @@ -6006,6 +6016,18 @@ def test_tupleparse_roundtrip( ), None, None, True ), + ( + "PROPERTY.ARRAY with xml:lang attribute", + dict( + xml_str='' + '', + exp_result=CIMProperty( + 'Foo', value=None, type='string', is_array=True, + propagated=False, + ), + ), + None, None, True + ), ( "PROPERTY.ARRAY with CLASSORIGIN and PROPAGATED attributes", dict( @@ -7741,6 +7763,15 @@ def test_tupleparse_roundtrip( ), None, None, True ), + ( + "QUALIFIER with xml:lang attribute", + dict( + xml_str='' + '', + exp_result=CIMQualifier('Qual', value=None, type='string'), + ), + None, None, True + ), ( "QUALIFIER with OVERRIDABLE attribute (true)", dict(