Project

General

Profile

« Previous | Next » 

Revision 1832

xml_dom.py: value(): Skip comment nodes. This fixes a bug where comments inside text elements would prevent the value from being retrieved.

View differences:

inputs/CTFS/test/VegX.organisms.xml.ref
2 2
<VegX xmlns:tcs="http://www.tdwg.org/schemas/tcs/1.01">
3 3
    <individualOrganismObservations id="0">
4 4
        <individualOrganismObservation>
5
            <individualOrganismID>0</individualOrganismID>
5 6
            <plotObservationID>0</plotObservationID>
6 7
            <relativePlotPosition>
7 8
                <relativeX>-79.848494</relativeX>
......
13 14
            </simpleUserdefined>
14 15
        </individualOrganismObservation>
15 16
    </individualOrganismObservations>
17
    <individualOrganisms>
18
        <individualOrganism id="0"><taxonNameUsageConceptID>0</taxonNameUsageConceptID></individualOrganism>
19
        <individualOrganism id="1"><taxonNameUsageConceptID>1</taxonNameUsageConceptID></individualOrganism>
20
    </individualOrganisms>
21
    <taxonNameUsageConcepts>
22
        <taxonNameUsageConcept id="0"/>
23
        <taxonNameUsageConcept id="1"/>
24
    </taxonNameUsageConcepts>
25
    <taxonDeterminations>
26
        <taxonDetermination>
27
            <taxonNameUsageConceptID>0</taxonNameUsageConceptID>
28
            <partyWithRole><role>computer</role></partyWithRole>
29
            <taxonRelationshipAssertions><taxonRelationshipAssertion><assertion><taxonConceptID>0</taxonConceptID></assertion></taxonRelationshipAssertion></taxonRelationshipAssertions>
30
        </taxonDetermination>
31
        <taxonDetermination>
32
            <taxonNameUsageConceptID>0</taxonNameUsageConceptID>
33
            <partyWithRole><role>identifier</role></partyWithRole>
34
            <taxonRelationshipAssertions>
35
                <taxonRelationshipAssertion><assertion><taxonConceptID>1</taxonConceptID></assertion></taxonRelationshipAssertion>
36
                <taxonRelationshipAssertion><assertion><taxonConceptID>2</taxonConceptID></assertion></taxonRelationshipAssertion>
37
            </taxonRelationshipAssertions>
38
        </taxonDetermination>
39
        <taxonDetermination>
40
            <taxonNameUsageConceptID>1</taxonNameUsageConceptID>
41
            <partyWithRole><role>computer</role></partyWithRole>
42
            <taxonRelationshipAssertions><taxonRelationshipAssertion><assertion><taxonConceptID>3</taxonConceptID></assertion></taxonRelationshipAssertion></taxonRelationshipAssertions>
43
        </taxonDetermination>
44
        <taxonDetermination>
45
            <taxonNameUsageConceptID>1</taxonNameUsageConceptID>
46
            <partyWithRole><role>identifier</role></partyWithRole>
47
            <taxonRelationshipAssertions>
48
                <taxonRelationshipAssertion><assertion><taxonConceptID>4</taxonConceptID></assertion></taxonRelationshipAssertion>
49
                <taxonRelationshipAssertion><assertion><taxonConceptID>5</taxonConceptID></assertion></taxonRelationshipAssertion>
50
            </taxonRelationshipAssertions>
51
        </taxonDetermination>
52
    </taxonDeterminations>
53
    <taxonConcepts>
54
        <taxonConcept id="0">
55
            <tcs:Rank code="sp"/>
56
            <tcs:Name>prunifolius</tcs:Name>
57
        </taxonConcept>
58
        <taxonConcept id="1">
59
            <tcs:Rank code="fam"/>
60
            <tcs:Name>Violaceae</tcs:Name>
61
        </taxonConcept>
62
        <taxonConcept id="2">
63
            <tcs:Rank code="gen"/>
64
            <tcs:Name>Hybanthus</tcs:Name>
65
        </taxonConcept>
66
        <taxonConcept id="3">
67
            <tcs:Rank code="sp"/>
68
            <tcs:Name>asterolepis</tcs:Name>
69
        </taxonConcept>
70
        <taxonConcept id="4">
71
            <tcs:Rank code="fam"/>
72
            <tcs:Name>Malvaceae</tcs:Name>
73
        </taxonConcept>
74
        <taxonConcept id="5">
75
            <tcs:Rank code="gen"/>
76
            <tcs:Name>Quararibea</tcs:Name>
77
        </taxonConcept>
78
    </taxonConcepts>
16 79
    <plotObservations>
17 80
        <plotObservation id="0"><obsStartDate>1981-05-03</obsStartDate></plotObservation>
18 81
        <plotObservation id="1"><obsStartDate>1981-05-03</obsStartDate></plotObservation>
19 82
    </plotObservations>
20 83
    <individualOrganismObservations id="1">
21 84
        <individualOrganismObservation>
85
            <individualOrganismID>1</individualOrganismID>
22 86
            <plotObservationID>1</plotObservationID>
23 87
            <relativePlotPosition>
24 88
                <relativeX>-79.84848</relativeX>
inputs/CTFS/test/VegBIEN.organisms.xml.ref
21 21
                <definedvalue>1</definedvalue>
22 22
            </definedvalue>
23 23
        </aggregateoccurrence>
24
        <taxondetermination>
25
            <role>computer</role>
26
            <iscurrent>true</iscurrent>
27
            <plantconcept_id>
28
                <plantconcept>
29
                    <plantname_id>
30
                        <plantname>
31
                            <rank>species</rank>
32
                            <plantname>prunifolius</plantname>
33
                        </plantname>
34
                    </plantname_id>
35
                </plantconcept>
36
            </plantconcept_id>
37
        </taxondetermination>
38
        <taxondetermination>
39
            <role>identifier</role>
40
            <isoriginal>true</isoriginal>
41
            <iscurrent>true</iscurrent>
42
            <plantconcept_id>
43
                <plantconcept>
44
                    <plantname_id>
45
                        <plantname>
46
                            <rank>genus</rank>
47
                            <plantname>Hybanthus</plantname>
48
                            <parent_id>
49
                                <plantname>
50
                                    <rank>family</rank>
51
                                    <plantname>Violaceae</plantname>
52
                                </plantname>
53
                            </parent_id>
54
                        </plantname>
55
                    </plantname_id>
56
                </plantconcept>
57
            </plantconcept_id>
58
        </taxondetermination>
24 59
    </taxonoccurrence>
25 60
    <taxonoccurrence id="1">
26 61
        <locationevent_id><locationevent><obsstartdate>1981-05-03</obsstartdate></locationevent></locationevent_id>
......
43 78
                <definedvalue>1</definedvalue>
44 79
            </definedvalue>
45 80
        </aggregateoccurrence>
81
        <taxondetermination>
82
            <role>computer</role>
83
            <iscurrent>true</iscurrent>
84
            <plantconcept_id>
85
                <plantconcept>
86
                    <plantname_id>
87
                        <plantname>
88
                            <rank>species</rank>
89
                            <plantname>asterolepis</plantname>
90
                        </plantname>
91
                    </plantname_id>
92
                </plantconcept>
93
            </plantconcept_id>
94
        </taxondetermination>
95
        <taxondetermination>
96
            <role>identifier</role>
97
            <isoriginal>true</isoriginal>
98
            <iscurrent>true</iscurrent>
99
            <plantconcept_id>
100
                <plantconcept>
101
                    <plantname_id>
102
                        <plantname>
103
                            <rank>genus</rank>
104
                            <plantname>Quararibea</plantname>
105
                            <parent_id>
106
                                <plantname>
107
                                    <rank>family</rank>
108
                                    <plantname>Malvaceae</plantname>
109
                                </plantname>
110
                            </parent_id>
111
                        </plantname>
112
                    </plantname_id>
113
                </plantconcept>
114
            </plantconcept_id>
115
        </taxondetermination>
46 116
    </taxonoccurrence>
47 117
</VegBIEN>
inputs/CTFS/test/import.organisms.out.ref
1
Inserted 13 new rows into database
1
Inserted 27 new rows into database
lib/xml_dom.py
147 147
def is_text(node): return has_one_child(node) and is_text_node(node.firstChild)
148 148

  
149 149
def value(node):
150
    if node.firstChild != None: return node.firstChild.nodeValue
150
    if is_elem(node):
151
        iter_ = NodeIter(node)
152
        util.skip(iter_, is_comment)
153
        try: return iter_.next().nodeValue
154
        except StopIteration: return None
151 155
    else: return node.nodeValue
152 156

  
153 157
def is_whitespace(node): return is_text_node(node) and value(node).isspace()

Also available in: Unified diff