public function xInclude($validate = false) {
        
        if (($root = $this->getDocumentComponent()) !== null) {
            
            $baseUri = str_replace('\\', '/', $this->getDomDocument()->documentElement->baseURI);
            $pathinfo = pathinfo($baseUri);
            $basePath = $pathinfo['dirname'];
            
            $iterator = new QtiComponentIterator($root, array('include'));
            foreach ($iterator as $include) {
                $parent = $iterator->parent();
                
                // Is the parent something we can deal with for replacement?
                $reflection = new ReflectionClass($parent);
                
                if ($reflection->hasMethod('getContent') === true && $parent->getContent() instanceof QtiComponentCollection) {
                    $href = $include->getHref();
                    
                    if (Url::isRelative($href) === true) {
                        $href = Url::rtrim($basePath) . '/' . Url::ltrim($href);
                        
                        $doc = new XmlDocument();
                        $doc->load($href, $validate);
                        $includeRoot = $doc->getDocumentComponent();
                        
                        if ($includeRoot instanceof Flow) {
                            // Derive xml:base...
                            $xmlBase = Url::ltrim(str_replace($basePath, '', $href));
                            $xmlBasePathInfo = pathinfo($xmlBase);
                            
                            if ($xmlBasePathInfo['dirname'] !== '.') {
                                $includeRoot->setXmlBase($xmlBasePathInfo['dirname'] . '/');
                            }
                        }
                        
                        $parent->getContent()->replace($include, $includeRoot);
                    }
                }
            }
        } else {
            $msg = "Cannot include fragments via XInclude before loading any file.";
            throw new LogicException($msg);
        }
    }