xref: /php-src/ext/xmlwriter/tests/008.phpt (revision 74859783)
1--TEST--
2XMLWriter: libxml2 XML Writer DTD Element & Attlist
3--EXTENSIONS--
4xmlwriter
5--FILE--
6<?php
7
8$xw = xmlwriter_open_memory();
9xmlwriter_set_indent($xw, TRUE);
10xmlwriter_start_document($xw, NULL, "UTF-8");
11xmlwriter_start_dtd_entity($xw, "ent", false);
12xmlwriter_text($xw, "val");
13xmlwriter_end_dtd_entity($xw);
14xmlwriter_write_dtd_entity($xw, "ent2", "val2");
15xmlwriter_write_dtd_element($xw, 'sxe', '(elem1+, elem11, elem22*)');
16xmlwriter_write_dtd_attlist($xw, 'sxe', 'id     CDATA  #implied');
17xmlwriter_start_dtd_element($xw, 'elem1');
18xmlwriter_text($xw, 'elem2*');
19xmlwriter_end_dtd_element($xw);
20xmlwriter_start_dtd_attlist($xw, 'elem1');
21xmlwriter_text($xw, "attr1  CDATA  #required\n");
22xmlwriter_text($xw, 'attr2  CDATA  #implied');
23xmlwriter_end_dtd_attlist($xw);
24xmlwriter_end_document($xw);
25// Force to write and empty the buffer
26$output = xmlwriter_flush($xw, true);
27print $output;
28?>
29--EXPECT--
30<?xml version="1.0" encoding="UTF-8"?>
31<!ENTITY ent "val">
32<!ENTITY ent2 "val2">
33<!ELEMENT sxe (elem1+, elem11, elem22*)>
34<!ATTLIST sxe id     CDATA  #implied>
35<!ELEMENT elem1 elem2*>
36<!ATTLIST elem1 attr1  CDATA  #required
37attr2  CDATA  #implied>
38