protected function parseView(ExpressViewRenderer $renderer, $data, $resource = '')
	{
		try
		{
			// This ugly pre-processing is neccessary due to DOM XML forgetting about self-closing elements.
			$reader = new XmlStreamReader();
			$reader->XML($data);
			
			$buffer = '<?xml version="1.0"?>' . "\n";
			
			while($reader->read())
			{
				switch($reader->nodeType)
				{
					case XmlStreamReader::ELEMENT:
						$buffer .= '<' . $reader->name;
						
						$namespaces = [];
						
						while($reader->moveToNextAttribute())
						{
							if($reader->namespaceURI == self::NS_XML)
							{
								switch($reader->localName)
								{
									case 'nsdec':
									case 'empty':
										continue 2;
								}
							}
							
							if($reader->namespaceURI == self::NS_XMLNS)
							{
								$namespaces[$reader->name] = $reader->value;
							}
						
							$buffer .= ' ' . $reader->name . '="' . htmlspecialchars($reader->value, ENT_COMPAT | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8') . '"';
						}
						
						$reader->moveToElement();
						
						if(!empty($namespaces))
						{
							$encoded = base64_encode(json_encode($namespaces, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
							$buffer .= ' xml:nsdec="' . htmlspecialchars($encoded, ENT_QUOTES | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8') . '"';
						}
						
						if($reader->isEmptyElement)
						{
							$buffer .= ' xml:empty="" />';
						}
						else
						{
							$buffer .= '>';
						}
						break;
					case XmlStreamReader::END_ELEMENT:
						$buffer .= '</' . $reader->name . '>';
						break;
					case XmlStreamReader::SIGNIFICANT_WHITESPACE:
					case XmlStreamReader::TEXT:
					case XmlStreamReader::WHITESPACE:
						$buffer .= htmlspecialchars($reader->value, ENT_QUOTES | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8');
						break;
				}
			}
			
			// Parse XML buffer into a DOM document.
			$builder = new XmlDocumentBuilder();
			$xml = $builder->buildFromSource($buffer);
	
			$compiler = new ExpressCompiler($renderer);
			$compiler->setResource($resource);
			
			$parser = new ExpressViewParser();
			
			$view = $parser->parseSource($xml);
			$view->compile($compiler);
			
			return $compiler;
		}
		catch(\Exception $e)
		{
			$ex = $e;
			
			do
			{
				if($ex instanceof ExpressViewException)
				{
					if($ex->getErrorFile() === NULL)
					{
						$ex->setErrorFile($resource);
					}
				}
			}
			while($ex = $ex->getPrevious());
			
			throw $e;
		}
	}
protected function parseView(ExpressViewRenderer $renderer, $data, $resource = '')
	{
		try
		{
			// This ugly pre-processing is neccessary due to DOM XML forgetting about self-closing elements.
			$reader = new XmlStreamReader();
			$reader->XML($data);
			
			$buffer = '<?xml version="1.0"?>' . "\n";
			
			while($reader->read())
			{
				switch($reader->nodeType)
				{
					case XmlStreamReader::ELEMENT:
						$buffer .= '<' . $reader->name;
						
						$namespaces = [];
						
						while($reader->moveToNextAttribute())
						{
							if($reader->namespaceURI == self::NS_XML)
							{
								switch($reader->localName)
								{
									case 'nsdec':
									case 'empty':
										continue 2;
								}
							}
							
							if($reader->namespaceURI == self::NS_XMLNS)
							{
								$namespaces[$reader->name] = $reader->value;
							}
						
							$buffer .= ' ' . $reader->name . '="' . htmlspecialchars($reader->value, ENT_COMPAT | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8') . '"';
						}
						
						$reader->moveToElement();
						
						if(!empty($namespaces))
						{
							$encoded = base64_encode(json_encode($namespaces, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
							$buffer .= ' xml:nsdec="' . htmlspecialchars($encoded, ENT_QUOTES | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8') . '"';
						}
						
						if($reader->isEmptyElement)
						{
							$buffer .= ' xml:empty="" />';
						}
						else
						{
							$buffer .= '>';
						}
						break;
					case XmlStreamReader::END_ELEMENT:
						$buffer .= '</' . $reader->name . '>';
						break;
					case XmlStreamReader::SIGNIFICANT_WHITESPACE:
					case XmlStreamReader::TEXT:
					case XmlStreamReader::WHITESPACE:
						$buffer .= htmlspecialchars($reader->value, ENT_QUOTES | ENT_XML1 | ENT_SUBSTITUTE, 'UTF-8');
						break;
				}
			}
			
			// Parse XML buffer into a DOM document.
			$builder = new XmlDocumentBuilder();
			$xml = $builder->buildFromSource($buffer);
	
			$compiler = new ExpressCompiler($renderer);
			$compiler->setResource($resource);
			
			$parser = new ExpressViewParser();
			
			$view = $parser->parseSource($xml);
			$view->compile($compiler);
			
			return $compiler;
		}
		catch(\Exception $e)
		{
			$ex = $e;
			
			do
			{
				if($ex instanceof ExpressViewException)
				{
					if($ex->getErrorFile() === NULL)
					{
						$ex->setErrorFile($resource);
					}
				}
			}
			while($ex = $ex->getPrevious());
			
			throw $e;
		}
	}
protected function parseView ( ExpressViewRenderer $ renderer , $ data , $ resource = '' ) { try { // This ugly pre-processing is neccessary due to DOM XML forgetting about self-closing elements. $ reader = new XmlStreamReader ( ) ; $ reader -> XML ( $ data ) ; $ buffer = '<?xml version="1.0"?>' . "\n" ; while ( $ reader -> read ( ) ) { switch ( $ reader -> nodeType ) { case XmlStreamReader :: ELEMENT : $ buffer .= '<' . $ reader -> name ; $ namespaces = [ ] ; while ( $ reader -> moveToNextAttribute ( ) ) { if ( $ reader -> namespaceURI == self :: NS_XML ) { switch ( $ reader -> localName ) { case 'nsdec' : case 'empty' : continue 2 ; } } if ( $ reader -> namespaceURI == self :: NS_XMLNS ) { $ namespaces [ $ reader -> name ] = $ reader -> value ; } $ buffer .= ' ' . $ reader -> name . '="' . htmlspecialchars ( $ reader -> value , ENT_COMPAT | ENT_XML1 | ENT_SUBSTITUTE , 'UTF-8' ) . '"' ; } $ reader -> moveToElement ( ) ; if ( ! empty ( $ namespaces ) ) { $ encoded = base64_encode ( json_encode ( $ namespaces , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ) ; $ buffer .= ' xml:nsdec="' . htmlspecialchars ( $ encoded , ENT_QUOTES | ENT_XML1 | ENT_SUBSTITUTE , 'UTF-8' ) . '"' ; } if ( $ reader -> isEmptyElement ) { $ buffer .= ' xml:empty="" />' ; } else { $ buffer .= '>' ; } break ; case XmlStreamReader :: END_ELEMENT : $ buffer .= '</' . $ reader -> name . '>' ; break ; case XmlStreamReader :: SIGNIFICANT_WHITESPACE : case XmlStreamReader :: TEXT : case XmlStreamReader :: WHITESPACE : $ buffer .= htmlspecialchars ( $ reader -> value , ENT_QUOTES | ENT_XML1 | ENT_SUBSTITUTE , 'UTF-8' ) ; break ; } } // Parse XML buffer into a DOM document. $ builder = new XmlDocumentBuilder ( ) ; $ xml = $ builder -> buildFromSource ( $ buffer ) ; $ compiler = new ExpressCompiler ( $ renderer ) ; $ compiler -> setResource ( $ resource ) ; $ parser = new ExpressViewParser ( ) ; $ view = $ parser -> parseSource ( $ xml ) ; $ view -> compile ( $ compiler ) ; return $ compiler ; } catch ( \ Exception $ e ) { $ ex = $ e ; do { if ( $ ex instanceof ExpressViewException ) { if ( $ ex -> getErrorFile ( ) === NULL ) { $ ex -> setErrorFile ( $ resource ) ; } } } while ( $ ex = $ ex -> getPrevious ( ) ) ; throw $ e ; } }
Compile the given XML source and return a compiler object.

@param string $data
@return ExpressCompiler
Compile the given XML source and return a compiler object .