private function runXhtml(XmlDocument $doc, XhtmlRenderingEngine $renderer)
    {
        $arguments = $this->getArguments();
        $profile = $arguments['flavour'];
        
        $xml = $renderer->render($doc->getDocumentComponent());
        
        $header = '';
        $footer = '';
        $indent = '';
        $nl = '';
        
        if ($arguments['format'] === true) {
            $xml->formatOutput = true;
            $indent .= "\x20\x20";
            $nl .= "\n";
        }
        
        if ($arguments['document'] === true) {
            $rootComponent = $doc->getDocumentComponent();
            
            $title = '';
            if ($rootComponent->getQtiClassName() === 'assessmentItem') {
                $title = XmlUtils::escapeXmlSpecialChars($rootComponent->getTitle());
            }
            
            $header .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
            $header .= "<html>${nl}";
            $header .= "${indent}<head>${nl}";
            $header .= "${indent}${indent}<meta charset=\"utf-8\">${nl}";
            
            if (empty($title) !== false) {
                $header .= "${indent}${indent}<title>" . $title . "</title>${nl}";
            }
            
            $header .= "${indent}${indent}" . $renderer->getStylesheets()->ownerDocument->saveXML($renderer->getStylesheets());
            $header .= "${indent}</head>${nl}";
            $header .= "${indent}<body>${nl}";
            
            $footer = "${indent}</body>${nl}";
            $footer .= "</html>\n";
        }
    
        $body = $xml->saveXml($xml->documentElement) . "${nl}";
        
        // Indent body...
        $indentBody = '';
        
        if ($arguments['document'] === null) {
            $indent = '';
        }
        
        foreach (preg_split('/\n|\r/u', $body, -1, PREG_SPLIT_NO_EMPTY) as $bodyLine) {
            // do stuff with $line
            $indentBody .= "${indent}${indent}${bodyLine}${nl}";
        }
        
        $body = $indentBody;
        
        return "{$header}{$indentBody}{$footer}";
    }
private function runXhtml(XmlDocument $doc, XhtmlRenderingEngine $renderer)
    {
        $arguments = $this->getArguments();
        $profile = $arguments['flavour'];
        
        $xml = $renderer->render($doc->getDocumentComponent());
        
        $header = '';
        $footer = '';
        $indent = '';
        $nl = '';
        
        if ($arguments['format'] === true) {
            $xml->formatOutput = true;
            $indent .= "\x20\x20";
            $nl .= "\n";
        }
        
        if ($arguments['document'] === true) {
            $rootComponent = $doc->getDocumentComponent();
            
            $title = '';
            if ($rootComponent->getQtiClassName() === 'assessmentItem') {
                $title = XmlUtils::escapeXmlSpecialChars($rootComponent->getTitle());
            }
            
            $header .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
            $header .= "<html>${nl}";
            $header .= "${indent}<head>${nl}";
            $header .= "${indent}${indent}<meta charset=\"utf-8\">${nl}";
            
            if (empty($title) !== false) {
                $header .= "${indent}${indent}<title>" . $title . "</title>${nl}";
            }
            
            $header .= "${indent}${indent}" . $renderer->getStylesheets()->ownerDocument->saveXML($renderer->getStylesheets());
            $header .= "${indent}</head>${nl}";
            $header .= "${indent}<body>${nl}";
            
            $footer = "${indent}</body>${nl}";
            $footer .= "</html>\n";
        }
    
        $body = $xml->saveXml($xml->documentElement) . "${nl}";
        
        // Indent body...
        $indentBody = '';
        
        if ($arguments['document'] === null) {
            $indent = '';
        }
        
        foreach (preg_split('/\n|\r/u', $body, -1, PREG_SPLIT_NO_EMPTY) as $bodyLine) {
            // do stuff with $line
            $indentBody .= "${indent}${indent}${bodyLine}${nl}";
        }
        
        $body = $indentBody;
        
        return "{$header}{$indentBody}{$footer}";
    }
private function runXhtml ( XmlDocument $ doc , XhtmlRenderingEngine $ renderer ) { $ arguments = $ this -> getArguments ( ) ; $ profile = $ arguments [ 'flavour' ] ; $ xml = $ renderer -> render ( $ doc -> getDocumentComponent ( ) ) ; $ header = '' ; $ footer = '' ; $ indent = '' ; $ nl = '' ; if ( $ arguments [ 'format' ] === true ) { $ xml -> formatOutput = true ; $ indent .= "\x20\x20" ; $ nl .= "\n" ; } if ( $ arguments [ 'document' ] === true ) { $ rootComponent = $ doc -> getDocumentComponent ( ) ; $ title = '' ; if ( $ rootComponent -> getQtiClassName ( ) === 'assessmentItem' ) { $ title = XmlUtils :: escapeXmlSpecialChars ( $ rootComponent -> getTitle ( ) ) ; } $ header .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" ; $ header .= "<html>${nl}" ; $ header .= "${indent}<head>${nl}" ; $ header .= "${indent}${indent}<meta charset=\"utf-8\">${nl}" ; if ( empty ( $ title ) !== false ) { $ header .= "${indent}${indent}<title>" . $ title . "</title>${nl}" ; } $ header .= "${indent}${indent}" . $ renderer -> getStylesheets ( ) -> ownerDocument -> saveXML ( $ renderer -> getStylesheets ( ) ) ; $ header .= "${indent}</head>${nl}" ; $ header .= "${indent}<body>${nl}" ; $ footer = "${indent}</body>${nl}" ; $ footer .= "</html>\n" ; } $ body = $ xml -> saveXml ( $ xml -> documentElement ) . "${nl}" ; // Indent body... $ indentBody = '' ; if ( $ arguments [ 'document' ] === null ) { $ indent = '' ; } foreach ( preg_split ( '/\n|\r/u' , $ body , - 1 , PREG_SPLIT_NO_EMPTY ) as $ bodyLine ) { // do stuff with $line $ indentBody .= "${indent}${indent}${bodyLine}${nl}" ; } $ body = $ indentBody ; return "{$header}{$indentBody}{$footer}" ; }
Run the rendering behaviour related to the "XHTML" flavour.

@param \qtism\data\storage\xml\XmlDocument $doc The QTI XML document to be rendered.
@param \qtism\runtime\rendering\markup\xhtml\XhtmlRenderingEngine $renderer
@return string The raw rendering data.
Run the rendering behaviour related to the XHTML flavour .