Skip to content

Commit

Permalink
dom: New FoX option - invalid-pretty-print
Browse files Browse the repository at this point in the history
Add a new DOMConfiguration option "invalid-pretty-print",
like "format-pretty-print" this option causes whitespace to
be added to the document serialization to help readability.
However, unlike format-pretty-print validity is not preserved
(e.g. a DTD may specify that empty nodes are not allowed
invalid-pretty-print may add them, format-pretty-print will
not). As the wxml option pretty-print does not know about this
the FoX DOM does not implement format-pretty-print. The new
option is a way to make the output more readble without
overhalling wxml.

Setting the "cannonical-form" option unsets "invalid-pretty-print"
and "invalid-pretty-print" defaults to no pretty printing (.false.).
  • Loading branch information
andreww committed Nov 9, 2009
1 parent d92e284 commit 2d82f5d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 106 deletions.
63 changes: 11 additions & 52 deletions dom/m_dom_configuration.m4
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TOHW_m_dom_publics(`

integer, parameter :: configParamLen = 42

character(len=configParamLen), parameter :: configParams(23) = (/ &
character(len=configParamLen), parameter :: configParams(24) = (/ &
! DOM 3 Core:
"canonical-form ", &
"cdata-sections ", &
Expand Down Expand Up @@ -49,57 +49,12 @@ TOHW_m_dom_publics(`
! DOM 3 LS (Serializer)
"discard-default-content ", &
"format-pretty-print ", &
"xml-declaration " /)

!!$ logical, parameter :: paramSettable(26) = (/ &
!!$ .true., & ! canonical-form
!!$ .true., & ! cdata-sections
!!$ .false., & ! check-character-normalization
!!$ .true., & ! comments
!!$ .false., & ! datatype-normalization
!!$ .true., & ! element-content-whitespace
!!$ .true., & ! entities
!!$ .false., & ! error-handler BREACH OF SPEC
!!$ !.false., & ! infoset
!!$ .true., & ! namespaces
!!$ .true., & ! namespace-declarations
!!$ .false., & ! normalize-characters
!!$ .true., & ! split-cdata-sections
!!$ .false., & ! well-formed
!!$ .false., & ! charset-overrides-xml-encoding
!!$ .false., & ! disallow-doctype
!!$ .false., & ! ignore-unknown-character-denormalizations
!!$ .false., & ! resource-resolver BREACH OF SPEC
!!$ .false., & ! supported-media-types-only
!!$ .true., & ! discard-default-content
!!$ .false., & ! format-pretty-print
!!$ .true. /) ! xml-declaration
integer, parameter :: paramSettable = 127956694

!!$ logical, parameter :: paramDefaults(26) = (/ &
!!$ .false., & ! canonical-form
!!$ .true., & ! cdata-sections
!!$ .false., & ! check-character-normalization
!!$ .true., & ! comments
!!$ .false., & ! datatype-normalization
!!$ .true., & ! element-content-whitespace
!!$ .true., & ! entities
!!$ .false., & ! error-handler BREACH OF SPEC
!!$ !.true., & ! infoset
!!$ .true., & ! namespaces
!!$ .true., & ! namespace-declarations
!!$ .false., & ! normalize-characters
!!$ .true., & ! split-cdata-sections
!!$ .true., & ! well-formed
!!$ .false., & ! charset-overrides-xml-encoding
!!$ .false., & ! disallow-doctype
!!$ .true., & ! ignore-unknown-character-denormalizations
!!$ .false., & ! resource-resolver BREACH OF SPEC
!!$ .false., & ! supported-media-types-only
!!$ .true., & ! discard-default-content
!!$ .false., & ! format-pretty-print
!!$ .true. /) ! xml-declaration
integer, parameter :: paramDefaults = 94672596
"xml-declaration ", &
! Extra (FoX) configuration options
"invalid-pretty-print " /)

integer, parameter :: paramSettable = 27293398
integer, parameter :: paramDefaults = 10786516

type DOMConfiguration
private
Expand Down Expand Up @@ -198,6 +153,7 @@ TOHW_m_dom_contents(`
! call setParameter(domConfig, "format-pretty-print", .false.)
domConfig%parameters = ibclr(domConfig%parameters, 21)
domConfig%parameters = ibclr(domConfig%parameters, 23)
domConfig%parameters = ibclr(domConfig%parameters, 24)
else
call resetParameter(domConfig, "entities")
! cant do normalize-characters
Expand All @@ -209,6 +165,7 @@ TOHW_m_dom_contents(`
call resetParameter(domConfig, "format-pretty-print")
call resetParameter(domConfig, "discard-default-content")
call resetParameter(domConfig, "xml-declaration")
call resetParameter(domConfig, "invalid-pretty-print")
endif
case ("cdata-sections")
if (value) domConfig%parameters = ibclr(domConfig%parameters, 1)
Expand All @@ -230,6 +187,8 @@ TOHW_m_dom_contents(`
if (value) domConfig%parameters = ibclr(domConfig%parameters, 1)
case ("xml-declaration")
if (value) domConfig%parameters = ibclr(domConfig%parameters, 1)
case ("invalid-pretty-print")
if (value) domConfig%parameters = ibclr(domConfig%parameters, 1)
end select

end subroutine setParameter
Expand Down
63 changes: 11 additions & 52 deletions dom/m_dom_dom.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module m_dom_dom

integer, parameter :: configParamLen = 42

character(len=configParamLen), parameter :: configParams(23) = (/ &
character(len=configParamLen), parameter :: configParams(24) = (/ &
! DOM 3 Core:
"canonical-form ", &
"cdata-sections ", &
Expand Down Expand Up @@ -62,57 +62,12 @@ module m_dom_dom
! DOM 3 LS (Serializer)
"discard-default-content ", &
"format-pretty-print ", &
"xml-declaration " /)

!!$ logical, parameter :: paramSettable(26) = (/ &
!!$ .true., & ! canonical-form
!!$ .true., & ! cdata-sections
!!$ .false., & ! check-character-normalization
!!$ .true., & ! comments
!!$ .false., & ! datatype-normalization
!!$ .true., & ! element-content-whitespace
!!$ .true., & ! entities
!!$ .false., & ! error-handler BREACH OF SPEC
!!$ !.false., & ! infoset
!!$ .true., & ! namespaces
!!$ .true., & ! namespace-declarations
!!$ .false., & ! normalize-characters
!!$ .true., & ! split-cdata-sections
!!$ .false., & ! well-formed
!!$ .false., & ! charset-overrides-xml-encoding
!!$ .false., & ! disallow-doctype
!!$ .false., & ! ignore-unknown-character-denormalizations
!!$ .false., & ! resource-resolver BREACH OF SPEC
!!$ .false., & ! supported-media-types-only
!!$ .true., & ! discard-default-content
!!$ .false., & ! format-pretty-print
!!$ .true. /) ! xml-declaration
integer, parameter :: paramSettable = 127956694

!!$ logical, parameter :: paramDefaults(26) = (/ &
!!$ .false., & ! canonical-form
!!$ .true., & ! cdata-sections
!!$ .false., & ! check-character-normalization
!!$ .true., & ! comments
!!$ .false., & ! datatype-normalization
!!$ .true., & ! element-content-whitespace
!!$ .true., & ! entities
!!$ .false., & ! error-handler BREACH OF SPEC
!!$ !.true., & ! infoset
!!$ .true., & ! namespaces
!!$ .true., & ! namespace-declarations
!!$ .false., & ! normalize-characters
!!$ .true., & ! split-cdata-sections
!!$ .true., & ! well-formed
!!$ .false., & ! charset-overrides-xml-encoding
!!$ .false., & ! disallow-doctype
!!$ .true., & ! ignore-unknown-character-denormalizations
!!$ .false., & ! resource-resolver BREACH OF SPEC
!!$ .false., & ! supported-media-types-only
!!$ .true., & ! discard-default-content
!!$ .false., & ! format-pretty-print
!!$ .true. /) ! xml-declaration
integer, parameter :: paramDefaults = 94672596
"xml-declaration ", &
! Extra (FoX) configuration options
"invalid-pretty-print " /)

integer, parameter :: paramSettable = 27293398
integer, parameter :: paramDefaults = 10786516

type DOMConfiguration
private
Expand Down Expand Up @@ -616,6 +571,7 @@ recursive subroutine setParameter(domConfig, name, value, ex)
! call setParameter(domConfig, "format-pretty-print", .false.)
domConfig%parameters = ibclr(domConfig%parameters, 21)
domConfig%parameters = ibclr(domConfig%parameters, 23)
domConfig%parameters = ibclr(domConfig%parameters, 24)
else
call resetParameter(domConfig, "entities")
! cant do normalize-characters
Expand All @@ -627,6 +583,7 @@ recursive subroutine setParameter(domConfig, name, value, ex)
call resetParameter(domConfig, "format-pretty-print")
call resetParameter(domConfig, "discard-default-content")
call resetParameter(domConfig, "xml-declaration")
call resetParameter(domConfig, "invalid-pretty-print")
endif
case ("cdata-sections")
if (value) domConfig%parameters = ibclr(domConfig%parameters, 1)
Expand All @@ -648,6 +605,8 @@ recursive subroutine setParameter(domConfig, name, value, ex)
if (value) domConfig%parameters = ibclr(domConfig%parameters, 1)
case ("xml-declaration")
if (value) domConfig%parameters = ibclr(domConfig%parameters, 1)
case ("invalid-pretty-print")
if (value) domConfig%parameters = ibclr(domConfig%parameters, 1)
end select

end subroutine setParameter
Expand Down
9 changes: 8 additions & 1 deletion dom/m_dom_utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,15 @@ subroutine serialize(startNode, name, ex)
! (except for namespace Normalization) but rather just
! pay attention to the DOMConfig values

! NOTE: We set pretty_print on the basis of the FoX specific
! "invalid-pretty-print" config option. The DOM-L3-LS
! option "format-pretty-print is always false and is
! not settable by the user - this is because WXML
! cannot preserve validity conditions that may be set
! by a DTD. If WXML ever learns to do this we will need
! to pass the value of "format-pretty-print" through.
call xml_OpenFile(name, xf, iostat=iostat, unit=-1, &
pretty_print=getParameter(getDomConfig(doc), "format-pretty-print"), &
pretty_print=getParameter(getDomConfig(doc), "invalid-pretty-print"), &
canonical=getParameter(getDomConfig(doc), "canonical-form"), &
warning=.false., addDecl=.false.)
if (iostat/=0) then
Expand Down
9 changes: 8 additions & 1 deletion dom/m_dom_utils.m4
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,15 @@ contains
! (except for namespace Normalization) but rather just
! pay attention to the DOMConfig values

! NOTE: We set pretty_print on the basis of the FoX specific
! "invalid-pretty-print" config option. The DOM-L3-LS
! option "format-pretty-print is always false and is
! not settable by the user - this is because WXML
! cannot preserve validity conditions that may be set
! by a DTD. If WXML ever learns to do this we will need
! to pass the value of "format-pretty-print" through.
call xml_OpenFile(name, xf, iostat=iostat, unit=-1, &
pretty_print=getParameter(getDomConfig(doc), "format-pretty-print"), &
pretty_print=getParameter(getDomConfig(doc), "invalid-pretty-print"), &
canonical=getParameter(getDomConfig(doc), "canonical-form"), &
warning=.false., addDecl=.false.)
if (iostat/=0) then
Expand Down

0 comments on commit 2d82f5d

Please sign in to comment.