| 1 | package UDDI::HalfDecent::Record; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | UDDI::HalfDecent::Record - a business/service/etc. record from a UDDI registry | ||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | $business = new UDDI::HalfDecent::Record($rs, $node, 'business'); | ||
| 13 | $name = $business->xpath("name"); | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | Represents a business, service, or other object, as described by a | ||
| 18 | UDDI node and returned in response to a C<find_business()>, | ||
| 19 | C<find_service> or similar request. | ||
| 20 | |||
| 21 | =head1 METHODS | ||
| 22 | |||
| 23 | =head2 new() | ||
| 24 | |||
| 25 | $record = new UDDI::HalfDecent::Record($rs, $node, $type); | ||
| 26 | |||
| 27 | Creates and returns a new UDDI object representing a business, service | ||
| 28 | or other. Note that B<client code need never call this>: it is | ||
| 29 | invoked by the UDDI library itself, in methods such as | ||
| 30 | C<UDDI::HalfDecent::ResultSet::record()>. | ||
| 31 | |||
| 32 | This constructor takes three arguments: C<$rs> is the result-set | ||
| 33 | object for which it is created, and which will be used for logging, | ||
| 34 | etc; C<$node> is the context node of the element in the UDDI XML | ||
| 35 | response describing this object; and C<$type> is the type of object | ||
| 36 | described (C<business>, C<service>, etc. | ||
| 37 | |||
| 38 | =cut | ||
| 39 | |||
| 40 | sub new { | ||
| 41 | my $class = shift(); | ||
| 42 | my($rs, $node, $type) = @_; | ||
| 43 | |||
| 44 | my $this = bless { | ||
| 45 | rs => $rs, | ||
| 46 | node => $node, | ||
| 47 | type => $type, | ||
| 48 | }, $class; | ||
| 49 | |||
| 50 | return $this; | ||
| 51 | } | ||
| 52 | |||
| 53 | |||
| 54 | =head2 xpath() | ||
| 55 | |||
| 56 | $name = $record->xpath("name"); | ||
| 57 | $description = $record->xpath("uddi:description"); | ||
| 58 | |||
| 59 | Returns the value corresponding to the specified XPath within the | ||
| 60 | business. The specified XPaths may include the following predefined | ||
| 61 | namespace prefixes: | ||
| 62 | |||
| 63 | =over 4 | ||
| 64 | |||
| 65 | =item xsd | ||
| 66 | |||
| 67 | C<http://www.w3.org/2001/XMLSchema> | ||
| 68 | |||
| 69 | =item xsi | ||
| 70 | |||
| 71 | C<http://www.w3.org/2001/XMLSchema-instance> | ||
| 72 | |||
| 73 | =item enc | ||
| 74 | |||
| 75 | C<http://schemas.xmlsoap.org/soap/encoding/> | ||
| 76 | |||
| 77 | =item env | ||
| 78 | |||
| 79 | C<http://schemas.xmlsoap.org/soap/envelope/> | ||
| 80 | |||
| 81 | =item uddi | ||
| 82 | |||
| 83 | The name space for whatever UDDI version is in effect. | ||
| 84 | |||
| 85 | =back | ||
| 86 | |||
| 87 | To simplify application code, the UDDI namespace is assumed if none is | ||
| 88 | specified. | ||
| 89 | |||
| 90 | =cut | ||
| 91 | |||
| 92 | sub xpath { | ||
| 93 | my $this = shift(); | ||
| 94 | my($xpath) = @_; | ||
| 95 | |||
| 96 | my $val = $this->{rs}->{xpc}->findvalue("$xpath", $this->{node}); | ||
| 97 | return $val if defined $val && $val ne ""; | ||
| 98 | return $val if $xpath =~ /^@/; | ||
| 99 | $val = $this->{rs}->{xpc}->findvalue("uddi:$xpath", $this->{node}); | ||
| 100 | return $val; | ||
| 101 | } | ||
| 102 | |||
| 103 | |||
| 104 | =head2 as_xml() | ||
| 105 | |||
| 106 | print $rec->as_xml(); | ||
| 107 | |||
| 108 | Returns an XML representation of the whole record. | ||
| 109 | |||
| 110 | =cut | ||
| 111 | |||
| 112 | sub as_xml { | ||
| 113 | my $this = shift(); | ||
| 114 | return $this->{node}->toString(); | ||
| 115 | } | ||
| 116 | |||
| 117 | |||
| 118 | =head1 SEE ALSO | ||
| 119 | |||
| 120 | C<UDDI::HalfDecent> | ||
| 121 | is the module that uses this. See also its SEE ALSOs. | ||
| 122 | |||
| 123 | =head1 AUTHOR, COPYRIGHT AND LICENSE | ||
| 124 | |||
| 125 | As for C<Net::Z3950::UDDI>. | ||
| 126 | |||
| 127 | =cut | ||
| 128 | |||
| 129 | 1; |