2 use NCIP::Configuration;
7 use base qw(Class::Accessor);
10 our $nsURI = 'http://www.niso.org/2008/ncip';
19 my $nicp = NCIP->new($config_dir);
27 my $class = ref $proto || $proto;
28 my $config_dir = shift;
30 my $config = NCIP::Configuration->new($config_dir);
31 $self->{config} = $config;
32 return bless $self, $class;
36 =head2 process_request()
38 my $response = $ncip->process_request($xml);
46 my $request_type = $self->handle_initiation($xml);
47 unless ($request_type) {
49 # We have invalid xml, or we can't figure out what kind of request this is
53 #my $response = "<HTML> <HEAD> <TITLE>Hello There</TITLE> </HEAD> <BODY> <H1>Hello You Big JERK!</H1> Who would take this book seriously if the first eaxample didn't say \"hello world\"? </BODY> </HTML>";
59 =head2 handle_initiation
63 sub handle_initiation {
68 $dom = XML::LibXML->load_xml( string => $xml );
71 warn "Invalid xml, caught error: $_";
75 # should check validity with validate at this point
76 my $request_type = $self->parse_request($dom);
86 # this should perhaps be in it's own module
89 my $validity = $dom->is_valid();
91 # we could validate against the dtd here, might be good?
92 # my $dtd = XML::LibXML::Dtd->parse_string($dtd_str);
93 # my $validity = $dom->is_valid($dtd);
94 # perhaps we could check the ncip version and validate that too
101 my $nodes = $dom->getElementsByTagNameNS($nsURI,'NCIPMessage');
103 my @childnodes = $nodes->[0]->childNodes();
105 return $childnodes[1]->localname();