2 use NCIP::Configuration;
10 our $VERSION = '0.01';
11 our $nsURI = 'http://www.niso.org/2008/ncip';
20 my $nicp = NCIP->new($config_dir);
28 my $class = ref $proto || $proto;
29 my $config_dir = shift;
31 my $config = NCIP::Configuration->new($config_dir);
32 $self->{config} = $config;
33 return bless $self, $class;
37 =head2 process_request()
39 my $response = $ncip->process_request($xml);
47 my $request_type = $self->handle_initiation($xml);
48 unless ($request_type) {
50 # We have invalid xml, or we can't figure out what kind of request this is
57 #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>";
61 my $handler = NCIP::Handler->new($request_type);
62 return $handler->handle($xml);
65 =head2 handle_initiation
69 sub handle_initiation {
74 $dom = XML::LibXML->load_xml( string => $xml );
77 warn "Invalid xml, caught error: $_";
81 # should check validity with validate at this point
82 # if ( $self->validate($dom) ) {
83 my $request_type = $self->parse_request($dom);
85 # do whatever we should do to initiate, then hand back request_type
92 # warn "Not valid xml";
93 # not valid throw error
105 # this should perhaps be in it's own module
108 my $validity = $dom->is_valid();
110 # we could validate against the dtd here, might be good?
111 # my $dtd = XML::LibXML::Dtd->parse_string($dtd_str);
112 # my $validity = $dom->is_valid($dtd);
113 # perhaps we could check the ncip version and validate that too
120 my $nodes = $dom->getElementsByTagNameNS( $nsURI, 'NCIPMessage' );
122 my @childnodes = $nodes->[0]->childNodes();
123 if ( $childnodes[1] ) {
124 return $childnodes[1]->localname();