|
3 | 3 |
|
4 | 4 | from lxml import etree |
5 | 5 |
|
6 | | -from reqif.helpers.lxml import stringify_namespaced_children |
| 6 | +from reqif.helpers.lxml import ( |
| 7 | + lxml_convert_children_from_reqif_ns_xhtml_string, |
| 8 | + stringify_children, |
| 9 | + stringify_namespaced_children, |
| 10 | +) |
| 11 | +from reqif.helpers.string.xhtml_indent import reqif_unindent_xhtml_string |
7 | 12 | from reqif.models.reqif_spec_object import ( |
8 | 13 | ReqIFSpecObject, |
9 | 14 | SpecObjectAttribute, |
@@ -201,17 +206,33 @@ def parse(spec_object_xml) -> ReqIFSpecObject: |
201 | 206 | ) |
202 | 207 | elif attribute_xml.tag == "ATTRIBUTE-VALUE-XHTML": |
203 | 208 | the_value = attribute_xml.find("THE-VALUE") |
204 | | - attribute_value = stringify_namespaced_children(the_value) |
| 209 | + |
| 210 | + # Edge: There are not <xhtml:...> or <reqif-xhtml...> tags. |
| 211 | + if len(the_value.nsmap) > 0: |
| 212 | + attribute_value = stringify_namespaced_children(the_value) |
| 213 | + attribute_value_stripped_xhtml = ( |
| 214 | + reqif_unindent_xhtml_string( |
| 215 | + lxml_convert_children_from_reqif_ns_xhtml_string( |
| 216 | + the_value |
| 217 | + ) |
| 218 | + ) |
| 219 | + ) |
| 220 | + else: |
| 221 | + attribute_value = stringify_children(the_value) |
| 222 | + attribute_value_stripped_xhtml = ( |
| 223 | + reqif_unindent_xhtml_string(attribute_value) |
| 224 | + ) |
205 | 225 | attribute_definition_ref = ( |
206 | 226 | attribute_xml.find("DEFINITION") |
207 | 227 | .find("ATTRIBUTE-DEFINITION-XHTML-REF") |
208 | 228 | .text |
209 | 229 | ) |
210 | 230 | attribute = SpecObjectAttribute( |
211 | | - xml_node=attribute_xml, |
212 | 231 | attribute_type=SpecObjectAttributeType.XHTML, |
213 | 232 | definition_ref=attribute_definition_ref, |
214 | 233 | value=attribute_value, |
| 234 | + value_stripped_xhtml=attribute_value_stripped_xhtml, |
| 235 | + xml_node=attribute_xml, |
215 | 236 | ) |
216 | 237 | else: |
217 | 238 | raise NotImplementedError(etree.tostring(attribute_xml)) |
|
0 commit comments