Esempio n. 1
0
 /**
  * @param string $qualifiedName Qualified name of the document element.
  * @param string $publicId Public id.
  * @param string $systemId System id.
  * @return self
  */
 public function addDocType($qualifiedName, $publicId, $systemId)
 {
     $implementation = new DomImplementation();
     $type = $implementation->createDocumentType($qualifiedName, $publicId, $systemId);
     $this->appendChild($type);
     return $this;
 }
Esempio n. 2
0
 public function testSimple()
 {
     $implementation = new DomImplementation();
     $type = $implementation->createDocumentType('html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd');
     $document = $implementation->createDocument('http://www.w3.org/1999/xhtml', 'html', $type);
     $html = $document->documentElement;
     $head = $html->addElement('head');
     $head->addElement('title')->addText('Hello');
     $head->addElement('meta')->setAttributes(array('name' => 'Keywords', 'content' => 'php, dom'));
     $body = $html->addElement('body');
     $body->addElement('p')->addText('Hello World');
     $this->assertEquals('Blar\\Dom\\DomDocument', get_class($document));
     $this->assertXmlStringEqualsXmlFile(__DIR__ . '/DomImplementation/simple.xml', (string) $document);
     # var_dump($document->validate());
     # die();
 }
Esempio n. 3
0
 /**
  * @param string $namespaceURI Namespace uri.
  * @param string $qualifiedName Qualified name.
  * @param DomDocumentType $type Document type.
  * @return DomDocument
  */
 public function createDocument($namespaceURI = NULL, $qualifiedName = NULL, DomDocumentType $type)
 {
     /*
     $document = new DomDocument();
     
     $document->appendChild($type);
     $document->addElementNS($namespaceURI, $qualifiedName);
     
     return $document;
     */
     $baseDocument = parent::createDocument($namespaceURI, $qualifiedName, $type);
     if (!array_key_exists('domdocument', $this->nodeClasses)) {
         return $baseDocument;
     }
     $extendedClassName = $this->nodeClasses['domdocument'];
     $extendedDocument = new $extendedClassName($baseDocument->xmlVersion, $baseDocument->xmlEncoding);
     $extendedDocument->loadXML($baseDocument->saveXML());
     return $extendedDocument;
 }
Esempio n. 4
0
 public function testAppendDoctypeAndValidateWithReload()
 {
     $implementation = new DomImplementation();
     $type = $implementation->createDocumentType('html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd');
     $document = new DomDocument();
     $document->appendChild($type);
     $html = $document->addElementNS('http://www.w3.org/1999/xhtml', 'html');
     $head = $html->addElement('head');
     $head->addElement('title');
     $html->addElement('body');
     $document->reload();
     $this->assertTrue($document->validate());
 }