xref: /PHP-8.0/ext/xmlwriter/tests/OO_008.phpt (revision 782352c5)
1--TEST--
2XMLWriter: libxml2 XML Writer DTD Element & Attlist
3--SKIPIF--
4<?php
5if (!extension_loaded("xmlwriter")) die("skip");
6?>
7--FILE--
8<?php
9
10$xw = new XMLWriter();
11$xw->openMemory();
12$xw->setIndent(TRUE);
13$xw->startDocument(NULL, "UTF-8");
14$xw->writeDtdElement('sxe', '(elem1+, elem11, elem22*)');
15$xw->writeDtdAttlist('sxe', 'id     CDATA  #implied');
16$xw->startDtdElement('elem1');
17$xw->text('elem2*');
18$xw->endDtdElement();
19$xw->startDtdAttlist('elem1');
20$xw->text("attr1  CDATA  #required\n");
21$xw->text('attr2  CDATA  #implied');
22$xw->endDtdAttlist();
23$xw->endDocument();
24// Force to write and empty the buffer
25$output = $xw->flush(true);
26print $output;
27?>
28--EXPECT--
29<?xml version="1.0" encoding="UTF-8"?>
30<!ELEMENT sxe (elem1+, elem11, elem22*)>
31<!ATTLIST sxe id     CDATA  #implied>
32<!ELEMENT elem1 elem2*>
33<!ATTLIST elem1 attr1  CDATA  #required
34attr2  CDATA  #implied>
35