Skip to content

Have you considered implementing a declarative syntax for parsing? #99

Description

@thiagomajesk

Hi again! The last time we spoke I've been using Saxy to create an RSS feed parser and after successfully implementing the RSS 2.0 spec, I'm now trying to make the handler code a little bit more generic to accept other types of configuration and was wondering if you have ever considered implementing something similar to https://github.com/pauldix/sax-machine with Saxy (and if not, how hard would it be to get it done in your opinion).

I've been toying with the idea, but since I'm not used to parsing documents in SAX-style I'm having a bit of trouble figuring out a nice way of abstracting the handler logic into something more reusable that does not compromise that much performance. I figure this type of configuration could be passed to a generic handler and elements being parsed accordingly:

[
  [element: :title],
  [element: :cloud],
  [element: :image, from: image_mappings],	
  [element: "textInput", from: text_input_mappings],
  [elements: "skipHours", from: skip_hours_mappings],
  [elements: :item, as: :entry, from: entry_mappings]
]

Update¹: I'm seeing this section in the docs about the Saxy.Builder https://hexdocs.pm/saxy/Saxy.html#module-encoder, that presents a declarative API for encoding the data into XML, but it couldn't find if the other way around is also supported.

Update²: I'm also gonna link the repo I'm working on, perhaps you could give me some pointers on how better to optimize/ reuse the parsing code: https://github.com/thiagomajesk/gluttony.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions