diff --git a/dom/m_dom_dom.F90 b/dom/m_dom_dom.F90 index a2eaae2e..c9daf23b 100644 --- a/dom/m_dom_dom.F90 +++ b/dom/m_dom_dom.F90 @@ -5036,64 +5036,6 @@ function getNamedItem(map, name, ex)result(np) end function getNamedItem - pure function getNamedItem_Value_len(map, p, name) result(n) - type(NamedNodeMap), intent(in) :: map - logical, intent(in) :: p - character(len=*), intent(in) :: name - integer :: n - - integer :: i - - n = 0 - if (p) then - do i = 1, map%length - if (str_vs(map%nodes(i)%this%nodeName)==name) then - ! This has to be NodeValue, not TextContent since it should be 0 for entity/notation - n = getNodeValue_len(map%nodes(i)%this, .true.) - exit - endif - enddo - endif - - end function getNamedItem_Value_len - - - function getNamedItem_Value(map, name, ex)result(c) - type(DOMException), intent(out), optional :: ex - type(NamedNodeMap), pointer :: map - character(len=*), intent(in) :: name -#ifdef RESTRICTED_ASSOCIATED_BUG - character(len=getNamedItem_Value_len(map, .true., name)) :: c -#else - character(len=getNamedItem_Value_len(map, associated(map), name)) :: c -#endif - - integer :: i - - if (.not.associated(map)) then - if (getFoX_checks().or.FoX_MAP_IS_NULL<200) then - call throw_exception(FoX_MAP_IS_NULL, "getNamedItem_Value", ex) - if (present(ex)) then - if (inException(ex)) then - return - endif - endif -endif - - endif - - c = "" - do i = 1, map%length - if (str_vs(map%nodes(i)%this%nodeName)==name) then - ! This has to be NodeValue, not TextContent since it should be 0 for entity/notation - c = getNodeValue(map%nodes(i)%this) - return - endif - enddo - - end function getNamedItem_Value - - function setNamedItem(map, arg, ex)result(np) type(DOMException), intent(out), optional :: ex type(NamedNodeMap), pointer :: map @@ -5397,71 +5339,6 @@ function getNamedItemNS(map, namespaceURI, localName, ex)result(np) end function getNamedItemNS - pure function getNamedItemNS_Value_len(map, p, namespaceURI, localName) result(n) - type(NamedNodeMap), intent(in) :: map - logical, intent(in) :: p - character(len=*), intent(in) :: namespaceURI - character(len=*), intent(in) :: localName - integer :: n - - integer :: i - - n = 0 - if (.not.p) return - if (map%ownerElement%nodeType/=ELEMENT_NODE) return - ! Since entities & notations cant have NS. - - do i = 1, map%length - if (str_vs(map%nodes(i)%this%elExtras%namespaceURI)==namespaceURI & - .and. str_vs(map%nodes(i)%this%elExtras%localName)==localName) then - n = getNodeValue_len(map%nodes(i)%this, .true.) - exit - endif - enddo - - end function getNamedItemNS_Value_len - - - function getNamedItemNS_Value(map, namespaceURI, localName, ex)result(c) - type(DOMException), intent(out), optional :: ex - type(NamedNodeMap), pointer :: map - character(len=*), intent(in) :: namespaceURI - character(len=*), intent(in) :: localName -#ifdef RESTRICTED_ASSOCIATED_BUG - character(len=getNamedItemNS_Value_len(map, .true., namespaceURI, localName)) :: c -#else - character(len=getNamedItemNS_Value_len(map, associated(map), namespaceURI, localName)) :: c -#endif - - integer :: i - type(Node), pointer :: np - - if (.not.associated(map)) then - if (getFoX_checks().or.FoX_MAP_IS_NULL<200) then - call throw_exception(FoX_MAP_IS_NULL, "getNamedItemNS_Value", ex) - if (present(ex)) then - if (inException(ex)) then - return - endif - endif -endif - - endif - - c = "" - if (map%ownerElement%nodeType/=ELEMENT_NODE) return - do i = 0, getLength(map) - 1 - np => item(map, i) - if (getNamespaceURI(np)==namespaceURI & - .and. getLocalName(np)==localName) then - c = getNodeValue(np) - return - endif - enddo - - end function getNamedItemNS_Value - - function setNamedItemNS(map, arg, ex)result(np) type(DOMException), intent(out), optional :: ex type(NamedNodeMap), pointer :: map @@ -9339,6 +9216,8 @@ function getAttribute(arg, name, ex)result(c) character(len=getAttribute_len(arg, associated(arg), name)) :: c #endif + integer :: i + if (.not.associated(arg)) then if (getFoX_checks().or.FoX_NODE_IS_NULL<200) then call throw_exception(FoX_NODE_IS_NULL, "getAttribute", ex) @@ -9363,7 +9242,16 @@ function getAttribute(arg, name, ex)result(c) endif - c = getNamedItem_Value(getAttributes(arg), name) + if (len(c)>0) then + do i = 1, arg%elExtras%attributes%length + if (str_vs(arg%elExtras%attributes%nodes(i)%this%nodeName)==name) then + c = getTextContent(arg%elExtras%attributes%nodes(i)%this) + exit + endif + enddo + else + c = "" + endif end function getAttribute @@ -9726,6 +9614,8 @@ function getAttributeNS(arg, namespaceURI, localName, ex)result(c) character(len=getAttributesNS_len(arg, associated(arg), localname, namespaceURI)) :: c #endif + integer :: i + if (.not.associated(arg)) then if (getFoX_checks().or.FoX_NODE_IS_NULL<200) then call throw_exception(FoX_NODE_IS_NULL, "getAttributeNS", ex) @@ -9750,8 +9640,19 @@ function getAttributeNS(arg, namespaceURI, localName, ex)result(c) endif - c = getNamedItemNS_Value(getAttributes(arg), namespaceURI, localName) - + if (len(c)>0) then + do i = 1, arg%elExtras%attributes%length + if ((str_vs(arg%elExtras%attributes%nodes(i)%this%elExtras%localName)==localname & + .and. str_vs(arg%elExtras%attributes%nodes(i)%this%elExtras%namespaceURI)==namespaceURI) & + .or. (namespaceURI=="".and.str_vs(arg%elExtras%attributes%nodes(i)%this%nodeName)==localname)) then + c = getTextContent(arg%elExtras%attributes%nodes(i)%this) + exit + endif + enddo + else + c = "" + endif + end function getAttributeNS diff --git a/dom/m_dom_element.m4 b/dom/m_dom_element.m4 index 77005a16..e2518428 100644 --- a/dom/m_dom_element.m4 +++ b/dom/m_dom_element.m4 @@ -55,6 +55,8 @@ TOHW_m_dom_get(DOMString, tagName, np%nodeName, (ELEMENT_NODE)) character(len=getAttribute_len(arg, associated(arg), name)) :: c #endif + integer :: i + if (.not.associated(arg)) then TOHW_m_dom_throw_error(FoX_NODE_IS_NULL) endif @@ -63,7 +65,16 @@ TOHW_m_dom_get(DOMString, tagName, np%nodeName, (ELEMENT_NODE)) TOHW_m_dom_throw_error(FoX_INVALID_NODE) endif - c = getNamedItem_Value(getAttributes(arg), name) + if (len(c)>0) then + do i = 1, arg%elExtras%attributes%length + if (str_vs(arg%elExtras%attributes%nodes(i)%this%nodeName)==name) then + c = getTextContent(arg%elExtras%attributes%nodes(i)%this) + exit + endif + enddo + else + c = "" + endif end function getAttribute @@ -268,6 +279,8 @@ TOHW_m_dom_get(DOMString, tagName, np%nodeName, (ELEMENT_NODE)) character(len=getAttributesNS_len(arg, associated(arg), localname, namespaceURI)) :: c #endif + integer :: i + if (.not.associated(arg)) then TOHW_m_dom_throw_error(FoX_NODE_IS_NULL) endif @@ -276,8 +289,19 @@ TOHW_m_dom_get(DOMString, tagName, np%nodeName, (ELEMENT_NODE)) TOHW_m_dom_throw_error(FoX_INVALID_NODE) endif - c = getNamedItemNS_Value(getAttributes(arg), namespaceURI, localName) - + if (len(c)>0) then + do i = 1, arg%elExtras%attributes%length + if ((str_vs(arg%elExtras%attributes%nodes(i)%this%elExtras%localName)==localname & + .and. str_vs(arg%elExtras%attributes%nodes(i)%this%elExtras%namespaceURI)==namespaceURI) & + .or. (namespaceURI=="".and.str_vs(arg%elExtras%attributes%nodes(i)%this%nodeName)==localname)) then + c = getTextContent(arg%elExtras%attributes%nodes(i)%this) + exit + endif + enddo + else + c = "" + endif + end function getAttributeNS diff --git a/dom/m_dom_namednodemap.m4 b/dom/m_dom_namednodemap.m4 index 4a5d225f..e01fe50d 100644 --- a/dom/m_dom_namednodemap.m4 +++ b/dom/m_dom_namednodemap.m4 @@ -49,55 +49,6 @@ TOHW_m_dom_contents(` end function getNamedItem - pure function getNamedItem_Value_len(map, p, name) result(n) - type(NamedNodeMap), intent(in) :: map - logical, intent(in) :: p - character(len=*), intent(in) :: name - integer :: n - - integer :: i - - n = 0 - if (p) then - do i = 1, map%length - if (str_vs(map%nodes(i)%this%nodeName)==name) then - ! This has to be NodeValue, not TextContent since it should be 0 for entity/notation - n = getNodeValue_len(map%nodes(i)%this, .true.) - exit - endif - enddo - endif - - end function getNamedItem_Value_len - - - TOHW_function(getNamedItem_Value, (map, name), c) - type(NamedNodeMap), pointer :: map - character(len=*), intent(in) :: name -#ifdef RESTRICTED_ASSOCIATED_BUG - character(len=getNamedItem_Value_len(map, .true., name)) :: c -#else - character(len=getNamedItem_Value_len(map, associated(map), name)) :: c -#endif - - integer :: i - - if (.not.associated(map)) then - TOHW_m_dom_throw_error(FoX_MAP_IS_NULL) - endif - - c = "" - do i = 1, map%length - if (str_vs(map%nodes(i)%this%nodeName)==name) then - ! This has to be NodeValue, not TextContent since it should be 0 for entity/notation - c = getNodeValue(map%nodes(i)%this) - return - endif - enddo - - end function getNamedItem_Value - - TOHW_function(setNamedItem, (map, arg), np) type(NamedNodeMap), pointer :: map type(Node), pointer :: arg @@ -300,62 +251,6 @@ TOHW_m_dom_contents(` end function getNamedItemNS - pure function getNamedItemNS_Value_len(map, p, namespaceURI, localName) result(n) - type(NamedNodeMap), intent(in) :: map - logical, intent(in) :: p - character(len=*), intent(in) :: namespaceURI - character(len=*), intent(in) :: localName - integer :: n - - integer :: i - - n = 0 - if (.not.p) return - if (map%ownerElement%nodeType/=ELEMENT_NODE) return - ! Since entities & notations cant have NS. - - do i = 1, map%length - if (str_vs(map%nodes(i)%this%elExtras%namespaceURI)==namespaceURI & - .and. str_vs(map%nodes(i)%this%elExtras%localName)==localName) then - n = getNodeValue_len(map%nodes(i)%this, .true.) - exit - endif - enddo - - end function getNamedItemNS_Value_len - - - TOHW_function(getNamedItemNS_Value, (map, namespaceURI, localName), c) - type(NamedNodeMap), pointer :: map - character(len=*), intent(in) :: namespaceURI - character(len=*), intent(in) :: localName -#ifdef RESTRICTED_ASSOCIATED_BUG - character(len=getNamedItemNS_Value_len(map, .true., namespaceURI, localName)) :: c -#else - character(len=getNamedItemNS_Value_len(map, associated(map), namespaceURI, localName)) :: c -#endif - - integer :: i - type(Node), pointer :: np - - if (.not.associated(map)) then - TOHW_m_dom_throw_error(FoX_MAP_IS_NULL) - endif - - c = "" - if (map%ownerElement%nodeType/=ELEMENT_NODE) return - do i = 0, getLength(map) - 1 - np => item(map, i) - if (getNamespaceURI(np)==namespaceURI & - .and. getLocalName(np)==localName) then - c = getNodeValue(np) - return - endif - enddo - - end function getNamedItemNS_Value - - TOHW_function(setNamedItemNS, (map, arg), np) type(NamedNodeMap), pointer :: map type(Node), pointer :: arg