Elegant XML parsing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Elegant XML parsing

cjhowe
Is there an elegant way to read multiple xml files,
group the elements and write a new xml document?

for instance, I'm trying to merge controller.xml files
and am needing the first file read to output all of
the handler elements, read the second file and output
all of the handler elements after the handler elements
from the first
Reply | Threaded
Open this post in threaded view
|

Re: Elegant XML parsing

Leon Torres-2
You could use a scripting language to do this easily.  I would use Ruby with
REXML, which would make this task about 50-100 lines of code.

- Leon


Chris Howe wrote:
> Is there an elegant way to read multiple xml files,
> group the elements and write a new xml document?
>
> for instance, I'm trying to merge controller.xml files
> and am needing the first file read to output all of
> the handler elements, read the second file and output
> all of the handler elements after the handler elements
> from the first
>
Reply | Threaded
Open this post in threaded view
|

Re: Elegant XML parsing

cjhowe
Thanks Leon,

I ended up using XSLT and did it in 20 lines :)
http://issues.apache.org/jira/browse/OFBIZ-77

It doesn't do it on the fly and it's not incorporated
to run as a service or anything and it doesn't parse
the namespace into the root element, but if people
vote for the issue, I'll spend some time making it
accept an array and run as a service.  But it does
what I need and makes one less thing that I have to
look at when updating my applications.

--- Leon Torres <[hidden email]> wrote:

> You could use a scripting language to do this
> easily.  I would use Ruby with
> REXML, which would make this task about 50-100 lines
> of code.
>
> - Leon
>
>
> Chris Howe wrote:
> > Is there an elegant way to read multiple xml
> files,
> > group the elements and write a new xml document?
> >
> > for instance, I'm trying to merge controller.xml
> files
> > and am needing the first file read to output all
> of
> > the handler elements, read the second file and
> output
> > all of the handler elements after the handler
> elements
> > from the first
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: Elegant XML parsing

Jacques Le Roux
Administrator
Thanks Chris (and Leon ;),

I was too thinking that XSLT was the way, but have still to learn...

Jacques

> Thanks Leon,
>
> I ended up using XSLT and did it in 20 lines :)
> http://issues.apache.org/jira/browse/OFBIZ-77
>
> It doesn't do it on the fly and it's not incorporated
> to run as a service or anything and it doesn't parse
> the namespace into the root element, but if people
> vote for the issue, I'll spend some time making it
> accept an array and run as a service.  But it does
> what I need and makes one less thing that I have to
> look at when updating my applications.
>
> --- Leon Torres <[hidden email]> wrote:
>
> > You could use a scripting language to do this
> > easily.  I would use Ruby with
> > REXML, which would make this task about 50-100 lines
> > of code.
> >
> > - Leon
> >
> >
> > Chris Howe wrote:
> > > Is there an elegant way to read multiple xml
> > files,
> > > group the elements and write a new xml document?
> > >
> > > for instance, I'm trying to merge controller.xml
> > files
> > > and am needing the first file read to output all
> > of
> > > the handler elements, read the second file and
> > output
> > > all of the handler elements after the handler
> > elements
> > > from the first
> > >
> >