diff --git a/dom/m_dom_document_type.m4 b/dom/m_dom_document_type.m4 index ab63c374..10971b8f 100644 --- a/dom/m_dom_document_type.m4 +++ b/dom/m_dom_document_type.m4 @@ -49,6 +49,42 @@ TOHW_m_dom_contents(` ! function getSystemId(docType) result(c) See m_dom_common - TOHW_m_dom_get(DOMString, internalSubset, np%dtdExtras%internalSubset, (DOCUMENT_TYPE_NODE)) + pure function getInternalSubset_len(arg, p) result(n) + type(Node), pointer :: arg + logical, intent(in) :: p + integer :: n + + n = 0 + if (p) then + if (associated(arg%ownerDocument)) then + if (associated(arg%ownerDocument%docExtras%xds%intSubset)) then + n = size(arg%ownerDocument%docExtras%xds%intSubset) + endif + endif + endif + end function getInternalSubset_len + + TOHW_function(getInternalSubset, (arg), s) + type(Node), pointer :: arg +#ifdef RESTRICTED_ASSOCIATED_BUG + character(len=getInternalSubset_len(arg, .true.)) :: s +#else + character(len=getInternalSubset_len(arg, associated(arg))) :: s +#endif + + if (.not.associated(arg)) then + TOHW_m_dom_throw_error(FoX_NODE_IS_NULL) + endif + + if (arg%nodeType/=DOCUMENT_TYPE_NODE) then + TOHW_m_dom_throw_error(FoX_INVALID_NODE) + endif + + if (len(s)>0) then + s = str_vs(arg%ownerDocument%docExtras%xds%intSubset) + else + s = "" + endif + end function getInternalSubset ')`'dnl diff --git a/dom/m_dom_dom.F90 b/dom/m_dom_dom.F90 index 431a2b42..9386f509 100644 --- a/dom/m_dom_dom.F90 +++ b/dom/m_dom_dom.F90 @@ -212,7 +212,6 @@ module m_dom_dom type docTypeExtras character, pointer :: publicId(:) => null() ! doctype, entity, notation character, pointer :: systemId(:) => null() ! doctype, entity, notation - character, pointer :: internalSubset(:) => null() ! doctype character, pointer :: notationName(:) => null() ! entity logical :: illFormed = .false. ! entity type(namedNodeMap) :: entities ! doctype @@ -851,7 +850,6 @@ subroutine destroyDocumentType(np, ex) if (associated(np%dtdExtras%publicId)) deallocate(np%dtdExtras%publicId) if (associated(np%dtdExtras%systemId)) deallocate(np%dtdExtras%systemId) - if (associated(np%dtdExtras%internalSubset)) deallocate(np%dtdExtras%internalSubset) ! Destroy all entities & notations (docType only) if (associated(np%dtdExtras%entities%nodes)) then @@ -5663,8 +5661,6 @@ function createDocumentType(impl, qualifiedName, publicId, systemId, ex)result(d dt%readonly = .true. dt%dtdExtras%publicId => vs_str_alloc(publicId) dt%dtdExtras%systemId => vs_str_alloc(systemId) - allocate(dt%dtdExtras%internalSubset(0)) ! FIXME This is valid behaviour, but we should - ! really be able to get the intSubset from SAX dt%dtdExtras%entities%ownerElement => dt dt%dtdExtras%notations%ownerElement => dt @@ -8520,33 +8516,33 @@ end function getNotations ! function getSystemId(docType) result(c) See m_dom_common - - pure function getinternalSubset_len(np, p) result(n) - type(Node), intent(in) :: np + pure function getInternalSubset_len(arg, p) result(n) + type(Node), pointer :: arg logical, intent(in) :: p integer :: n - if (p .and. ( & - np%nodeType==DOCUMENT_TYPE_NODE .or. & - .false.)) then - n = size(np%dtdExtras%internalSubset) - else - n = 0 + n = 0 + if (p) then + if (associated(arg%ownerDocument)) then + if (associated(arg%ownerDocument%docExtras%xds%intSubset)) then + n = size(arg%ownerDocument%docExtras%xds%intSubset) + endif + endif endif - end function getinternalSubset_len -function getinternalSubset(np, ex)result(c) + end function getInternalSubset_len + + function getInternalSubset(arg, ex)result(s) type(DOMException), intent(out), optional :: ex - type(Node), pointer :: np + type(Node), pointer :: arg #ifdef RESTRICTED_ASSOCIATED_BUG - character(len=getinternalSubset_len(np, .true.)) :: c + character(len=getInternalSubset_len(arg, .true.)) :: s #else - character(len=getinternalSubset_len(np, associated(np))) :: c + character(len=getInternalSubset_len(arg, associated(arg))) :: s #endif - - if (.not.associated(np)) then + if (.not.associated(arg)) then if (getFoX_checks().or.FoX_NODE_IS_NULL<200) then - call throw_exception(FoX_NODE_IS_NULL, "getinternalSubset", ex) + call throw_exception(FoX_NODE_IS_NULL, "getInternalSubset", ex) if (present(ex)) then if (inException(ex)) then return @@ -8556,10 +8552,9 @@ function getinternalSubset(np, ex)result(c) endif - if (getNodeType(np)/=DOCUMENT_TYPE_NODE .and. & - .true.) then - if (getFoX_checks().or.FoX_INVALID_NODE<200) then - call throw_exception(FoX_INVALID_NODE, "getinternalSubset", ex) + if (arg%nodeType/=DOCUMENT_TYPE_NODE) then + if (getFoX_checks().or.FoX_INVALID_NODE<200) then + call throw_exception(FoX_INVALID_NODE, "getInternalSubset", ex) if (present(ex)) then if (inException(ex)) then return @@ -8569,10 +8564,12 @@ function getinternalSubset(np, ex)result(c) endif - c = str_vs(np%dtdExtras%internalSubset) - - end function getinternalSubset - + if (len(s)>0) then + s = str_vs(arg%ownerDocument%docExtras%xds%intSubset) + else + s = "" + endif + end function getInternalSubset diff --git a/dom/m_dom_implementation.m4 b/dom/m_dom_implementation.m4 index ada80693..31ff90a4 100644 --- a/dom/m_dom_implementation.m4 +++ b/dom/m_dom_implementation.m4 @@ -62,8 +62,6 @@ TOHW_m_dom_contents(` dt%readonly = .true. dt%dtdExtras%publicId => vs_str_alloc(publicId) dt%dtdExtras%systemId => vs_str_alloc(systemId) - allocate(dt%dtdExtras%internalSubset(0)) ! FIXME This is valid behaviour, but we should - ! really be able to get the intSubset from SAX dt%dtdExtras%entities%ownerElement => dt dt%dtdExtras%notations%ownerElement => dt diff --git a/dom/m_dom_types.m4 b/dom/m_dom_types.m4 index 06d7e13e..2ddde088 100644 --- a/dom/m_dom_types.m4 +++ b/dom/m_dom_types.m4 @@ -81,7 +81,6 @@ TOHW_m_dom_publics(` type docTypeExtras character, pointer :: publicId(:) => null() ! doctype, entity, notation character, pointer :: systemId(:) => null() ! doctype, entity, notation - character, pointer :: internalSubset(:) => null() ! doctype character, pointer :: notationName(:) => null() ! entity logical :: illFormed = .false. ! entity type(namedNodeMap) :: entities ! doctype @@ -231,7 +230,6 @@ TOHW_m_dom_contents(` if (associated(np%dtdExtras%publicId)) deallocate(np%dtdExtras%publicId) if (associated(np%dtdExtras%systemId)) deallocate(np%dtdExtras%systemId) - if (associated(np%dtdExtras%internalSubset)) deallocate(np%dtdExtras%internalSubset) ! Destroy all entities & notations (docType only) if (associated(np%dtdExtras%entities%nodes)) then