forked from andreww/fox
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathm_dom_dom.F90
12324 lines (10265 loc) · 338 KB
/
m_dom_dom.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
! ATTENTION
! THIS FILE IS AUTOGENERATED
! DO NOT EDIT DIRECTLY
! EDIT FILES dom/m_dom_***.m4
!
module m_dom_dom
use fox_m_fsys_array_str, only: str_vs, vs_str, vs_str_alloc
use fox_m_fsys_format, only: operator(//)
use fox_m_fsys_string, only: toLower
use fox_m_utils_uri, only: URI, parseURI, destroyURI, isAbsoluteURI, &
rebaseURI, expressURI
use m_common_charset, only: checkChars, XML1_0, XML1_1
use m_common_element, only: element_t, get_element, attribute_t, &
attribute_has_default, get_attribute_declaration, get_attlist_size
use m_common_namecheck, only: checkQName, prefixOfQName, localPartOfQName, &
checkName, checkPublicId, checkNCName
use m_common_struct, only: xml_doc_state, init_xml_doc_state, destroy_xml_doc_state
use m_dom_error, only: DOMException, throw_exception, inException, getExceptionCode, &
NO_MODIFICATION_ALLOWED_ERR, NOT_FOUND_ERR, HIERARCHY_REQUEST_ERR, &
WRONG_DOCUMENT_ERR, FoX_INTERNAL_ERROR, FoX_NODE_IS_NULL, FoX_LIST_IS_NULL, &
INUSE_ATTRIBUTE_ERR, FoX_MAP_IS_NULL, INVALID_CHARACTER_ERR, NAMESPACE_ERR, &
FoX_INVALID_PUBLIC_ID, FoX_INVALID_SYSTEM_ID, FoX_IMPL_IS_NULL, FoX_INVALID_NODE, &
FoX_INVALID_CHARACTER, FoX_INVALID_COMMENT, FoX_INVALID_CDATA_SECTION, &
FoX_INVALID_PI_DATA, NOT_SUPPORTED_ERR, FoX_INVALID_ENTITY, &
INDEX_SIZE_ERR, FoX_NO_SUCH_ENTITY, FoX_HIERARCHY_REQUEST_ERR, &
FoX_INVALID_URI
implicit none
private
integer, parameter :: configParamLen = 42
character(len=configParamLen), parameter :: configParams(24) = (/ &
! DOM 3 Core:
"canonical-form ", &
"cdata-sections ", &
"check-character-normalization ", &
"comments ", &
"datatype-normalization ", &
"element-content-whitespace ", &
"entities ", &
"error-handler ", &
! "infoset ", & is not a real config option
"namespaces ", &
"namespace-declarations ", &
"normalize-characters ", &
! "schema-location ", & we dont implement
! "schema-type ", & we dont implement
"split-cdata-sections ", &
"validate ", &
"validate-if-schema ", &
"well-formed ", &
! DOM 3 LS (Parser):
"charset-overrides-xml-encoding ", &
"disallow-doctype ", &
"ignore-unknown-character-denormalizations", &
"resource-resolver ", &
"supported-media-types-only ", &
! DOM 3 LS (Serializer)
"discard-default-content ", &
"format-pretty-print ", &
"xml-declaration ", &
! Extra (FoX) configuration options
"invalid-pretty-print " /)
integer, parameter :: paramSettable = 27293398
integer, parameter :: paramDefaults = 10786516
type DOMConfiguration
private
integer :: parameters = paramDefaults
! FIXME make sure this is 32 bit at least.
end type DOMConfiguration
interface canSetParameter
module procedure canSetParameter_log
module procedure canSetParameter_ch
end interface canSetParameter
public :: setParameter
public :: getParameter
public :: canSetParameter
public :: getParameterNames
public :: newDOMConfig
public :: copyDOMConfig
integer, parameter :: ELEMENT_NODE = 1
integer, parameter :: ATTRIBUTE_NODE = 2
integer, parameter :: TEXT_NODE = 3
integer, parameter :: CDATA_SECTION_NODE = 4
integer, parameter :: ENTITY_REFERENCE_NODE = 5
integer, parameter :: ENTITY_NODE = 6
integer, parameter :: PROCESSING_INSTRUCTION_NODE = 7
integer, parameter :: COMMENT_NODE = 8
integer, parameter :: DOCUMENT_NODE = 9
integer, parameter :: DOCUMENT_TYPE_NODE = 10
integer, parameter :: DOCUMENT_FRAGMENT_NODE = 11
integer, parameter :: NOTATION_NODE = 12
integer, parameter :: XPATH_NAMESPACE_NODE = 13
type DOMImplementation
private
character(len=7) :: id = "FoX_DOM"
logical :: FoX_checks = .true. ! Do extra checks not mandated by DOM
end type DOMImplementation
type ListNode
private
type(Node), pointer :: this => null()
end type ListNode
type NodeList
private
character, pointer :: nodeName(:) => null() ! What was getByTagName run on?
character, pointer :: localName(:) => null() ! What was getByTagNameNS run on?
character, pointer :: namespaceURI(:) => null() ! What was getByTagNameNS run on?
type(Node), pointer :: element => null() ! which element or document was the getByTagName run from?
type(ListNode), pointer :: nodes(:) => null()
integer :: length = 0
end type NodeList
type NodeListptr
private
type(NodeList), pointer :: this
end type NodeListptr
type NamedNodeMap
private
logical :: readonly = .false.
type(Node), pointer :: ownerElement => null()
type(ListNode), pointer :: nodes(:) => null()
integer :: length = 0
end type NamedNodeMap
type documentExtras
type(DOMImplementation), pointer :: implementation => null() ! only for doctype
type(Node), pointer :: docType => null()
type(Node), pointer :: documentElement => null()
character, pointer :: inputEncoding(:) => null()
character, pointer :: xmlEncoding(:) => null()
type(NodeListPtr), pointer :: nodelists(:) => null() ! document
! In order to keep track of all nodes not connected to the document
logical :: liveNodeLists ! For the document, are nodelists live?
type(NodeList) :: hangingNodes ! For the document, list of nodes not associated with doc
type(xml_doc_state), pointer :: xds => null()
logical :: strictErrorChecking = .true.
logical :: brokenNS = .false. ! FIXME consolidate these logical variables into bitmask
type(DOMConfiguration), pointer :: domConfig => null()
end type documentExtras
type elementOrAttributeExtras
! Needed for all:
character, pointer, dimension(:) :: namespaceURI => null()
character, pointer, dimension(:) :: prefix => null()
character, pointer, dimension(:) :: localName => null()
! Needed for elements:
type(NamedNodeMap) :: attributes
type(NodeList) :: namespaceNodes
! Needed for attributes:
type(Node), pointer :: ownerElement => null()
logical :: specified = .true.
logical :: isId = .false.
logical :: dom1 = .false.
end type elementOrAttributeExtras
type docTypeExtras
character, pointer :: publicId(:) => null() ! doctype, entity, notation
character, pointer :: systemId(:) => null() ! doctype, entity, notation
character, pointer :: notationName(:) => null() ! entity
logical :: illFormed = .false. ! entity
type(namedNodeMap) :: entities ! doctype
type(namedNodeMap) :: notations ! doctype
end type docTypeExtras
type Node
private
logical :: readonly = .false.
character, pointer, dimension(:) :: nodeName => null()
character, pointer, dimension(:) :: nodeValue => null()
integer :: nodeType = 0
type(Node), pointer :: parentNode => null()
type(Node), pointer :: firstChild => null()
type(Node), pointer :: lastChild => null()
type(Node), pointer :: previousSibling => null()
type(Node), pointer :: nextSibling => null()
type(Node), pointer :: ownerDocument => null()
type(NodeList) :: childNodes ! not for text, cdata, PI, comment, notation, docType, XPath
logical :: inDocument = .false.! For a node, is this node associated to the doc?
logical :: ignorableWhitespace = .false. ! Text nodes only
type(documentExtras), pointer :: docExtras => null()
type(elementOrAttributeExtras), pointer :: elExtras => null()
type(docTypeExtras), pointer :: dtdExtras => null()
integer :: textContentLength = 0
end type Node
type(DOMImplementation), save, target :: FoX_DOM
interface destroy
module procedure destroyNode
module procedure destroyNodeList
module procedure destroyNamedNodeMap
module procedure destroyDOMConfig
end interface destroy
public :: ELEMENT_NODE
public :: ATTRIBUTE_NODE
public :: TEXT_NODE
public :: CDATA_SECTION_NODE
public :: ENTITY_REFERENCE_NODE
public :: ENTITY_NODE
public :: PROCESSING_INSTRUCTION_NODE
public :: COMMENT_NODE
public :: DOCUMENT_NODE
public :: DOCUMENT_TYPE_NODE
public :: DOCUMENT_FRAGMENT_NODE
public :: NOTATION_NODE
public :: DOMImplementation
public :: DOMConfiguration
public :: Node
public :: ListNode
public :: NodeList
public :: NamedNodeMap
public :: destroy
public :: destroyAllNodesRecursively
public :: getNodeName
public :: getNodeValue
public :: setNodeValue
public :: getNodeType
public :: getParentNode
public :: getChildNodes
public :: getFirstChild
public :: getLastChild
public :: getNextSibling
public :: getPreviousSibling
public :: getAttributes
public :: getOwnerDocument
public :: insertBefore
public :: replaceChild
public :: removeChild
public :: appendChild
public :: hasChildNodes
public :: cloneNode
public :: normalize
public :: isSupported
public :: getNamespaceURI
public :: getPrefix
public :: setPrefix
public :: getLocalName
public :: hasAttributes
public :: isEqualNode
public :: isSameNode
public :: isDefaultNamespace
public :: lookupNamespaceURI
public :: lookupPrefix
public :: getTextContent
public :: setTextContent
public :: getNodePath
public :: setStringValue
public :: getStringValue
public :: setReadonlyNode
public :: getReadOnly
public :: getBaseURI
public :: item
public :: append
public :: pop_nl
public :: remove_nl
public :: destroyNodeList
interface append
module procedure append_nl
end interface
interface item
module procedure item_nl
end interface
interface getLength
module procedure getLength_nl
end interface getLength
public :: getNamedItem
public :: setNamedItem
public :: removeNamedItem
! public :: item
! public :: getLength
public :: getNamedItemNS
public :: setNamedItemNS
public :: removeNamedItemNS
! public :: append
public :: setReadOnlyMap
public :: destroyNamedNodeMap
interface item
module procedure item_nnm
end interface
interface getLength
module procedure getLength_nnm
end interface
public :: hasFeature
public :: createDocument
public :: createDocumentType
public :: destroyDocument
public :: createEmptyDocument
public :: getFoX_checks
public :: setFoX_checks
!FIXME lots of these should have a check if(namespaces) checkNCName
public :: getDocType
public :: getImplementation
public :: getDocumentElement
public :: setDocumentElement
public :: createElement
public :: createDocumentFragment
public :: createTextNode
public :: createComment
public :: createCdataSection
public :: createProcessingInstruction
public :: createAttribute
public :: createEntityReference
public :: createEmptyEntityReference
public :: getElementsByTagName
public :: importNode
public :: createElementNS
public :: createAttributeNS
public :: getElementsByTagNameNS
public :: getElementById
public :: getXmlStandalone
public :: setXmlStandalone
public :: getXmlVersion
public :: setXmlVersion
public :: getXmlEncoding
public :: getInputEncoding
public :: getDocumentURI
public :: setDocumentURI
public :: getStrictErrorChecking
public :: setStrictErrorChecking
public :: getDomConfig
public :: renameNode
public :: adoptNode
public :: setDocType
public :: setDomConfig
public :: setXds
public :: createNamespaceNode
public :: createEntity
public :: createNotation
public :: setGCstate
public :: getXds
public :: getLiveNodeLists
public :: setLiveNodeLists
!public :: getName
public :: getEntities
public :: getNotations
! public :: getPublicId
! public :: getSystemId
public :: getInternalSubset
public :: getTagName
public :: getAttribute
public :: setAttribute
public :: removeAttribute
public :: getAttributeNode
public :: setAttributeNode
public :: removeAttributeNode
public :: getAttributeNS
public :: setAttributeNS
public :: removeAttributeNS
public :: getAttributeNodeNS
public :: setAttributeNodeNS
public :: removeAttributeNodeNS
public :: hasAttribute
public :: hasAttributeNS
public :: setIdAttribute
public :: setIdAttributeNS
public :: setIdAttributeNode
!public :: getName
public :: getSpecified
public :: setSpecified
interface getValue
module procedure getValue_DOM
end interface
public :: getValue
public :: setValue
public :: getOwnerElement
public :: getIsId
public :: setIsId
interface getIsId
module procedure getIsId_DOM
end interface
interface setIsId
module procedure setIsId_DOM
end interface
public :: getLength
! public :: getData
! public :: setData
public :: substringData
public :: appendData
public :: insertData
public :: deleteData
public :: replaceData
interface getLength
module procedure getLength_characterdata
end interface
public :: getNotationName
public :: getIllFormed
public :: setIllFormed
public :: getTarget
public :: splitText
public :: getIsElementContentWhitespace
public :: setIsElementContentWhitespace
! Assorted functions with identical signatures despite belonging to different types.
public :: getData
public :: setData
public :: getName
public :: getPublicId
public :: getSystemId
public :: normalizeDocument
public :: getNamespaceNodes
public :: namespaceFixup
contains
subroutine resetParameter(domConfig, name)
type(DOMConfiguration), pointer :: domConfig
character(len=*), intent(in) :: name
integer :: i, n
do i = 1, size(configParams)
if (toLower(name)==trim(configParams(i))) then
n = i
exit
endif
enddo
if (i>size(configParams)) return
if (.not.btest(paramSettable, n)) return
if (btest(paramDefaults, n)) then
domConfig%parameters = ibset(domConfig%parameters, n)
else
domConfig%parameters = ibclr(domConfig%parameters, n)
endif
end subroutine resetParameter
recursive subroutine setParameter(domConfig, name, value, ex)
type(DOMException), intent(out), optional :: ex
type(DOMConfiguration), pointer :: domConfig
character(len=*), intent(in) :: name
logical, intent(in) :: value
integer :: i, n
if (toLower(name)=="infoset") then
if (value) then
call setParameter(domConfig, "validate-if-schema", .false.)
call setParameter(domConfig, "entities", .false.)
! cant do datatype-normalization
call setParameter(domConfig, "cdata-sections", .false.)
call setParameter(domConfig, "namespace-declarations", .true.)
! well-formed cannot be changed
call setParameter(domConfig, "element-content-whitespace", .true.)
call setParameter(domConfig, "comments", .true.)
call setParameter(domConfig, "namespaces", .true.)
endif
return
endif
do i = 1, size(configParams)
if (toLower(name)==trim(configParams(i))) then
n = i
exit
endif
enddo
if (i > size(configParams)) then
if (getFoX_checks().or.NOT_FOUND_ERR<200) then
call throw_exception(NOT_FOUND_ERR, "setParameter", ex)
if (present(ex)) then
if (inException(ex)) then
return
endif
endif
endif
endif
if (.not.canSetParameter(domConfig, name, value)) then
if (getFoX_checks().or.NOT_SUPPORTED_ERR<200) then
call throw_exception(NOT_SUPPORTED_ERR, "setParameter", ex)
if (present(ex)) then
if (inException(ex)) then
return
endif
endif
endif
endif
if (value) then
domConfig%parameters = ibset(domConfig%parameters, n)
else
domConfig%parameters = ibclr(domConfig%parameters, n)
endif
select case (toLower(name))
case ("canonical-form")
if (value) then
domConfig%parameters = ibclr(domConfig%parameters, 7)
! cant do normalize-characters
domConfig%parameters = ibclr(domConfig%parameters, 2)
domConfig%parameters = ibset(domConfig%parameters, 9)
domConfig%parameters = ibset(domConfig%parameters, 10)
! well-formed cannot be changed
domConfig%parameters = ibset(domConfig%parameters, 6)
! FIXME when we work out pretty-print/preserve-whitespace semantics
! 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
call resetParameter(domConfig, "cdata-sections")
call resetParameter(domConfig, "namespaces")
call resetParameter(domConfig, "namespace-declarations")
! well-formed cannot be changed
call resetParameter(domConfig, "element-content-whitespace")
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)
case ("element-content-whitespace")
if (.not.value) domConfig%parameters = ibclr(domConfig%parameters, 1)
case ("entities")
if (value) domConfig%parameters = ibclr(domConfig%parameters, 1)
case ("namespaces")
if (.not.value) domConfig%parameters = ibclr(domConfig%parameters, 1)
case ("namespaces-declarations")
if (.not.value) domConfig%parameters = ibclr(domConfig%parameters, 1)
case("validate")
if (value) domConfig%parameters = ibclr(domConfig%parameters, 14)
case ("validate-if-schema")
if (value) domConfig%parameters = ibclr(domConfig%parameters, 13)
case ("format-pretty-print")
if (value) domConfig%parameters = ibclr(domConfig%parameters, 1)
case ("discard-default-content")
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
recursive function getParameter(domConfig, name, ex)result(value)
type(DOMException), intent(out), optional :: ex
type(DOMConfiguration), pointer :: domConfig
character(len=*), intent(in) :: name
logical :: value
integer :: i, n
if (toLower(name)=="infoset") then
value = &
.not.getParameter(domConfig, "validate-if-schema") &
.and..not.getParameter(domConfig, "entities") &
.and..not.getParameter(domConfig, "datatype-normalization") &
.and..not.getParameter(domConfig, "cdata-sections") &
.and.getParameter(domConfig, "namespace-declarations") &
.and.getParameter(domConfig, "well-formed") &
.and.getParameter(domConfig, "element-content-whitespace") &
.and.getParameter(domConfig, "comments") &
.and.getParameter(domConfig, "namespaces")
return
endif
do i = 1, size(configParams)
if (toLower(name)==trim(configParams(i))) then
n = i
exit
endif
enddo
if (i > size(configParams)) then
if (getFoX_checks().or.NOT_FOUND_ERR<200) then
call throw_exception(NOT_FOUND_ERR, "getParameter", ex)
if (present(ex)) then
if (inException(ex)) then
return
endif
endif
endif
endif
value = btest(domConfig%parameters, n)
end function getParameter
function canSetParameter_log(domConfig, name, value, ex)result(p)
type(DOMException), intent(out), optional :: ex
type(DOMConfiguration), pointer :: domConfig
character(len=*), intent(in) :: name
logical, intent(in) :: value
logical :: p
integer :: i, n
if (toLower(name)=="infoset") then
p = .true.
return
endif
do i = 1, size(configParams)
if (toLower(name)==trim(configParams(i))) then
n = i
exit
endif
enddo
if (i > size(configParams)) then
p = .false.
return
endif
p = btest(paramSettable, n)
end function canSetParameter_log
function canSetParameter_ch(domConfig, name, value, ex)result(p)
type(DOMException), intent(out), optional :: ex
type(DOMConfiguration), pointer :: domConfig
character(len=*), intent(in) :: name
character(len=*), intent(in) :: value
logical :: p
! DOM 3 allows some config options to be set to strings
! (eg schemaLocation) but we dont support any of these,
! so no parameter can be set to a string.
p = .false.
end function canSetParameter_ch
function getParameterNames(domConfig, ex)result(s)
type(DOMException), intent(out), optional :: ex
type(DOMConfiguration), pointer :: domConfig
character(len=configParamLen) :: s(size(configParams))
s = configParams
end function getParameterNames
function newDOMConfig() result(dc)
type(DOMConfiguration), pointer :: dc
allocate(dc)
end function newDOMConfig
subroutine copyDOMConfig(dc1, dc2)
type(DOMConfiguration), pointer :: dc1, dc2
dc1%parameters = dc2%parameters
end subroutine copyDOMConfig
subroutine destroyDOMConfig(dc)
type(DOMConfiguration), pointer :: dc
deallocate(dc)
end subroutine destroyDOMConfig
function createNode(arg, nodeType, nodeName, nodeValue, ex)result(np)
type(DOMException), intent(out), optional :: ex
type(Node), pointer :: arg
integer, intent(in) :: nodeType
character(len=*), intent(in) :: nodeName
character(len=*), intent(in) :: nodeValue
type(Node), pointer :: np
allocate(np)
np%ownerDocument => arg
np%nodeType = nodeType
np%nodeName => vs_str_alloc(nodeName)
np%nodeValue => vs_str_alloc(nodeValue)
allocate(np%childNodes%nodes(0))
end function createNode
recursive subroutine destroyNode(np, ex)
type(DOMException), intent(out), optional :: ex
type(Node), pointer :: np
if (.not.associated(np)) return
select case(np%nodeType)
case (ELEMENT_NODE, ATTRIBUTE_NODE, XPATH_NAMESPACE_NODE)
call destroyElementOrAttribute(np, ex)
case (DOCUMENT_TYPE_NODE)
call destroyDocumentType(np, ex)
case (ENTITY_NODE, NOTATION_NODE)
call destroyEntityOrNotation(np, ex)
case (DOCUMENT_NODE)
call destroyDocument(np,ex)
end select
call destroyNodeContents(np)
deallocate(np)
end subroutine destroyNode
recursive subroutine destroyElementOrAttribute(np, ex)
type(DOMException), intent(out), optional :: ex
type(Node), pointer :: np
integer :: i
if (np%nodeType /= ELEMENT_NODE &
.and. np%nodeType /= ATTRIBUTE_NODE &
.and. np%nodeType /= XPATH_NAMESPACE_NODE) then
if (getFoX_checks().or.FoX_INTERNAL_ERROR<200) then
call throw_exception(FoX_INTERNAL_ERROR, "destroyElementOrAttribute", ex)
if (present(ex)) then
if (inException(ex)) then
return
endif
endif
endif
endif
if (associated(np%elExtras%attributes%nodes)) deallocate(np%elExtras%attributes%nodes)
do i = 1, np%elExtras%namespaceNodes%length
call destroyNode(np%elExtras%namespaceNodes%nodes(i)%this)
enddo
if (associated(np%elExtras%namespaceNodes%nodes)) deallocate(np%elExtras%namespaceNodes%nodes)
if (associated(np%elExtras%namespaceURI)) deallocate(np%elExtras%namespaceURI)
if (associated(np%elExtras%prefix)) deallocate(np%elExtras%prefix)
if (associated(np%elExtras%localName)) deallocate(np%elExtras%localName)
deallocate(np%elExtras)
end subroutine destroyElementOrAttribute
subroutine destroyEntityOrNotation(np, ex)
type(DOMException), intent(out), optional :: ex
type(Node), pointer :: np
if (np%nodeType /= ENTITY_NODE &
.and. np%nodeType /= NOTATION_NODE) then
if (getFoX_checks().or.FoX_INTERNAL_ERROR<200) then
call throw_exception(FoX_INTERNAL_ERROR, "destroyEntityOrNotation", ex)
if (present(ex)) then
if (inException(ex)) then
return
endif
endif
endif
endif
if (associated(np%dtdExtras%publicId)) deallocate(np%dtdExtras%publicId)
if (associated(np%dtdExtras%systemId)) deallocate(np%dtdExtras%systemId)
if (associated(np%dtdExtras%notationName)) deallocate(np%dtdExtras%notationName)
deallocate(np%dtdExtras)
end subroutine destroyEntityOrNotation
subroutine destroyDocumentType(np, ex)
type(DOMException), intent(out), optional :: ex
type(Node), pointer :: np
integer :: i
if (np%nodeType /= DOCUMENT_TYPE_NODE) then
if (getFoX_checks().or.FoX_INTERNAL_ERROR<200) then
call throw_exception(FoX_INTERNAL_ERROR, "destroyDocumentType", ex)
if (present(ex)) then
if (inException(ex)) then
return
endif
endif
endif
endif
if (associated(np%dtdExtras%publicId)) deallocate(np%dtdExtras%publicId)
if (associated(np%dtdExtras%systemId)) deallocate(np%dtdExtras%systemId)
! Destroy all entities & notations (docType only)
if (associated(np%dtdExtras%entities%nodes)) then
do i = 1, size(np%dtdExtras%entities%nodes)
call destroyAllNodesRecursively(np%dtdExtras%entities%nodes(i)%this)
enddo
deallocate(np%dtdExtras%entities%nodes)
endif
if (associated(np%dtdExtras%notations%nodes)) then
do i = 1, size(np%dtdExtras%notations%nodes)
call destroy(np%dtdExtras%notations%nodes(i)%this)
enddo
deallocate(np%dtdExtras%notations%nodes)
endif
deallocate(np%dtdExtras)
end subroutine destroyDocumentType
recursive subroutine destroyAllNodesRecursively(arg, except)
! Only recurses once into destroyDocumentType
type(Node), pointer :: arg
logical, intent(in), optional :: except
type(Node), pointer :: this, deadNode, treeroot
logical :: doneChildren, doneAttributes
integer :: i_tree
if (.not.associated(arg)) return
treeroot => arg
i_tree = 0
doneChildren = .false.
doneAttributes = .false.
this => treeroot
deadNode => null()
do
if (.not.doneChildren.and..not.(getNodeType(this)==ELEMENT_NODE.and.doneAttributes)) then
else
if (getNodeType(this)==ELEMENT_NODE.and..not.doneChildren) then
doneAttributes = .true.
else
endif
endif
deadNode => null()
if (.not.doneChildren) then
if (getNodeType(this)==ELEMENT_NODE.and..not.doneAttributes) then
if (getLength(getAttributes(this))>0) then
this => item(getAttributes(this), 0)
else
doneAttributes = .true.
endif
elseif (hasChildNodes(this)) then
this => getFirstChild(this)
doneChildren = .false.
doneAttributes = .false.
else
doneChildren = .true.
doneAttributes = .false.
endif
else ! if doneChildren
deadNode => this
if (associated(this, treeroot)) exit
if (getNodeType(this)==ATTRIBUTE_NODE) then
if (i_tree<getLength(getAttributes(getOwnerElement(this)))-1) then
i_tree= i_tree+ 1
this => item(getAttributes(getOwnerElement(this)), i_tree)
doneChildren = .false.
else
i_tree= 0
this => getOwnerElement(this)
doneAttributes = .true.
doneChildren = .false.
endif
elseif (associated(getNextSibling(this))) then
this => getNextSibling(this)
doneChildren = .false.
doneAttributes = .false.
else
this => getParentNode(this)
endif
call destroy(deadNode)
endif
enddo
deallocate(arg%childNodes%nodes)
allocate(arg%childNodes%nodes(0))
arg%firstChild => null()
arg%lastChild => null()
if (.not.present(except)) call destroyNode(arg)
end subroutine destroyAllNodesRecursively
subroutine destroyNodeContents(np)
type(Node), intent(inout) :: np
if (associated(np%nodeName)) deallocate(np%nodeName)
if (associated(np%nodeValue)) deallocate(np%nodeValue)
deallocate(np%childNodes%nodes)
end subroutine destroyNodeContents
pure function getnodeName_len(np, p) result(n)
type(Node), intent(in) :: np
logical, intent(in) :: p
integer :: n
if (p) then
n = size(np%nodeName)
else
n = 0
endif
end function getnodeName_len
function getnodeName(np, ex)result(c)
type(DOMException), intent(out), optional :: ex
type(Node), pointer :: np
#ifdef RESTRICTED_ASSOCIATED_BUG
character(len=getnodeName_len(np, .true.)) :: c
#else
character(len=getnodeName_len(np, associated(np))) :: c
#endif
if (.not.associated(np)) then
if (getFoX_checks().or.FoX_NODE_IS_NULL<200) then
call throw_exception(FoX_NODE_IS_NULL, "getnodeName", ex)
if (present(ex)) then
if (inException(ex)) then
return
endif
endif
endif
endif
c = str_vs(np%nodeName)
end function getnodeName
pure function getNodeValue_len(np, p) result(n)