Am Mittwoch, 19. Mai 2010 00:52:29 schrieb Chris Prather:

> > There are a few minor questions related to b) - regarding, e.g., the
> > handling of attributes belonging to different namespaces - which can
> > probably be sorted out - read: expect more mails to come ;-)
> 
> I don't know about PRANG but XML::Toolkit has XMLNS support in the
> most recent versions.

PRANG seems to have some support for this, too, but I couldn't wrap my head 
around that yet. I think I'll leave that for another post, since I probably 
need to describe the specific problem in more detail which wouldn't fit into 
this thread.
 
> Out of curiosity why are you looking at PRANG? I ask this as the maint
> for XML::Toolkit wondering which features to steal / recommend PRANG
> over XML::Toolkit ... or how to make the interactions between the two
> easier.

Well, I initially started out with XML::Compile::Schema and then had a look 
for a tool that would provide some support for creating MODS records 
programmatically.
The one-sentence-abstract for PRANG on CPAN "XML graph engine - XML to Moose 
objects and back!" got me attracted and the seemingly strong connection to XML 
Schemata kept me there.

> > But how am I supposed to tackle this problem using Moose/PRANG? Changing
> > the 'isa' property of Moose attributes at runtime based on the value of
> > another attribute (holding the MODS version number) seems weird.
> > I'd be glad if someone could describe possible solutions and/or point to
> > existing code solving this kind of problem.
> 
> Previous ways I've used to solve this is to make all options possible
> but not required. That is make a single set of classes handle all
> possible forms of the input document, and confirm that they round-trip
> the output properly. However what you lose is the latent validation
> that simply building a parse tree provides, and that can be "icky".

So in the end I'd have to do the validation (i.e., adding checks to the setter 
method if xml subelements and xml attribute values are legal in the concrete 
record I'm dealing with) by hand. 
At least that would leave me with easy serialization.

Which reminds me that - when parsing a XML record - the constructor method 
needs to find out about the MODS version of the record that's being parsed.
Yuck. The more I think about it, there more headaches I get ;-)

> Karen's suggestion elsewhere in this thread about using a
> Parametarized role is an interesting one, and I suspect something like
> that where you have different "versions" of the classes and write a
> custom parser that inspects the version element before continuing on
> the parse for the different versions of MODS is probably a less
> "radical" version of this same idea. In XML::Toolkit you'd do this by
> subclassing the Loader and overriding the parse functionality, it's
> non-trivial but not exactly rocket science ... 

That probably depends on the experience level of the programmer... :-]

> it's also never been
> done so there may be unknown dragons. With PRANG, I hope Sam Vilain
> speaks up.

Thanks for your hints!
Heiko

Reply via email to