Commit 7d37e62
authored
* fix: normalize MacDive UDDF namespace and structural quirks before parsing
MacDive exports declare a default XML namespace on the root element
(xmlns="http://www.streit.cc/uddf/3.2/"), which causes all
findElements() calls in the parser to return empty results since
elements are resolved against that namespace rather than the empty one.
Additionally, MacDive places <country> inside geography/address/country
rather than as a direct child of <site>, and puts <equipmentused> inside
<informationafterdive> rather than <informationbeforedive>.
Adds a UddfNormalizer pre-processing layer that dispatches to dialect-
specific handlers before the existing parser runs. The MacDive handler
strips the namespace declaration, copies <country> up to the <site>
level, and moves <equipmentused> into <informationbeforedive>.
No changes to the core parser. UddfFullImportService.importAllDataFromUddf
is the single integration point, covering all callers automatically.
Adds 25 unit tests covering the normalizer, dialect detection, and
end-to-end field mapping (depth, duration, water temp, notes, profile,
site country, coordinates, weight).
* fix: support MacDive UDDF dialect in import
MacDive exports are valid UDDF 3.2.1 but diverge from the canonical
form the parser expects in several ways:
- Default XML namespace on the root element causes all findElements()
calls to return empty results. Strip it from the raw string before
parsing to avoid re-serialisation ambiguity.
- diveduration and divetime values are float strings (e.g. "3494.00")
which int.tryParse() rejects, leaving runtime empty and collapsing
all profile waypoint timestamps to 0. Fall back to
double.tryParse().round() for both fields.
- Site country is nested at geography/address/country instead of being
a direct child of the site element.
- equipmentused appears inside informationafterdive rather than
informationbeforedive where the parser reads it.
Adds UddfNormalizer dispatcher and MacDiveDialectNormalizer that
pre-processes the raw XML string before the core parser runs.
25 unit tests cover namespace stripping, structural fixes, and full
end-to-end import of all key fields.
* Fix: wrapped angle brackets with backticks in doc comments
* fix: handle float-string passedtime in MacDive UDDF surface interval parsing
MacDive exports all numeric values as float strings (e.g. "3600.00").
int.tryParse fails on these, silently dropping surface intervals. Apply
the same double.tryParse fallback already used for diveduration and
divetime waypoints.
* refactor: introduce UddfDialect strategy pattern for dialect-aware UDDF normalization
Replace the static MacDiveDialectNormalizer utility class with a proper
strategy pattern based on an abstract UddfDialect base class, per maintainer
feedback on the PR.
Changes:
- Add UddfDialect abstract base class with isMatch() and a default no-op
normalizeXml() — the single extension point for new dialects
- Replace MacDiveDialectNormalizer with MacDiveDialect extends UddfDialect,
organised into private _fixEncoding / _fixStructure helpers for readability
- Move float-encoded integer normalisation (e.g. "60.00" -> "60") into
MacDiveDialect._fixEncoding via regex, removing the need for double-parse
fallbacks in the parser
- Rewrite UddfNormalizer to iterate a _dialects list, making adding a new
dialect a one-line registration
- Simplify two int.tryParse fallbacks in UddfFullImportService back to plain
int.tryParse — the parser is now fully dialect-unaware
The parser no longer contains any dialect-specific logic. A new dialect only
requires extending UddfDialect and adding one entry to _dialects.
Tests: 28 passing (3 new — float encoding, UddfDialect passthrough, negative
isMatch detection)
* fix: Update stale namespace comment
* fix: harden MacDive dialect detection and normalization safety
MacDiveDialect.isMatch previously matched on the UDDF 3.2 namespace
alone, which Submersion and Subsurface also use. Detection now checks
<generator> tag first, rejecting known non-MacDive exporters, and falls
back to structural quirk heuristics only when no generator is present.
Also adds idempotency guards to _fixSiteCountry and _moveEquipmentUsed
to prevent duplicate elements on repeated normalization, and creates
<informationbeforedive> when absent instead of silently skipping the
dive (which would lose equipment/weight data).
1 parent e92d5c1 commit 7d37e62
5 files changed
Lines changed: 768 additions & 2 deletions
File tree
- lib/core/services/export/uddf
- dialects
- test/core/services/export/uddf
Lines changed: 136 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments