[6] | 1 | module m_dom_attribute |
---|
| 2 | |
---|
| 3 | use m_dom_types |
---|
| 4 | use m_dom_node |
---|
| 5 | use m_strings |
---|
| 6 | |
---|
| 7 | private |
---|
| 8 | !------------------------------------------------------- |
---|
| 9 | ! METHODS FOR ATTRIBUTE NODES |
---|
| 10 | !------------------------------------------------------- |
---|
| 11 | |
---|
| 12 | public :: getName |
---|
| 13 | public :: getValue |
---|
| 14 | public :: setValue |
---|
| 15 | |
---|
| 16 | CONTAINS |
---|
| 17 | |
---|
| 18 | function getName(attribute) |
---|
| 19 | |
---|
| 20 | type(fnode), intent(in) :: attribute |
---|
| 21 | type(string) :: getName |
---|
| 22 | |
---|
| 23 | if (attribute % nodeType == ATTRIBUTE_NODE) then |
---|
| 24 | getName = attribute%nodeName |
---|
| 25 | else |
---|
| 26 | getName = '' |
---|
| 27 | endif |
---|
| 28 | |
---|
| 29 | end function getName |
---|
| 30 | |
---|
| 31 | !----------------------------------------------------------- |
---|
| 32 | |
---|
| 33 | function getValue(attribute) |
---|
| 34 | |
---|
| 35 | type(fnode), intent(in) :: attribute |
---|
| 36 | type(string) :: getValue |
---|
| 37 | |
---|
| 38 | if (attribute % nodeType == ATTRIBUTE_NODE) then |
---|
| 39 | getValue = attribute%nodeValue |
---|
| 40 | else |
---|
| 41 | getValue = '' |
---|
| 42 | endif |
---|
| 43 | |
---|
| 44 | end function getValue |
---|
| 45 | |
---|
| 46 | !----------------------------------------------------------- |
---|
| 47 | |
---|
| 48 | subroutine setValue(attribute, value) |
---|
| 49 | |
---|
| 50 | character(len=*), intent(in) :: value |
---|
| 51 | type(fnode), pointer :: attribute |
---|
| 52 | |
---|
| 53 | if (attribute % nodeType == ATTRIBUTE_NODE) then |
---|
| 54 | call setNodeValue(attribute,value) |
---|
| 55 | endif |
---|
| 56 | |
---|
| 57 | end subroutine setValue |
---|
| 58 | |
---|
| 59 | !----------------------------------------------------------- |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | !!! NB Is this a good idea? |
---|
| 63 | !!! NB pure functions have no side effects |
---|
| 64 | |
---|
| 65 | pure function attr_name_len(attribute) |
---|
| 66 | type(fnode), intent(in) :: attribute |
---|
| 67 | integer :: attr_name_len |
---|
| 68 | if (attribute % nodeType == ATTRIBUTE_NODE) then |
---|
| 69 | attr_name_len = len_trim(attribute % nodeName) |
---|
| 70 | else |
---|
| 71 | attr_name_len = 0 |
---|
| 72 | end if |
---|
| 73 | end function attr_name_len |
---|
| 74 | |
---|
| 75 | pure function attr_val_len(attribute) |
---|
| 76 | type(fnode), intent(in) :: attribute |
---|
| 77 | integer :: attr_val_len |
---|
| 78 | if (attribute % nodeType == ATTRIBUTE_NODE) then |
---|
| 79 | attr_val_len = len_trim(attribute % nodeValue) |
---|
| 80 | else |
---|
| 81 | attr_val_len = 0 |
---|
| 82 | end if |
---|
| 83 | end function attr_val_len |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | end module m_dom_attribute |
---|