Skip to content

Commit b0caf24

Browse files
authored
ixml: implement create_attribute_ns() (#1016)
1 parent d78d56d commit b0caf24

File tree

6 files changed

+49
-12
lines changed

6 files changed

+49
-12
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
},
1616
"license": "MIT",
1717
"dependencies": {
18-
"@abaplint/cli": "^2.113.210",
18+
"@abaplint/cli": "^2.113.220",
1919
"@abaplint/database-pg": "^2.11.78",
2020
"@abaplint/database-sqlite": "^2.11.78",
21-
"@abaplint/runtime": "^2.11.93",
22-
"@abaplint/transpiler-cli": "^2.11.93",
21+
"@abaplint/runtime": "^2.11.96",
22+
"@abaplint/transpiler-cli": "^2.11.96",
2323
"0x": "^6.0.0"
2424
}
2525
}

src/ixml/cl_ixml.clas.locals_imp.abap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ CLASS lcl_node IMPLEMENTATION.
482482
ENDMETHOD.
483483

484484
METHOD if_ixml_element~set_attribute_node_ns.
485-
ASSERT 1 = 'todo'.
485+
mi_attributes->set_named_item_ns( new_attr ).
486486
ENDMETHOD.
487487

488488
METHOD if_ixml_element~set_attribute.
@@ -784,7 +784,9 @@ CLASS lcl_document IMPLEMENTATION.
784784
ENDMETHOD.
785785

786786
METHOD if_ixml_document~create_attribute_ns.
787-
ASSERT 1 = 'todo'.
787+
CREATE OBJECT rval TYPE lcl_node.
788+
rval->if_ixml_node~set_name( name ).
789+
rval->if_ixml_node~set_namespace_prefix( prefix ).
788790
ENDMETHOD.
789791

790792
METHOD if_ixml_document~create_element_ns.

src/ixml/cl_ixml.clas.testclasses.abap

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ CLASS ltcl_xml DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
4949
METHODS pretty4 FOR TESTING RAISING cx_static_check.
5050
METHODS pretty5 FOR TESTING RAISING cx_static_check.
5151
METHODS add_stuff FOR TESTING RAISING cx_static_check.
52+
METHODS create_attribute_ns FOR TESTING RAISING cx_static_check.
5253

5354
DATA mi_ixml TYPE REF TO if_ixml.
5455
DATA mi_document TYPE REF TO if_ixml_document.
@@ -1152,4 +1153,36 @@ CLASS ltcl_xml IMPLEMENTATION.
11521153

11531154
ENDMETHOD.
11541155

1156+
METHOD create_attribute_ns.
1157+
DATA li_element TYPE REF TO if_ixml_element.
1158+
DATA li_top TYPE REF TO if_ixml_element.
1159+
DATA lv_xml TYPE string.
1160+
DATA li_attr TYPE REF TO if_ixml_attribute.
1161+
1162+
li_top = mi_document->create_element_ns(
1163+
prefix = 'asx'
1164+
name = 'abap' ).
1165+
mi_document->append_child( li_top ).
1166+
1167+
li_element = mi_document->create_element( 'HELLO' ).
1168+
1169+
li_attr = mi_document->create_attribute_ns( 'version' ).
1170+
li_attr->if_ixml_node~set_value( '1.0' ).
1171+
li_element->set_attribute_node_ns( li_attr ).
1172+
1173+
li_attr = mi_document->create_attribute_ns(
1174+
name = 'asx'
1175+
prefix = 'xmlns' ).
1176+
li_attr->if_ixml_node~set_value( 'http://abapgit.org' ).
1177+
li_element->set_attribute_node_ns( li_attr ).
1178+
1179+
li_top->append_child( li_element ).
1180+
1181+
lv_xml = render( ).
1182+
1183+
cl_abap_unit_assert=>assert_char_cp(
1184+
act = lv_xml
1185+
exp = '*<HELLO version="1.0" xmlns:asx="http://abapgit.org"/>*' ).
1186+
ENDMETHOD.
1187+
11551188
ENDCLASS.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
INTERFACE if_ixml_attribute PUBLIC.
22
INTERFACES if_ixml_node.
3-
METHODS get_value RETURNING VALUE(val) TYPE string.
4-
METHODS set_value IMPORTING value TYPE string.
5-
METHODS get_name RETURNING VALUE(val) TYPE string.
3+
4+
ALIASES get_value FOR if_ixml_node~get_value.
5+
ALIASES set_value FOR if_ixml_node~set_value.
6+
ALIASES get_name FOR if_ixml_node~get_name.
7+
ALIASES set_name FOR if_ixml_node~set_name.
68
ENDINTERFACE.

src/ixml/if_ixml_document.intf.abap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ INTERFACE if_ixml_document PUBLIC.
2424
VALUE(child) TYPE REF TO if_ixml_node,
2525
create_attribute_ns
2626
IMPORTING
27-
name TYPE string
28-
prefix TYPE string OPTIONAL
27+
name TYPE string
28+
prefix TYPE string OPTIONAL
2929
RETURNING
30-
VALUE(element) TYPE REF TO if_ixml_attribute,
30+
VALUE(rval) TYPE REF TO if_ixml_attribute,
3131
create_element_ns
3232
IMPORTING
3333
name TYPE string

src/ixml/if_ixml_element.intf.abap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ INTERFACE if_ixml_element PUBLIC.
8080
ostream TYPE REF TO if_ixml_ostream,
8181
set_attribute_node_ns
8282
IMPORTING
83-
attr TYPE any,
83+
new_attr TYPE REF TO if_ixml_attribute,
8484
set_attribute
8585
IMPORTING
8686
name TYPE string

0 commit comments

Comments
 (0)