xref: /PHP-7.4/ext/xmlwriter/tests/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 = xmlwriter_open_memory();
11xmlwriter_set_indent($xw, TRUE);
12xmlwriter_start_document($xw, NULL, "UTF-8");
13xmlwriter_start_dtd_entity($xw, "ent", false);
14xmlwriter_text($xw, "val");
15xmlwriter_end_dtd_entity($xw);
16xmlwriter_write_dtd_entity($xw, "ent2", "val2");
17xmlwriter_write_dtd_element($xw, 'sxe', '(elem1+, elem11, elem22*)');
18xmlwriter_write_dtd_attlist($xw, 'sxe', 'id     CDATA  #implied');
19xmlwriter_start_dtd_element($xw, 'elem1');
20xmlwriter_text($xw, 'elem2*');
21xmlwriter_end_dtd_element($xw);
22xmlwriter_start_dtd_attlist($xw, 'elem1');
23xmlwriter_text($xw, "attr1  CDATA  #required\n");
24xmlwriter_text($xw, 'attr2  CDATA  #implied');
25xmlwriter_end_dtd_attlist($xw);
26xmlwriter_end_document($xw);
27// Force to write and empty the buffer
28$output = xmlwriter_flush($xw, true);
29print $output;
30?>
31--EXPECT--
32<?xml version="1.0" encoding="UTF-8"?>
33<!ENTITY ent "val">
34<!ENTITY ent2 "val2">
35<!ELEMENT sxe (elem1+, elem11, elem22*)>
36<!ATTLIST sxe id     CDATA  #implied>
37<!ELEMENT elem1 elem2*>
38<!ATTLIST elem1 attr1  CDATA  #required
39attr2  CDATA  #implied>
40