| Filename | /usr/share/perl5/XML/NamespaceSupport.pm |
| Statements | Executed 7682068 statements in 17.0s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 479680 | 2 | 1 | 8.30s | 8.30s | XML::NamespaceSupport::_get_ns_details |
| 294381 | 1 | 1 | 3.16s | 8.28s | XML::NamespaceSupport::process_attribute_name |
| 185299 | 1 | 1 | 1.97s | 5.14s | XML::NamespaceSupport::process_element_name |
| 185299 | 1 | 1 | 1.59s | 1.59s | XML::NamespaceSupport::push_context |
| 185299 | 1 | 1 | 1.12s | 1.12s | XML::NamespaceSupport::pop_context |
| 5000 | 1 | 1 | 103ms | 103ms | XML::NamespaceSupport::new |
| 1 | 1 | 1 | 21µs | 27µs | XML::NamespaceSupport::BEGIN@8 |
| 1 | 1 | 1 | 19µs | 43µs | XML::NamespaceSupport::BEGIN@110 |
| 1 | 1 | 1 | 19µs | 83µs | XML::NamespaceSupport::BEGIN@12 |
| 1 | 1 | 1 | 18µs | 45µs | XML::NamespaceSupport::BEGIN@99 |
| 1 | 1 | 1 | 18µs | 115µs | XML::NamespaceSupport::BEGIN@18 |
| 1 | 1 | 1 | 17µs | 82µs | XML::NamespaceSupport::BEGIN@13 |
| 1 | 1 | 1 | 15µs | 97µs | XML::NamespaceSupport::BEGIN@9 |
| 1 | 1 | 1 | 14µs | 75µs | XML::NamespaceSupport::BEGIN@16 |
| 1 | 1 | 1 | 14µs | 77µs | XML::NamespaceSupport::BEGIN@15 |
| 1 | 1 | 1 | 13µs | 85µs | XML::NamespaceSupport::BEGIN@11 |
| 1 | 1 | 1 | 13µs | 80µs | XML::NamespaceSupport::BEGIN@14 |
| 1 | 1 | 1 | 12µs | 84µs | XML::NamespaceSupport::BEGIN@10 |
| 0 | 0 | 0 | 0s | 0s | XML::NamespaceSupport::declare_prefix |
| 0 | 0 | 0 | 0s | 0s | XML::NamespaceSupport::declare_prefixes |
| 0 | 0 | 0 | 0s | 0s | XML::NamespaceSupport::get_declared_prefixes |
| 0 | 0 | 0 | 0s | 0s | XML::NamespaceSupport::get_prefix |
| 0 | 0 | 0 | 0s | 0s | XML::NamespaceSupport::get_prefixes |
| 0 | 0 | 0 | 0s | 0s | XML::NamespaceSupport::get_uri |
| 0 | 0 | 0 | 0s | 0s | XML::NamespaceSupport::parse_jclark_notation |
| 0 | 0 | 0 | 0s | 0s | XML::NamespaceSupport::process_name |
| 0 | 0 | 0 | 0s | 0s | XML::NamespaceSupport::reset |
| 0 | 0 | 0 | 0s | 0s | XML::NamespaceSupport::undeclare_prefix |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | ### | ||||
| 3 | # XML::NamespaceSupport - a simple generic namespace processor | ||||
| 4 | # Robin Berjon <robin@knowscape.com> | ||||
| 5 | ### | ||||
| 6 | |||||
| 7 | package XML::NamespaceSupport; | ||||
| 8 | 3 | 41µs | 2 | 33µs | # spent 27µs (21+6) within XML::NamespaceSupport::BEGIN@8 which was called:
# once (21µs+6µs) by XML::SAX::Expat::BEGIN@10 at line 8 # spent 27µs making 1 call to XML::NamespaceSupport::BEGIN@8
# spent 6µs making 1 call to strict::import |
| 9 | 3 | 44µs | 2 | 179µs | # spent 97µs (15+82) within XML::NamespaceSupport::BEGIN@9 which was called:
# once (15µs+82µs) by XML::SAX::Expat::BEGIN@10 at line 9 # spent 97µs making 1 call to XML::NamespaceSupport::BEGIN@9
# spent 82µs making 1 call to constant::import |
| 10 | 3 | 40µs | 2 | 156µs | # spent 84µs (12+72) within XML::NamespaceSupport::BEGIN@10 which was called:
# once (12µs+72µs) by XML::SAX::Expat::BEGIN@10 at line 10 # spent 84µs making 1 call to XML::NamespaceSupport::BEGIN@10
# spent 72µs making 1 call to constant::import |
| 11 | 3 | 47µs | 2 | 157µs | # spent 85µs (13+72) within XML::NamespaceSupport::BEGIN@11 which was called:
# once (13µs+72µs) by XML::SAX::Expat::BEGIN@10 at line 11 # spent 85µs making 1 call to XML::NamespaceSupport::BEGIN@11
# spent 72µs making 1 call to constant::import |
| 12 | 3 | 39µs | 2 | 147µs | # spent 83µs (19+64) within XML::NamespaceSupport::BEGIN@12 which was called:
# once (19µs+64µs) by XML::SAX::Expat::BEGIN@10 at line 12 # spent 83µs making 1 call to XML::NamespaceSupport::BEGIN@12
# spent 64µs making 1 call to constant::import |
| 13 | 3 | 42µs | 2 | 147µs | # spent 82µs (17+65) within XML::NamespaceSupport::BEGIN@13 which was called:
# once (17µs+65µs) by XML::SAX::Expat::BEGIN@10 at line 13 # spent 82µs making 1 call to XML::NamespaceSupport::BEGIN@13
# spent 65µs making 1 call to constant::import |
| 14 | 3 | 40µs | 2 | 147µs | # spent 80µs (13+67) within XML::NamespaceSupport::BEGIN@14 which was called:
# once (13µs+67µs) by XML::SAX::Expat::BEGIN@10 at line 14 # spent 80µs making 1 call to XML::NamespaceSupport::BEGIN@14
# spent 67µs making 1 call to constant::import |
| 15 | 3 | 42µs | 2 | 140µs | # spent 77µs (14+63) within XML::NamespaceSupport::BEGIN@15 which was called:
# once (14µs+63µs) by XML::SAX::Expat::BEGIN@10 at line 15 # spent 77µs making 1 call to XML::NamespaceSupport::BEGIN@15
# spent 63µs making 1 call to constant::import |
| 16 | 3 | 43µs | 2 | 136µs | # spent 75µs (14+61) within XML::NamespaceSupport::BEGIN@16 which was called:
# once (14µs+61µs) by XML::SAX::Expat::BEGIN@10 at line 16 # spent 75µs making 1 call to XML::NamespaceSupport::BEGIN@16
# spent 61µs making 1 call to constant::import |
| 17 | |||||
| 18 | 3 | 462µs | 2 | 212µs | # spent 115µs (18+97) within XML::NamespaceSupport::BEGIN@18 which was called:
# once (18µs+97µs) by XML::SAX::Expat::BEGIN@10 at line 18 # spent 115µs making 1 call to XML::NamespaceSupport::BEGIN@18
# spent 97µs making 1 call to vars::import |
| 19 | 1 | 2µs | $VERSION = '1.09'; | ||
| 20 | 1 | 1µs | $NS_XMLNS = 'http://www.w3.org/2000/xmlns/'; | ||
| 21 | 1 | 1µs | $NS_XML = 'http://www.w3.org/XML/1998/namespace'; | ||
| 22 | |||||
| 23 | |||||
| 24 | # add the ns stuff that baud wants based on Java's xml-writer | ||||
| 25 | |||||
| 26 | |||||
| 27 | #-------------------------------------------------------------------# | ||||
| 28 | # constructor | ||||
| 29 | #-------------------------------------------------------------------# | ||||
| 30 | # spent 103ms within XML::NamespaceSupport::new which was called 5000 times, avg 21µs/call:
# 5000 times (103ms+0s) by XML::SAX::Expat::_create_parser at line 123 of XML/SAX/Expat.pm, avg 21µs/call | ||||
| 31 | 5000 | 9.55ms | my $class = ref($_[0]) ? ref(shift) : shift; | ||
| 32 | 5000 | 5.84ms | my $options = shift; | ||
| 33 | 5000 | 26.1ms | my $self = [ | ||
| 34 | 1, # FATALS | ||||
| 35 | [[ # NSMAP | ||||
| 36 | undef, # DEFAULT | ||||
| 37 | { xml => $NS_XML }, # PREFIX_MAP | ||||
| 38 | undef, # DECLARATIONS | ||||
| 39 | ]], | ||||
| 40 | 'aaa', # UNKNOWN_PREF | ||||
| 41 | 0, # AUTO_PREFIX | ||||
| 42 | 1, # XML_11 | ||||
| 43 | ]; | ||||
| 44 | 5000 | 14.4ms | $self->[NSMAP]->[0]->[PREFIX_MAP]->{xmlns} = $NS_XMLNS if $options->{xmlns}; | ||
| 45 | 5000 | 7.61ms | $self->[FATALS] = $options->{fatal_errors} if defined $options->{fatal_errors}; | ||
| 46 | 5000 | 6.67ms | $self->[AUTO_PREFIX] = $options->{auto_prefix} if defined $options->{auto_prefix}; | ||
| 47 | 5000 | 6.27ms | $self->[XMLNS_11] = $options->{xmlns_11} if defined $options->{xmlns_11}; | ||
| 48 | 5000 | 31.9ms | return bless $self, $class; | ||
| 49 | } | ||||
| 50 | #-------------------------------------------------------------------# | ||||
| 51 | |||||
| 52 | #-------------------------------------------------------------------# | ||||
| 53 | # reset() - return to the original state (for reuse) | ||||
| 54 | #-------------------------------------------------------------------# | ||||
| 55 | sub reset { | ||||
| 56 | my $self = shift; | ||||
| 57 | $#{$self->[NSMAP]} = 0; | ||||
| 58 | } | ||||
| 59 | #-------------------------------------------------------------------# | ||||
| 60 | |||||
| 61 | #-------------------------------------------------------------------# | ||||
| 62 | # push_context() - add a new empty context to the stack | ||||
| 63 | #-------------------------------------------------------------------# | ||||
| 64 | # spent 1.59s within XML::NamespaceSupport::push_context which was called 185299 times, avg 9µs/call:
# 185299 times (1.59s+0s) by XML::SAX::Expat::_handle_start at line 184 of XML/SAX/Expat.pm, avg 9µs/call | ||||
| 65 | 185299 | 206ms | my $self = shift; | ||
| 66 | push @{$self->[NSMAP]}, [ | ||||
| 67 | $self->[NSMAP]->[-1]->[DEFAULT], | ||||
| 68 | 185299 | 1.69s | { %{$self->[NSMAP]->[-1]->[PREFIX_MAP]} }, | ||
| 69 | [], | ||||
| 70 | ]; | ||||
| 71 | } | ||||
| 72 | #-------------------------------------------------------------------# | ||||
| 73 | |||||
| 74 | #-------------------------------------------------------------------# | ||||
| 75 | # pop_context() - remove the topmost context fromt the stack | ||||
| 76 | #-------------------------------------------------------------------# | ||||
| 77 | # spent 1.12s within XML::NamespaceSupport::pop_context which was called 185299 times, avg 6µs/call:
# 185299 times (1.12s+0s) by XML::SAX::Expat::_handle_end at line 243 of XML/SAX/Expat.pm, avg 6µs/call | ||||
| 78 | 185299 | 213ms | my $self = shift; | ||
| 79 | 185299 | 253ms | die 'Trying to pop context without push context' unless @{$self->[NSMAP]} > 1; | ||
| 80 | 185299 | 843ms | pop @{$self->[NSMAP]}; | ||
| 81 | } | ||||
| 82 | #-------------------------------------------------------------------# | ||||
| 83 | |||||
| 84 | #-------------------------------------------------------------------# | ||||
| 85 | # declare_prefix() - declare a prefix in the current scope | ||||
| 86 | #-------------------------------------------------------------------# | ||||
| 87 | sub declare_prefix { | ||||
| 88 | my $self = shift; | ||||
| 89 | my $prefix = shift; | ||||
| 90 | my $value = shift; | ||||
| 91 | |||||
| 92 | warn <<' EOWARN' unless defined $prefix or $self->[AUTO_PREFIX]; | ||||
| 93 | Prefix was undefined. | ||||
| 94 | If you wish to set the default namespace, use the empty string ''. | ||||
| 95 | If you wish to autogenerate prefixes, set the auto_prefix option | ||||
| 96 | to a true value. | ||||
| 97 | EOWARN | ||||
| 98 | |||||
| 99 | 3 | 139µs | 2 | 72µs | # spent 45µs (18+27) within XML::NamespaceSupport::BEGIN@99 which was called:
# once (18µs+27µs) by XML::SAX::Expat::BEGIN@10 at line 99 # spent 45µs making 1 call to XML::NamespaceSupport::BEGIN@99
# spent 27µs making 1 call to warnings::unimport |
| 100 | if ($prefix eq 'xml' and $value ne $NS_XML) { | ||||
| 101 | die "The xml prefix can only be bound to the $NS_XML namespace." | ||||
| 102 | } | ||||
| 103 | elsif ($value eq $NS_XML and $prefix ne 'xml') { | ||||
| 104 | die "the $NS_XML namespace can only be bound to the xml prefix."; | ||||
| 105 | } | ||||
| 106 | elsif ($value eq $NS_XML and $prefix eq 'xml') { | ||||
| 107 | return 1; | ||||
| 108 | } | ||||
| 109 | return 0 if index(lc($prefix), 'xml') == 0; | ||||
| 110 | 3 | 1.55ms | 2 | 67µs | # spent 43µs (19+24) within XML::NamespaceSupport::BEGIN@110 which was called:
# once (19µs+24µs) by XML::SAX::Expat::BEGIN@10 at line 110 # spent 43µs making 1 call to XML::NamespaceSupport::BEGIN@110
# spent 24µs making 1 call to warnings::import |
| 111 | |||||
| 112 | if (defined $prefix and $prefix eq '') { | ||||
| 113 | $self->[NSMAP]->[-1]->[DEFAULT] = $value; | ||||
| 114 | } | ||||
| 115 | else { | ||||
| 116 | die "Cannot undeclare prefix $prefix" if $value eq '' and not $self->[XMLNS_11]; | ||||
| 117 | if (not defined $prefix and $self->[AUTO_PREFIX]) { | ||||
| 118 | while (1) { | ||||
| 119 | $prefix = $self->[UNKNOWN_PREF]++; | ||||
| 120 | last if not exists $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix}; | ||||
| 121 | } | ||||
| 122 | } | ||||
| 123 | elsif (not defined $prefix and not $self->[AUTO_PREFIX]) { | ||||
| 124 | return 0; | ||||
| 125 | } | ||||
| 126 | $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix} = $value; | ||||
| 127 | } | ||||
| 128 | push @{$self->[NSMAP]->[-1]->[DECLARATIONS]}, $prefix; | ||||
| 129 | return 1; | ||||
| 130 | } | ||||
| 131 | #-------------------------------------------------------------------# | ||||
| 132 | |||||
| 133 | #-------------------------------------------------------------------# | ||||
| 134 | # declare_prefixes() - declare several prefixes in the current scope | ||||
| 135 | #-------------------------------------------------------------------# | ||||
| 136 | sub declare_prefixes { | ||||
| 137 | my $self = shift; | ||||
| 138 | my %prefixes = @_; | ||||
| 139 | while (my ($k,$v) = each %prefixes) { | ||||
| 140 | $self->declare_prefix($k,$v); | ||||
| 141 | } | ||||
| 142 | } | ||||
| 143 | #-------------------------------------------------------------------# | ||||
| 144 | |||||
| 145 | #-------------------------------------------------------------------# | ||||
| 146 | # undeclare_prefix | ||||
| 147 | #-------------------------------------------------------------------# | ||||
| 148 | sub undeclare_prefix { | ||||
| 149 | my $self = shift; | ||||
| 150 | my $prefix = shift; | ||||
| 151 | return unless not defined $prefix or $prefix eq ''; | ||||
| 152 | return unless exists $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix}; | ||||
| 153 | |||||
| 154 | my ( $tfix ) = grep { $_ eq $prefix } @{$self->[NSMAP]->[-1]->[DECLARATIONS]}; | ||||
| 155 | if ( not defined $tfix ) { | ||||
| 156 | die "prefix $prefix not declared in this context\n"; | ||||
| 157 | } | ||||
| 158 | |||||
| 159 | @{$self->[NSMAP]->[-1]->[DECLARATIONS]} = grep { $_ ne $prefix } @{$self->[NSMAP]->[-1]->[DECLARATIONS]}; | ||||
| 160 | delete $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix}; | ||||
| 161 | } | ||||
| 162 | #-------------------------------------------------------------------# | ||||
| 163 | |||||
| 164 | #-------------------------------------------------------------------# | ||||
| 165 | # get_prefix() - get a (random) prefix for a given URI | ||||
| 166 | #-------------------------------------------------------------------# | ||||
| 167 | sub get_prefix { | ||||
| 168 | my $self = shift; | ||||
| 169 | my $uri = shift; | ||||
| 170 | |||||
| 171 | # we have to iterate over the whole hash here because if we don't | ||||
| 172 | # the iterator isn't reset and the next pass will fail | ||||
| 173 | my $pref; | ||||
| 174 | while (my ($k, $v) = each %{$self->[NSMAP]->[-1]->[PREFIX_MAP]}) { | ||||
| 175 | $pref = $k if $v eq $uri; | ||||
| 176 | } | ||||
| 177 | return $pref; | ||||
| 178 | } | ||||
| 179 | #-------------------------------------------------------------------# | ||||
| 180 | |||||
| 181 | #-------------------------------------------------------------------# | ||||
| 182 | # get_prefixes() - get all the prefixes for a given URI | ||||
| 183 | #-------------------------------------------------------------------# | ||||
| 184 | sub get_prefixes { | ||||
| 185 | my $self = shift; | ||||
| 186 | my $uri = shift; | ||||
| 187 | |||||
| 188 | return keys %{$self->[NSMAP]->[-1]->[PREFIX_MAP]} unless defined $uri; | ||||
| 189 | return grep { $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$_} eq $uri } keys %{$self->[NSMAP]->[-1]->[PREFIX_MAP]}; | ||||
| 190 | } | ||||
| 191 | #-------------------------------------------------------------------# | ||||
| 192 | |||||
| 193 | #-------------------------------------------------------------------# | ||||
| 194 | # get_declared_prefixes() - get all prefixes declared in the last context | ||||
| 195 | #-------------------------------------------------------------------# | ||||
| 196 | sub get_declared_prefixes { | ||||
| 197 | return @{$_[0]->[NSMAP]->[-1]->[DECLARATIONS]}; | ||||
| 198 | } | ||||
| 199 | #-------------------------------------------------------------------# | ||||
| 200 | |||||
| 201 | #-------------------------------------------------------------------# | ||||
| 202 | # get_uri() - get an URI given a prefix | ||||
| 203 | #-------------------------------------------------------------------# | ||||
| 204 | sub get_uri { | ||||
| 205 | my $self = shift; | ||||
| 206 | my $prefix = shift; | ||||
| 207 | |||||
| 208 | warn "Prefix must not be undef in get_uri(). The emtpy prefix must be ''" unless defined $prefix; | ||||
| 209 | |||||
| 210 | return $self->[NSMAP]->[-1]->[DEFAULT] if $prefix eq ''; | ||||
| 211 | return $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix} if exists $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix}; | ||||
| 212 | return undef; | ||||
| 213 | } | ||||
| 214 | #-------------------------------------------------------------------# | ||||
| 215 | |||||
| 216 | #-------------------------------------------------------------------# | ||||
| 217 | # process_name() - provide details on a name | ||||
| 218 | #-------------------------------------------------------------------# | ||||
| 219 | sub process_name { | ||||
| 220 | my $self = shift; | ||||
| 221 | my $qname = shift; | ||||
| 222 | my $aflag = shift; | ||||
| 223 | |||||
| 224 | if ($self->[FATALS]) { | ||||
| 225 | return( ($self->_get_ns_details($qname, $aflag))[0,2], $qname ); | ||||
| 226 | } | ||||
| 227 | else { | ||||
| 228 | eval { return( ($self->_get_ns_details($qname, $aflag))[0,2], $qname ); } | ||||
| 229 | } | ||||
| 230 | } | ||||
| 231 | #-------------------------------------------------------------------# | ||||
| 232 | |||||
| 233 | #-------------------------------------------------------------------# | ||||
| 234 | # process_element_name() - provide details on a element's name | ||||
| 235 | #-------------------------------------------------------------------# | ||||
| 236 | # spent 5.14s (1.97+3.18) within XML::NamespaceSupport::process_element_name which was called 185299 times, avg 28µs/call:
# 185299 times (1.97s+3.18s) by XML::SAX::Expat::_handle_start at line 215 of XML/SAX/Expat.pm, avg 28µs/call | ||||
| 237 | 185299 | 212ms | my $self = shift; | ||
| 238 | 185299 | 213ms | my $qname = shift; | ||
| 239 | |||||
| 240 | 185299 | 1.33s | 185299 | 3.18s | if ($self->[FATALS]) { # spent 3.18s making 185299 calls to XML::NamespaceSupport::_get_ns_details, avg 17µs/call |
| 241 | return $self->_get_ns_details($qname, 0); | ||||
| 242 | } | ||||
| 243 | else { | ||||
| 244 | eval { return $self->_get_ns_details($qname, 0); } | ||||
| 245 | } | ||||
| 246 | } | ||||
| 247 | #-------------------------------------------------------------------# | ||||
| 248 | |||||
| 249 | |||||
| 250 | #-------------------------------------------------------------------# | ||||
| 251 | # process_attribute_name() - provide details on a attribute's name | ||||
| 252 | #-------------------------------------------------------------------# | ||||
| 253 | # spent 8.28s (3.16+5.12) within XML::NamespaceSupport::process_attribute_name which was called 294381 times, avg 28µs/call:
# 294381 times (3.16s+5.12s) by XML::SAX::Expat::_handle_start at line 202 of XML/SAX/Expat.pm, avg 28µs/call | ||||
| 254 | 294381 | 340ms | my $self = shift; | ||
| 255 | 294381 | 328ms | my $qname = shift; | ||
| 256 | |||||
| 257 | 294381 | 2.13s | 294381 | 5.12s | if ($self->[FATALS]) { # spent 5.12s making 294381 calls to XML::NamespaceSupport::_get_ns_details, avg 17µs/call |
| 258 | return $self->_get_ns_details($qname, 1); | ||||
| 259 | } | ||||
| 260 | else { | ||||
| 261 | eval { return $self->_get_ns_details($qname, 1); } | ||||
| 262 | } | ||||
| 263 | } | ||||
| 264 | #-------------------------------------------------------------------# | ||||
| 265 | |||||
| 266 | |||||
| 267 | #-------------------------------------------------------------------# | ||||
| 268 | # ($ns, $prefix, $lname) = $self->_get_ns_details($qname, $f_attr) | ||||
| 269 | # returns ns, prefix, and lname for a given attribute name | ||||
| 270 | # >> the $f_attr flag, if set to one, will work for an attribute | ||||
| 271 | #-------------------------------------------------------------------# | ||||
| 272 | # spent 8.30s within XML::NamespaceSupport::_get_ns_details which was called 479680 times, avg 17µs/call:
# 294381 times (5.12s+0s) by XML::NamespaceSupport::process_attribute_name at line 257, avg 17µs/call
# 185299 times (3.18s+0s) by XML::NamespaceSupport::process_element_name at line 240, avg 17µs/call | ||||
| 273 | 479680 | 503ms | my $self = shift; | ||
| 274 | 479680 | 546ms | my $qname = shift; | ||
| 275 | 479680 | 488ms | my $aflag = shift; | ||
| 276 | |||||
| 277 | 479680 | 515ms | my ($ns, $prefix, $lname); | ||
| 278 | 479680 | 1.31s | (my ($tmp_prefix, $tmp_lname) = split /:/, $qname, 3) | ||
| 279 | < 3 or die "Invalid QName: $qname"; | ||||
| 280 | |||||
| 281 | # no prefix | ||||
| 282 | 479680 | 594ms | my $cur_map = $self->[NSMAP]->[-1]; | ||
| 283 | 479680 | 1.03s | if (not defined($tmp_lname)) { | ||
| 284 | 479680 | 466ms | $prefix = undef; | ||
| 285 | 479680 | 523ms | $lname = $qname; | ||
| 286 | # attr don't have a default namespace | ||||
| 287 | 479680 | 551ms | $ns = ($aflag) ? undef : $cur_map->[DEFAULT]; | ||
| 288 | } | ||||
| 289 | |||||
| 290 | # prefix | ||||
| 291 | else { | ||||
| 292 | if (exists $cur_map->[PREFIX_MAP]->{$tmp_prefix}) { | ||||
| 293 | $prefix = $tmp_prefix; | ||||
| 294 | $lname = $tmp_lname; | ||||
| 295 | $ns = $cur_map->[PREFIX_MAP]->{$prefix} | ||||
| 296 | } | ||||
| 297 | else { # no ns -> lname == name, all rest undef | ||||
| 298 | die "Undeclared prefix: $tmp_prefix"; | ||||
| 299 | } | ||||
| 300 | } | ||||
| 301 | |||||
| 302 | 479680 | 2.65s | return ($ns, $prefix, $lname); | ||
| 303 | } | ||||
| 304 | #-------------------------------------------------------------------# | ||||
| 305 | |||||
| 306 | #-------------------------------------------------------------------# | ||||
| 307 | # parse_jclark_notation() - parse the Clarkian notation | ||||
| 308 | #-------------------------------------------------------------------# | ||||
| 309 | sub parse_jclark_notation { | ||||
| 310 | shift; | ||||
| 311 | my $jc = shift; | ||||
| 312 | $jc =~ m/^\{(.*)\}([^}]+)$/; | ||||
| 313 | return $1, $2; | ||||
| 314 | } | ||||
| 315 | #-------------------------------------------------------------------# | ||||
| 316 | |||||
| 317 | |||||
| 318 | #-------------------------------------------------------------------# | ||||
| 319 | # Java names mapping | ||||
| 320 | #-------------------------------------------------------------------# | ||||
| 321 | 1 | 2µs | *XML::NamespaceSupport::pushContext = \&push_context; | ||
| 322 | 1 | 1µs | *XML::NamespaceSupport::popContext = \&pop_context; | ||
| 323 | 1 | 2µs | *XML::NamespaceSupport::declarePrefix = \&declare_prefix; | ||
| 324 | 1 | 1µs | *XML::NamespaceSupport::declarePrefixes = \&declare_prefixes; | ||
| 325 | 1 | 1µs | *XML::NamespaceSupport::getPrefix = \&get_prefix; | ||
| 326 | 1 | 1µs | *XML::NamespaceSupport::getPrefixes = \&get_prefixes; | ||
| 327 | 1 | 1µs | *XML::NamespaceSupport::getDeclaredPrefixes = \&get_declared_prefixes; | ||
| 328 | 1 | 2µs | *XML::NamespaceSupport::getURI = \&get_uri; | ||
| 329 | 1 | 1µs | *XML::NamespaceSupport::processName = \&process_name; | ||
| 330 | 1 | 1µs | *XML::NamespaceSupport::processElementName = \&process_element_name; | ||
| 331 | 1 | 2µs | *XML::NamespaceSupport::processAttributeName = \&process_attribute_name; | ||
| 332 | 1 | 1µs | *XML::NamespaceSupport::parseJClarkNotation = \&parse_jclark_notation; | ||
| 333 | 1 | 1µs | *XML::NamespaceSupport::undeclarePrefix = \&undeclare_prefix; | ||
| 334 | #-------------------------------------------------------------------# | ||||
| 335 | |||||
| 336 | |||||
| 337 | 1 | 18µs | 1; | ||
| 338 | #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,# | ||||
| 339 | #`,`, Documentation `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,# | ||||
| 340 | #```````````````````````````````````````````````````````````````````# | ||||
| 341 | |||||
| 342 | =pod | ||||
| 343 | |||||
| - - |