+=head2 C<protocol_version>
+
+The version of the protocol that the current stream is conforming to.
+It is reset before and after the parsing phase, so it's effectively only available from inside C<parse>.
+
+=cut
+
+eval "sub $_ { \@_ <= 1 ? \$_[0]->{$_} : (\$_[0]->{$_} = \$_[1]) }"
+ for qw<_session protocol_version>;
+
+# We must store the session in ourselves because it's only possible to pass
+# arguments to XML::Twig objects by a global stash.
+
+sub start {
+ my ($self, $sess) = @_;
+
+ $self->SUPER::start($sess);
+ $self->_session($sess);
+
+ return;
+}
+
+sub parse {
+ my ($self, $sess, $fh) = @_;
+
+ $self->protocol_version(undef);
+
+ $self->XML::Twig::parse($fh);
+ $self->purge;
+
+ $self->protocol_version(undef);
+
+ return 0;
+}
+
+sub finish {
+ my ($self, $sess) = @_;
+
+ $self->_session(undef);
+ $self->SUPER::finish($sess);
+
+ return;
+}
+
+sub handle_version {
+ my ($twig, $node) = @_;
+
+ $twig->protocol_version($node->text);
+
+ $twig->purge;
+}
+