Hi, I''ve already talked about this in another topic, but I''ve found another approach. We have some complex definitions and structures in our database and I''d like to make it possible to simplify adding items to the application. I''d like to do that using XML. Using XML we''ll define a few common item structures that can be used as a template for new items. But I don''t want to actually store physical XML-files on the server, I want to store the XML in a database. Now my question is: how to do that? I know how to store it, but I don''t know how to read it. The sequence is quite simple. If a user wants to create a new item from a template, they select the appropriate template and the XML needs to be parsed so that the right values are copied into the right tables. Is this possible and how? The XML-parsers I know need to be fed from a file and I don''t want to do that. Thank you!
We do this in the Kete app (http://github.com/kete/kete). Look in lib/ extended_fields.rb for example code. In hindsight, I would probably have been better off to have done this with either marshalling or YAML rather than storing XML though. Cheers, Walter On Oct 9, 2009, at 10:35 PM, jhaagmans <jaap.haagmans-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I''ve already talked about this in another topic, but I''ve found > another approach. > > We have some complex definitions and structures in our database and > I''d like to make it possible to simplify adding items to the > application. I''d like to do that using XML. Using XML we''ll define a > few common item structures that can be used as a template for new > items. But I don''t want to actually store physical XML-files on the > server, I want to store the XML in a database. Now my question is: how > to do that? I know how to store it, but I don''t know how to read it. > > The sequence is quite simple. If a user wants to create a new item > from a template, they select the appropriate template and the XML > needs to be parsed so that the right values are copied into the right > tables. Is this possible and how? The XML-parsers I know need to be > fed from a file and I don''t want to do that. > > Thank you! > >
jhaagmans wrote:> Hi, > > I''ve already talked about this in another topic, but I''ve found > another approach. > > We have some complex definitions and structures in our database and > I''d like to make it possible to simplify adding items to the > application. I''d like to do that using XML. Using XML we''ll define a > few common item structures that can be used as a template for new > items. But I don''t want to actually store physical XML-files on the > server, I want to store the XML in a database. Now my question is: how > to do that? I know how to store it, but I don''t know how to read it.[...] I would suggest that XML or YAML in the DB is the wrong approach. I understand that you want flexibility without needing to change the schema, so why not consider a document database such as CouchDB? It sounds like this is really what you''re looking for. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
> I would suggest that XML or YAML in the DB is the wrong approach. I > understand that you want flexibility without needing to change the > schema, so why not consider a document database such as CouchDB? It > sounds like this is really what you''re looking for.Nope, I''m really looking for XML in a MySQL db. I hoped there was something like REXML to read XML from a database, but I can''t find it. We can always consider putting physical XML files somewhere, but I''d prefer putting it in the db.
jhaagmans wrote:>> I would suggest that XML or YAML in the DB is the wrong approach. �I >> understand that you want flexibility without needing to change the >> schema, so why not consider a document database such as CouchDB? �It >> sounds like this is really what you''re looking for. > > Nope, I''m really looking for XML in a MySQL db.Why? From your description, it sounds like a schemaless database like CouchDB is ideal here. Why do you specifically need XML?> I hoped there was > something like REXML to read XML from a database, but I can''t find it.If you use YAML, there''s Rails'' serialize method. But it''s still a pretty bad idea. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
On 11 okt, 16:36, Marnen Laibow-Koser <rails-mailing-l...@andreas- s.net> wrote:> jhaagmans wrote: > >> I would suggest that XML or YAML in the DB is the wrong approach. I > >> understand that you want flexibility without needing to change the > >> schema, so why not consider a document database such as CouchDB? It > >> sounds like this is really what you''re looking for. > > > Nope, I''m really looking for XML in a MySQL db. > > Why? From your description, it sounds like a schemaless database like > CouchDB is ideal here. Why do you specifically need XML?Because I have a client who already manually defines these items in XML for another application.
On Oct 11, 7:19 am, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I would suggest that XML or YAML in the DB is the wrong approach. I > > understand that you want flexibility without needing to change the > > schema, so why not consider a document database such as CouchDB? It > > sounds like this is really what you''re looking for. > > Nope, I''m really looking for XML in a MySQL db. I hoped there was > something like REXML to read XML from a database, but I can''t find it. >What part of REXML::Document.new(xml_string_from_the_db) doesn''t work for you? :) --Matt Jones