svn: /pear/peardoc/trunk/en/package/configuration/config/ avail-container/xml.xml examples/xml-write.php examples/xml-write.txt

[email protected] (Christian Weiske) Thu, 10 Mar 2011 20:50:16 +0000
Newsgroups php.pear.doc
Message-ID <[email protected]>
cweiske                                  Thu, 10 Mar 2011 20:50:16 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=309093

Log:
example for Config XML container

Changed paths:
    U   pear/peardoc/trunk/en/package/configuration/config/avail-container/xml.xml
    A   pear/peardoc/trunk/en/package/configuration/config/examples/xml-write.php
    A   pear/peardoc/trunk/en/package/configuration/config/examples/xml-write.txt

Modified: pear/peardoc/trunk/en/package/configuration/config/avail-container/xml.xml
===================================================================
--- pear/peardoc/trunk/en/package/configuration/config/avail-container/xml.xml	2011-03-10 20:24:09 UTC (rev 309092)
+++ pear/peardoc/trunk/en/package/configuration/config/avail-container/xml.xml	2011-03-10 20:50:16 UTC (rev 309093)
@@ -58,7 +58,7 @@
     <row>
      <entry><literal>indent</literal></entry>
      <entry>&type.string;</entry>
-     <entry><literal>  </literal></entry>
+     <entry><literal><![CDATA[  ]]></literal></entry>
      <entry>
       The character used for indentation when writing the XML document,
       if any. By default, two spaces are used.
@@ -120,5 +120,39 @@
  </table>


- <!-- FIXME: example file, example load, example save -->
+ <note>
+  <para>
+   To utilize the XML container, you need to have the
+   <link linkend="package.xml.xml-parser">XML_Parser</link>
+   package installed (optional dependency).
+  </para>
+ </note>
+
+
+ <section>
+  <info>
+   <title>Writing a config file with the XML container</title>
+  </info>
+
+  <programlisting role="php">
+   <xi:include parse="text"
+    xmlns:xi="http://www.w3.org/2001/XInclude"
+    href="&package.configuration.config.examples.xml-write.php;"
+   >
+    <xi:fallback>FIXME:MISSING XINCLUDE CONTENT</xi:fallback>
+   </xi:include>
+  </programlisting>
+
+  <example>
+   <title>Generated file</title>
+   <programlisting role="xml">
+    <xi:include parse="text"
+     xmlns:xi="http://www.w3.org/2001/XInclude"
+     href="&package.configuration.config.examples.xml-write.txt;"
+    >
+     <xi:fallback>FIXME:MISSING XINCLUDE CONTENT</xi:fallback>
+    </xi:include>
+   </programlisting>
+  </example>
+ </section>
 </section>

Added: pear/peardoc/trunk/en/package/configuration/config/examples/xml-write.php
===================================================================
--- pear/peardoc/trunk/en/package/configuration/config/examples/xml-write.php	                        (rev 0)
+++ pear/peardoc/trunk/en/package/configuration/config/examples/xml-write.php	2011-03-10 20:50:16 UTC (rev 309093)
@@ -0,0 +1,34 @@
+<?php
+require_once 'Config.php';
+
+$conf = new Config();
+$root = $conf->getRoot();
+$root->createComment('Demo config file with XML container');
+//we need a main section, otherwise we get invalid XML
+// see http://pear.php.net/bugs/bug.php?id=18357
+$main = $root->createSection('config');
+$main->createDirective('openLastFile', true);
+$main->createDirective('rememberFiles', 8);
+
+$main->createBlank();
+$dbsect = $main->createSection('database');
+$dbsect->createDirective('host', 'db-server.example.org');
+$dbsect->createDirective('name', 'demo-db');
+
+//this is a nested section
+$subsect = $dbsect->createSection('settings');
+$subsect->createDirective('charset', 'utf-8');
+$subsect->createDirective('reconnect', false);
+
+$r = $conf->writeConfig(
+    'xml-write.txt',
+    'xml',
+    array(
+        'encoding' => 'UTF-8',
+        'indent'   => ' ',
+    )
+);
+if (PEAR::isError($r)) {
+    echo $r->getMessage() . "\n";
+}
+?>
\ No newline at end of file

Added: pear/peardoc/trunk/en/package/configuration/config/examples/xml-write.txt
===================================================================
--- pear/peardoc/trunk/en/package/configuration/config/examples/xml-write.txt	                        (rev 0)
+++ pear/peardoc/trunk/en/package/configuration/config/examples/xml-write.txt	2011-03-10 20:50:16 UTC (rev 309093)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Demo config file with XML container -->
+<config>
+ <openLastFile>1</openLastFile>
+ <rememberFiles>8</rememberFiles>
+ <database>
+  <host>db-server.example.org</host>
+  <name>demo-db</name>
+  <settings>
+   <charset>utf-8</charset>
+   <reconnect />
+  </settings>
+ </database>
+</config>