Skip to content

Commit

Permalink
Added toleration support for xml:lang attributes.
Browse files Browse the repository at this point in the history
Details:
- 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).
- Enabled the disabled testcases for xml:lang, and added new testcases for
  all CIM-XML elements that can have xml:lang.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Feb 5, 2018
1 parent 3110d2e commit 43f7555
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 9 deletions.
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^

Expand Down
7 changes: 7 additions & 0 deletions docs/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
28 changes: 20 additions & 8 deletions pywbem/tupleparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,13 +1029,16 @@ def parse_instance(tup_tree):
<!ELEMENT INSTANCE (QUALIFIER*, (PROPERTY | PROPERTY.ARRAY |
PROPERTY.REFERENCE)*)>
<!ATTLIST INSTANCE
%ClassName;>
%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.

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
33 changes: 32 additions & 1 deletion testsuite/test_tupleparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4767,7 +4767,7 @@ def test_tupleparse_roundtrip(
'<INSTANCE CLASSNAME="CIM_Foo" xml:lang="en_us"/>',
exp_result=CIMInstance('CIM_Foo'),
),
None, None, False # TODO 1/18 AM #1033: Enable once xml:lang supported
None, None, True
),
(
"INSTANCE with properties",
Expand Down Expand Up @@ -5147,6 +5147,16 @@ def test_tupleparse_roundtrip(
),
None, None, True
),
(
"PROPERTY with xml:lang attribute",
dict(
xml_str=''
'<PROPERTY NAME="Foo" TYPE="string" xml:lang="en_us"/>',
exp_result=CIMProperty('Foo', value=None, type='string',
propagated=False),
),
None, None, True
),
(
"PROPERTY with CLASSORIGIN and PROPAGATED attributes",
dict(
Expand Down Expand Up @@ -6006,6 +6016,18 @@ def test_tupleparse_roundtrip(
),
None, None, True
),
(
"PROPERTY.ARRAY with xml:lang attribute",
dict(
xml_str=''
'<PROPERTY.ARRAY NAME="Foo" TYPE="string" xml:lang="en_us"/>',
exp_result=CIMProperty(
'Foo', value=None, type='string', is_array=True,
propagated=False,
),
),
None, None, True
),
(
"PROPERTY.ARRAY with CLASSORIGIN and PROPAGATED attributes",
dict(
Expand Down Expand Up @@ -7741,6 +7763,15 @@ def test_tupleparse_roundtrip(
),
None, None, True
),
(
"QUALIFIER with xml:lang attribute",
dict(
xml_str=''
'<QUALIFIER NAME="Qual" TYPE="string" xml:lang="en_us"/>',
exp_result=CIMQualifier('Qual', value=None, type='string'),
),
None, None, True
),
(
"QUALIFIER with OVERRIDABLE attribute (true)",
dict(
Expand Down

0 comments on commit 43f7555

Please sign in to comment.