Skip to content

Commit

Permalink
Hook up DOM to retrieve internal subset if available
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby White authored and Toby White committed Mar 28, 2008
1 parent 67f0e83 commit c002a55
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 34 deletions.
38 changes: 37 additions & 1 deletion dom/m_dom_document_type.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
55 changes: 26 additions & 29 deletions dom/m_dom_dom.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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



Expand Down
2 changes: 0 additions & 2 deletions dom/m_dom_implementation.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions dom/m_dom_types.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c002a55

Please sign in to comment.