silverdr
Any well established methods of handling XML data from / to PostgreSQL xml columns using Ecto? How do Elixir veterans do it? If they do, of course… ![]()
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 15 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Schultzer
Yeah, my Postgres driver is going to support anything out of the box, as any type even custom types in the end can be decoded to their base type, for XML it would be text.
But we probably want more then just text if we’re going to do more work with it in our application code.
silverdr
The post about “saviour” comment on github was about the fact that even if you create a custom Ecto type, you still cannot access XML data (even as string) from PostgreSQL column of XML type as you’ll get “type ‘xml’ can not be handled” errors. The solution is to add
And - TBH - the quote of the author there:
Postgrex.Extensionimplementation that treats it astextI presume. Not something exceptionally elegant I’d say (if I understood all of it)applies directly to me too
IOW - it was about getting the XML data out of the column “at all” and hence as string.
Schultzer
Yeah, I think I miss understood your comment and the issue.
I understod the issue to just wanting the xml to be decoded as a string, there is not a lot of value in that if you want to do further validation in your application code, that was what was what I was trying to refer to with structured, where I’m thinking Elixir terms. It could be an XML AST.
silverdr
I am not 100% sure I understand correctly, but in the end XML being string is of little value. It’s only a string representation of some structure so at some point I always need it “structured” in the sense I wrote above some time ago:
Schultzer
I’m about to deal with XML in my postgres driver, currently it just returns as a string automatically, but I wonder if you preferred it to be structured.
silverdr
FWIW - in relation to working with PostgreSQL XML columns’ records - this comment is a “saviour”
https://github.com/elixir-ecto/postgrex/issues/439#issuecomment-460851060
dimitarvp
I am joining @christhekeele here – f.ex. using
:xmerlis maddening because it has a nice low-level streaming interface (among others!) because on the one hand, 95% of the code is exactly the same… but the other 5% vary every frakkin time. This really makes it very difficult to extract out libraries. I entertained the idea but ultimately concluded it would add too little value for what would basically be just one instance of a SAX parser with the ability to pass “callbacks” to it… something everyone can roll in literal one hour maximum.christhekeele
I agree it’s scattered, but in practice those bits and pieces are well battle-tested, so it becomes hard to rationalize a thin wrapper around them just for convenience’s sake (when you can be production ready with a handful of function calls, or
defdelegates if you want to make your own holistic interface).Not saying we shouldn’t make a nice convenient wrapper—see, for example, the widely popular ets package—just encouraging you to articulate where you could see such a library substantially adding value, enough to rationalize a new dependency.
That kind of shopping list is what motivates people to strike dirt and create a new library.
I myself have thought about it before, for example, but ultimately the only two compelling differentiating features I’ve been able to come up with would be an Ecto.Type and streamlining SOAP handling specifically, both of which work just fine as their own stand-alone libraries and do not benefit substantially from being tightly integrated with the other bits and pieces of validation, streaming, building, etc.
The other attractive proposition for a holistic wrapper library would be to improve upon the Elixir ergonomics of working with the erlang libraries’ records. However, since polymorphism isn’t particularly useful in this domain outside of tapping into existing protocols—specifically
InspectandEnumerable—I’ve found that motivation to be sufficiently lacking to build out a library for that purpose alone.One day something may tip that scale, and conversations like these are what cause me to
mix newin my~/code/oss/elixirfolder more than anything.silverdr
Roger, thank you. I’ll have to sculpt something out of it. I didn’t say it’s not possible but that nothing I found is “full-fledged” as in “handles all both ways”. Things are scattered, and there are bits and pieces here and there. Even with your suggestions – where you surely have done these type of things before – it’s still three different libs, including an Erlang one. I’d dream of something like e. g.
JSON.decode,JSON.encode, as XML.de/encode, augmented withXML.validateand XML Ecto type. Anyway - it is what it is.Hehe… Yes, I know. Been there, seen that. Not in Elixir though
christhekeele
Yup, in that case I’d make a custom Ecto.Type for serializing/deserializing the
xmlcolumn between Elixir as binary, and look intoerlxmlthe sdtlib’sxmerl_xsdfor XSD validation. You could then considersweet_xmlif you want to use xpath to extract data, or just work withthe stdlib’serlxmlxmerlparsing. Thexml_builderlibrary should help you build responses and you can pass that back throughxmerl_xsdfor validation, and a properly implemented Ecto.Type should be capable of serializing resultant binaries back into postgresxmlcolumns.Truly, you are blessed.