我正在使用 SSAX-SXML 来处理仅模仿 XML 数据编码的树结构。所以我想到了直接使用 SXML 表示作为数据结构来使用。一切运行良好,我获得了默认访问器和 XPath 的所有功能,我发现它们非常有用。
但我有一个问题。XML 将所有内容都表示为字符串,因此我需要一直将字符串转换为数字,反之亦然。这将扼杀性能并且只是一个糟糕的设计理念。我正在考虑获取 SXML 列表并将所有字符串一次性转换为数字。但是,是否有 SXML 直接执行此操作的方法或通过 XML 告知某些内容应该表示为数字而不是字符串的方法?
这是我的 SXML 列表:
((wall (@ (uid "2387058723"))
(pt (@ (y "2.0") (x "1.0")))
(pt (@ (y "4.0") (x "3.0"))))
(wall (@ (uid "5493820876"))
(pt (@ (y "0.0") (x "0.0")))
(pt (@ (y "100.0") (x "0.0")))
(window (@ (to "0.4") (from "0.2")))
(window (@ (size "1.0") (from "0.2")))
(door (@ (size "1.0") (from "0.2"))))
(pilar (@ (uid "692034802"))
(center (@ (y "5.0") (x "5.0")))
(dim (@ (b "0.45") (a "0.3"))))
(room (@ (label "salon"))
(wall (@ (uid "2387058723")))
(wall (@ (uid "5493820876")))
(wall (@ (uid "5394501263")))
(wall (@ (uid "0034923049"))))
(entry (@ (doorNumber "0")) (wall (@ (uid "5493820876"))))
(num "0,9")
(pipe (@ (y "8.0") (x "10.0"))))
从一个看起来像这样的 XML(摘录):
<wall uid="2387058723">
<pt x="1.0" y="2.0"/>
<pt x="3.0" y="4.0"/>
</wall>
谢谢你。