Rebol 的 DOM 类似 Rebol 区块的库?

发布于 2024-08-09 10:59:31 字数 114 浏览 1 评论 0原文

我同意 Carl 的观点,即与 Rebol 的 Block 相比,XML 过于冗长,但 Rebol 的 Block 没有等效的 XML DOM 库,还是我弄错了?

如何遍历 block 的层次结构?

I agree with Carl that XML is too much verbose compared to Rebol's Block but there is no equivalent of XML DOM library for Rebol's Block or am I mistaken ?

How can I iterate through a hierarchy of block ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北座城市 2024-08-16 10:59:31

Rebol 的运行时块抽象!不足以覆盖 DOM。一个技术障碍是您无法获得块的单个唯一“父级”,因为它可能在多个位置具有别名。例如:

>> foo: [div id: "foo"]
== [div id: "foo"]

>> bar: [div id: "bar"]
== [div id: "bar"]

>> paragraph: [p ["Hello"]]
== [p ["Hello"]]

>> append foo append/only [contents:] paragraph
== [div id: "foo" contents: [p ["Hello"]]]

>> append bar append/only [contents:] paragraph
== [div id: "bar" contents: [p ["Hello"]]]

>> append second paragraph "World"
== ["Hello" "World"]

>> foo/contents
== [p ["Hello" "World"]]

>> bar/contents
== [p ["Hello" "World"]]

没有办法编写一个可以有意义地回答“获取父栏/内容”等问题的函数。尽管您已经得到了一些已被解析并带入您可以操作的结构中的内容,但它并不是一个具有与 DOM 匹配的特定设计的结构。

要像树一样自由地攀爬它,您必须构建一堆通过引用连接的对象。这几乎是所有其他语言所做的事情,所以这里没有免费的午餐。从好的方面来说,我们会为您处理部分解析工作,并且无需 DOM 库即可执行相当多的操作。这是比文本更好的起点!

不利的一面是,它看起来过于自由,以至于您想知道它是针对哪些用例进行优化的。答案是,除了 Rebol 方言之外,它没有针对任何其他方面进行了专门优化。 :) 循环推理,但它产生了一些特性,使该语言变得有趣,并且使其具有“永恒”的性质。

您可能会发现扩展标签提案的各个方面以及它引发的讨论很有启发性。

Rebol's runtime abstraction of block! is not adequate for getting coverage of the DOM. One technical barrier is that you can't get the single unique "parent" of a block, as it may be aliased at several locations. So for instance:

>> foo: [div id: "foo"]
== [div id: "foo"]

>> bar: [div id: "bar"]
== [div id: "bar"]

>> paragraph: [p ["Hello"]]
== [p ["Hello"]]

>> append foo append/only [contents:] paragraph
== [div id: "foo" contents: [p ["Hello"]]]

>> append bar append/only [contents:] paragraph
== [div id: "bar" contents: [p ["Hello"]]]

>> append second paragraph "World"
== ["Hello" "World"]

>> foo/contents
== [p ["Hello" "World"]]

>> bar/contents
== [p ["Hello" "World"]]

There's no way to write a function that can meaningfully answer questions like "get-parent bar/contents". Although you've got something which has been parsed and brought into a structure you can manipulate, it isn't a structure with particular designs matching the DOM.

To climb around it freely as a tree you'd have to build a bunch of objects connected with references. That's pretty much what every other language does, so no free lunch to be had here. On the plus side, part of the parsing is taken care of for you and there's quite a bit of manipulation you can do without a DOM library. It's a way better place to start than text!

On the downside, it can seem so freeform that you wonder what use cases it was optimized for. The answer is that it specifically wasn't optimized for anything, other than dialecting Rebol. :) Circular reasoning, but it has given rise to the properties that make the language interesting to study and which makes it sort of "timeless".

You might find aspects of the extended tag proposal and the discussion it provoked to be illuminating.

一杆小烟枪 2024-08-16 10:59:31

是的,Rebol 可用于这些目的。它可以通过 DSL 模拟任何语言。尝试使用 Mdlparser 进行 %Rebol-DOM.r 视图。

Yes Rebol can be used for these purposes. It can mimic any language by way of DSL's. Try %Rebol-DOM.r view with Mdlparser.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文