Grokbase
x

RFC: MooseX::XPathBuilder?

View TopicPrint | Flat  Thread  Threaded
1) Ian Sillitoe Hello, I have a role lying around in my code that requires an XML source and provides a trait that...
| +1 vote (Anchor)
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Hello,

I have a role lying around in my code that requires an XML source and
provides a trait that allows an attribute's value to default to a
specified XPath. I've found it useful as a quick way of extracting
snippets of XML data into an object.

I now need to refactor this out to somewhere else in my code - so
figured it might be an appropriate time to ask if this would be useful
to stick on cpan? Clashes with other modules?

Also, the trait works by changing options through: around
'_process_options' (lazy =3D> 1 and default =3D> sub { ... }) - does that
sound sane? I couldn't see anything on the extending moose docs about
what is considered typical (or safe/stable) to hook into - is there a
consensus on this?


#################################

package PDBx::NoAtom;

use PDBx::Moose;
use MooseX::Types::Moose qw/ Str ArrayRef /;
use namespace::autoclean;

our $VERSION =3D "0.01";

with 'MooseX::XPathBuilder';

has 'id' =3D> (
=A0=A0=A0 traits=A0=A0=A0=A0=A0 =3D> [ 'XPathBuilder' ],
=A0=A0=A0 is=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D> 'ro',
=A0=A0=A0 isa=A0=A0=A0=A0=A0=A0=A0=A0 =3D> Str,
=A0=A0=A0 xpath=A0=A0=A0=A0=A0=A0 =3D> '//PDBx:entry[1]/@id',
);

map {
=A0=A0=A0 has 'primary_citation_' . $_ =3D> (
=A0=A0=A0=A0=A0=A0=A0 traits=A0=A0=A0=A0=A0 =3D> [ 'XPathBuilder' ],
=A0=A0=A0=A0=A0=A0=A0 is=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D> 'ro',
=A0=A0=A0=A0=A0=A0=A0 isa=A0=A0=A0=A0=A0=A0=A0=A0 =3D> Str,
=A0=A0=A0=A0=A0=A0=A0 xpath=A0=A0=A0=A0=A0=A0 =3D>
q{//PDBx:citationCategory/PDBx:citation[@id=3D'primary']/PDBx:} . $_,
=A0=A0=A0 );
} qw(
=A0=A0=A0 country
=A0=A0=A0 journal_abbrev
=A0=A0=A0 journal_volume
=A0=A0=A0 page_first
=A0=A0=A0 page_last
=A0=A0=A0 pdbx_database_id_PubMed
=A0=A0=A0 title
=A0=A0=A0 year
);

#################################

use PDBx::NoAtom;

my $pdb =3D PDBx::NoAtom->new( xml_file =3D> '1cuk-noatom.xml.gz' );

$pdb->id=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0 # '1CUK'

$pdb->primary_citation_title;=A0=A0 # 'Crystal structure of DNA recombinati=
on
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 #=A0 protein RuvA and a model for its
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 #=A0 binding to the Holliday junction.'

#################################


All comments appreciated.

Cheers,

--
Ian Sillitoe
2) Robin Smidsrød This is extremely similar to my Rabbit module. Still not on CPAN, but it is lurking around here:...
| +1 vote (Anchor)
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On 27.01.2010 13:23, Ian Sillitoe wrote:
> Hello,
>
> I have a role lying around in my code that requires an XML source and
> provides a trait that allows an attribute's value to default to a
> specified XPath. I've found it useful as a quick way of extracting
> snippets of XML data into an object.

This is extremely similar to my Rabbit module. Still not on CPAN, but it
is lurking around here: http://github.com/robinsmidsrod/Rabbit

We've been discussing it together with other XML-related technologies
related to Moose on the #xml-toolkit channel on irc.perl.org

Come join us if you're interested.

Regards,
Robin Smidsrød
3) Ian Sillitoe 2010/1/27 Robin Smidsrød <robin@smidsrod.no>: Yup - that looks exactly the sort of thing that I was...
| +1 vote (Anchor)
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2010/1/27 Robin Smidsrød <robin@smidsrod.no>:
> On 27.01.2010 13:23, Ian Sillitoe wrote:
>> Hello,
>>
>> I have a role lying around in my code that requires an XML source and
>> provides a trait that allows an attribute's value to default to a
>> specified XPath. I've found it useful as a quick way of extracting
>> snippets of XML data into an object.
>
> This is extremely similar to my Rabbit module. Still not on CPAN, but it
> is lurking around here: http://github.com/robinsmidsrod/Rabbit


Yup - that looks exactly the sort of thing that I was putting together
- what are your plans for releasing this? I won't bother sticking my
stuff on CPAN.


> We've been discussing it together with other XML-related technologies
> related to Moose on the #xml-toolkit channel on irc.perl.org
>
> Come join us if you're interested.


Just popped in but seems no one's around. Will try check in again later.

Cheers,

--
Ian Sillitoe
CATH Team -- http://www.cathdb.info
4) Robin Smidsrød I'm not completely satisfied with the implementation of the _node, _xpc and namespace_map...
| +1 vote (Anchor)
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On 27.01.2010 16:33, Ian Sillitoe wrote:
> 2010/1/27 Robin Smidsrød <robin@smidsrod.no>:
>> On 27.01.2010 13:23, Ian Sillitoe wrote:
>
> Yup - that looks exactly the sort of thing that I was putting together
> - what are your plans for releasing this? I won't bother sticking my
> stuff on CPAN.
>

I'm not completely satisfied with the implementation of the _node, _xpc
and namespace_map attributes in Rabbit::RootNode and Rabbit::Node. I'd
like them to be stored inside the ->meta or somewhere hidden, so that
they don't pollute the namespace of the class that uses Rabbit::RootNode
or Rabbit::Node. If anyone knows how to do this I'd appreciate a patch
or some input very much. :)

Updating the namespace_map should also be done in a cleaner way. The
override syntax used today could be changed into something else, but I'm
not exactly sure what would be better.

On top of that I might rename it to XML::Rabbit instead of Rabbit to
make it more obvious that it is a class that deals with XML. If any of
you have some input on the name I'd love to hear it.

>
>> We've been discussing it together with other XML-related technologies
>> related to Moose on the #xml-toolkit channel on irc.perl.org
>>
>> Come join us if you're interested.
> Just popped in but seems no one's around. Will try check in again later.

The channel is not very active. Mentioning people by name helps to get
attention.

-- Robin
spacer
View TopicPrint | Flat  Thread  Threaded
Home > Groups > Moose > RFC: MooseX::XPathBuilder? (4 posts)