Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

absence of objects for XML traversing #3774

Open
h1alexbel opened this issue Dec 27, 2024 · 6 comments
Open

absence of objects for XML traversing #3774

h1alexbel opened this issue Dec 27, 2024 · 6 comments

Comments

@h1alexbel
Copy link
Contributor

Currently, there is no EO objects for traversing an XML document (DOM tree). Let's add new set of EO objects to the runtime: eo-dom, that will be standard library for XML manipulation

@h1alexbel
Copy link
Contributor Author

@maxonfjvipon @yegor256 WDYT? I would like to take this

@yegor256
Copy link
Member

yegor256 commented Dec 28, 2024

@h1alexbel can you give an example of its API?

@h1alexbel
Copy link
Contributor Author

h1alexbel commented Dec 29, 2024

@yegor256 I think EO implementation of DOM API can look like this:

+package org.eolang.dom

[] > creates-document-from-string
  (doc "<document/>").as-string > @ # <document/>

[] > creates-document-from-file
  (doc "data.xml").as-string > @ # <root><data>test</data></root>

[] > locates-element
  (doc "data.xml").xpath "//data/text()" # test

[] > appends-element
  ((doc "data.xml").xpath "/root").append "kid" # <root><kid/><data>test</data></root> 

So, basically my idea was to implement three basic operations with DOM in EO:

  • read from string and file,
  • traverse (using XPath),
  • and append an element to an element.

About #2813. As far I understood, it mostly about how we build our XMIR inside of the parser (not runtime objects). We can create some internal tool for XMIR manipulation that can replace XSLT, that we currently use. I also thought that we can create simpler, faster version of XSLT that will use simple DOM operations inside (so this tool will replace XSLT stylesheets we currently use, and will be platform-independent, so it can be shared in both runtimes without a problems).

WDYT?

@yegor256
Copy link
Member

@h1alexbel this is a valid idea, but I'm not sure it belongs to eo-runtime. Maybe it's better to create a new repository for it, similar to how we did with eo-strings, for example. @maxonfjvipon what's your take?

@maxonfjvipon
Copy link
Member

@h1alexbel I believe it definitely should be a separated repository, at least for now. In general, it would be interesting project, so go ahead

@h1alexbel
Copy link
Contributor Author

@yegor256 @maxonfjvipon I've started the development of eo-dom objects: https://github.com/h1alexbel/eo-dom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants