final public function parse(StreamInterface $stream)
    {
        $parser = xml_parser_create_ns($this->options['encoding'], $this->options['separator']);

        if (false === $this->options['case_folding']) {
            xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
        }

        if (null === $this->options['skip_tagstart']) {
            xml_parser_set_option($parser, XML_OPTION_SKIP_TAGSTART, $this->options['skip_tagstart']);
        }

        if (null === $this->options['skip_white']) {
            xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $this->options['skip_white']);
        }

        $this->onDocumentStart($parser, $stream);

        $this->attachHandlers($parser);

        $this->process($parser, $stream);

        $this->onDocumentEnd($parser, $stream);

        xml_parser_free($parser);

        $stream->close();

        return $this->getResult();
    }
final public function parse(StreamInterface $stream)
    {
        $parser = xml_parser_create_ns($this->options['encoding'], $this->options['separator']);

        if (false === $this->options['case_folding']) {
            xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
        }

        if (null === $this->options['skip_tagstart']) {
            xml_parser_set_option($parser, XML_OPTION_SKIP_TAGSTART, $this->options['skip_tagstart']);
        }

        if (null === $this->options['skip_white']) {
            xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $this->options['skip_white']);
        }

        $this->onDocumentStart($parser, $stream);

        $this->attachHandlers($parser);

        $this->process($parser, $stream);

        $this->onDocumentEnd($parser, $stream);

        xml_parser_free($parser);

        $stream->close();

        return $this->getResult();
    }
{@inheritdoc}