-Return all of the urls associated with this description in an array.\r
-\r
-=head2 get_best_url( )\r
-\r
-Attempts to retrieve the best URL associated with this description, based\r
-on the following content types (from most preferred to least preferred):\r
-\r
-=over 4\r
-\r
-=item * application/atom+xml\r
-\r
-=item * application/rss+xml\r
-\r
-=item * text/xml\r
-\r
-=back\r
-\r
-=head2 get_url_by_type( $type )\r
-\r
-Retrieves the first WWW::OpenSearch::URL associated with this description\r
-whose type is equal to $type.\r
-\r
-=head1 ACCESSORS\r
-\r
-=head2 version( )\r
-\r
-=head2 ns( )\r
-\r
-=head2 AdultContent( )\r
-\r
-=head2 Contact( )\r
-\r
-=head2 Description( )\r
-\r
-=head2 Developer( )\r
-\r
-=head2 Format( )\r
-\r
-=head2 Image( )\r
-\r
-=head2 LongName( )\r
-\r
-=head2 Query( )\r
-\r
-=head2 SampleSearch( )\r
-\r
-=head2 ShortName( )\r
-\r
-=head2 SyndicationRight( )\r
-\r
-=head2 Tags( )\r
-\r
-=head2 Url( )\r
-\r
-=head1 AUTHOR\r
-\r
-=over 4\r
-\r
-=item * Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>\r
-\r
-=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
-\r
-=back\r
-\r
-=head1 COPYRIGHT AND LICENSE\r
-\r
-Copyright 2006 by Tatsuhiko Miyagawa and Brian Cassidy\r
-\r
-This library is free software; you can redistribute it and/or modify\r
-it under the same terms as Perl itself. \r
-\r
-=cut\r
-\r
-for( @columns ) {\r
- no strict 'refs';\r
- my $col = lc;\r
- *$_ = \&$col;\r
-}\r
-\r
-sub new {\r
- my $class = shift;\r
- my $xml = shift;\r
- \r
- my $self = $class->SUPER::new;\r
- \r
- eval{ $self->load( $xml ); } if $xml;\r
- if( $@ ) {\r
- croak "Error while parsing Description XML: $@";\r
- }\r
-\r
- return $self;\r
-}\r
-\r
-sub load {\r
- my $self = shift;\r
- my $xml = shift;\r
- \r
- my $parser = XML::LibXML->new;\r
- my $doc = $parser->parse_string( $xml );\r
- my $element = $doc->documentElement;\r
- my $nodename = $element->nodeName;\r
-\r
- croak "Node should be OpenSearchDescription: $nodename" if $nodename ne 'OpenSearchDescription';\r
-\r
- my $ns = $element->getNamespace->value;\r
- my $version;\r
- if( $ns eq 'http://a9.com/-/spec/opensearch/1.1/' ) {\r
- $self->ns( $ns );\r
- $version = '1.1';\r
- }\r
- else {\r
- $version = '1.0';\r
- }\r
- $self->version( $version );\r
-\r
- for my $column ( @columns ) {\r
- my $node = $doc->documentElement->getChildrenByTagName( $column ) or next;\r
- if( $column eq 'Url' ) {\r
- if( $version eq '1.0' ) {\r
- $self->Url( [ WWW::OpenSearch::Url->new( template => $node->string_value, type => 'application/rss+xml' ) ] );\r
- next;\r
- }\r
-\r
- my @url;\r
- for my $urlnode ( $node->get_nodelist ) {\r
- my $type = $urlnode->getAttributeNode( 'type' )->value;\r
- my $url = $urlnode->getAttributeNode( 'template' )->value;\r
- $url =~ s/\?}/}/g; # optional\r
- my $method = $urlnode->getAttributeNode( 'method' );\r
- $method = $method->value if $method;\r
-
- my %params;\r
- for( $urlnode->getChildrenByTagName( 'Param' ) ) {\r
- my $param = $_->getAttributeNode( 'name' )->value;\r
+Return all of the urls associated with this description in an array.
+
+=head2 get_best_url( )
+
+Attempts to retrieve the best URL associated with this description, based
+on the following content types (from most preferred to least preferred):
+
+=over 4
+
+=item * application/atom+xml
+
+=item * application/rss+xml
+
+=item * text/xml
+
+=back
+
+=head2 get_url_by_type( $type )
+
+Retrieves the first WWW::OpenSearch::URL associated with this description
+whose type is equal to $type.
+
+=head1 ACCESSORS
+
+=head2 version( )
+
+=head2 ns( )
+
+=head2 AdultContent( )
+
+=head2 Contact( )
+
+=head2 Description( )
+
+=head2 Developer( )
+
+=head2 Format( )
+
+=head2 Image( )
+
+=head2 LongName( )
+
+=head2 Query( )
+
+=head2 SampleSearch( )
+
+=head2 ShortName( )
+
+=head2 SyndicationRight( )
+
+=head2 Tags( )
+
+=head2 Url( )
+
+=head1 AUTHOR
+
+=over 4
+
+=item * Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
+
+=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2007 by Tatsuhiko Miyagawa and Brian Cassidy
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+for( @columns ) {
+ no strict 'refs';
+ my $col = lc;
+ *$_ = \&$col;
+}
+
+sub new {
+ my $class = shift;
+ my $xml = shift;
+
+ my $self = $class->SUPER::new;
+
+ eval{ $self->load( $xml ); } if $xml;
+ if( $@ ) {
+ croak "Error while parsing Description XML: $@";
+ }
+
+ return $self;
+}
+
+sub load {
+ my $self = shift;
+ my $xml = shift;
+
+ my $parser = XML::LibXML->new;
+ my $doc = $parser->parse_string( $xml );
+ my $element = $doc->documentElement;
+ my $nodename = $element->nodeName;
+
+ croak "Node should be OpenSearchDescription: $nodename" if $nodename ne 'OpenSearchDescription';
+
+ my $ns = $element->getNamespace->value;
+ my $version;
+ if( $ns eq 'http://a9.com/-/spec/opensearchdescription/1.0/' ) {
+ $self->ns( 'http://a9.com/-/spec/opensearchrss/1.0/' );
+ $version = '1.0';
+ }
+ else {
+ $self->ns( $ns );
+ ( $version ) = $ns =~ m{([^/]+)/?$};
+ }
+ $self->version( $version );
+
+ for my $column ( @columns ) {
+ my $node = $doc->documentElement->getChildrenByTagName( $column ) or next;
+ if( $column eq 'Url' ) {
+ if( $version eq '1.0' ) {
+ $self->Url( [ WWW::OpenSearch::Url->new( template => $node->string_value, type => 'application/rss+xml', ns => $self->ns ) ] );
+ next;
+ }
+
+ my @url;
+ for my $urlnode ( $node->get_nodelist ) {
+ my $type = $urlnode->getAttributeNode( 'type' )->value;
+ my $url = $urlnode->getAttributeNode( 'template' )->value;
+ $url =~ s/\?}/}/g; # optional
+ my $method = $urlnode->getAttributeNode( 'method' );
+ $method = $method->value if $method;
+
+ my %params;
+ for( $urlnode->getChildrenByTagName( 'Param' ) ) {
+ my $param = $_->getAttributeNode( 'name' )->value;