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