public function render() {
		if(! $this->bParsed) {
			$this->parse();
		}

		if (! $this->rootNode) {
			throw new XMLParsingException('No template file loaded', 0);
		}

        $context = new Context($this);

		// DOCTYPE
        // The doctype is necessarily on the root tag, declared as an attribute, example:
        //   fig:doctype="html"
        // However, it can be on the root node of an included template (when using the reverse plug/slot pattern)
        if ($this->rootNode instanceof ViewElementTag) {
            $context->setDoctype($this->rootNode->getAttribute($this->figNamespace . 'doctype'));
        }

        try {
            $result = $this->rootNode->render($context);
        } catch (RequiredAttributeException $ex) {
            throw $ex->setFile($context->getFilename());
        } catch (TagRenderingException $ex) {
            throw new RenderingException($ex->getTag(), $context->getFilename(), $ex->getLine(), $ex->getMessage(), $ex);
        } catch (FeedClassNotFoundException $ex) {
            throw $ex->setFile($context->getFilename());
        }


		$result = $this->plugIntoSlots($context, $result);

		// Take care of the doctype at top of output
		if ($context->getDoctype()) {
			$result = '<!doctype ' . $context->getDoctype() . '>' . "\n" . $result;
		}

		return $result;
	}