nlopess         Tue Feb 15 12:20:44 2005 EDT

  Modified files:              
    /phpdoc/en/reference/libxml/functions       libxml-clear-errors.xml 
                                                libxml-get-errors.xml 
                                                libxml-get-last-error.xml 
                                                libxml-set-streams-context.xml 
                                                libxml-use-internal-errors.xml 
  Log:
  more docs & examples
  
http://cvs.php.net/diff.php/phpdoc/en/reference/libxml/functions/libxml-clear-errors.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/libxml/functions/libxml-clear-errors.xml
diff -u phpdoc/en/reference/libxml/functions/libxml-clear-errors.xml:1.1 
phpdoc/en/reference/libxml/functions/libxml-clear-errors.xml:1.2
--- phpdoc/en/reference/libxml/functions/libxml-clear-errors.xml:1.1    Mon Feb 
14 13:01:01 2005
+++ phpdoc/en/reference/libxml/functions/libxml-clear-errors.xml        Tue Feb 
15 12:20:43 2005
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
 <refentry id="function.libxml-clear-errors">
  <refnamediv>
   <refname>libxml_clear_errors</refname>
   <refpurpose>
-   Clear last error from libxml
+   Clear libxml error buffer
   </refpurpose>
  </refnamediv>
  <refsect1 role="description">
@@ -13,68 +13,27 @@
    <type>void</type><methodname>libxml_clear_errors</methodname>
    <void/>
   </methodsynopsis>
-
-  &warn.undocumented.func;
-
- </refsect1>
- <refsect1 role="parameters">
-  &reftitle.parameters;
   <para>
+   <function>libxml_clear_errors</function> clears the libxml error buffer.
   </para>
  </refsect1>
+
  <refsect1 role="returnvalues">
   &reftitle.returnvalues;
   <para>
-   What the function returns, first on success, then on failure. See
-   also the &return.success; entity
+   &return.void;
   </para>
  </refsect1>
 
- <!-- Use when examples exist
- <refsect1 role="examples">
-  &reftitle.examples;
-  <para>
-   <example>
-    <title><function>A libxml-clear-errors example</title>
-    <para>
-     Any text that describes the purpose of the example, or
-     what goes on in the example should go here (inside the
-     <example> tag, not out
-    </para>
-    <programlisting role="php">
-<![CDATA[
-<?php
-if ($anexample === true) {
-    echo 'Use the PEAR Coding Standards';
-}
-?>
-]]>
-    </programlisting>
-    &example.outputs;
-    <screen>
-<![CDATA[
-Use the PEAR Coding Standards
-]]>
-    </screen>
-   </example>
-  </para>
- </refsect1>
- -->
-
-
- <!-- Use when adding See Also links
  <refsect1 role="seealso">
   &reftitle.seealso;
   <para>
    <simplelist>
-    <member><function></function></member>
-    <member>Or <link linkend="somethingelse">something else</link></member>
+    <member><function>libxml_get_errors</function></member>
+    <member><function>libxml_get_last_error</function></member>
    </simplelist>
   </para>
  </refsect1>
- -->
-
-
 </refentry>
 
 <!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/libxml/functions/libxml-get-errors.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/libxml/functions/libxml-get-errors.xml
diff -u phpdoc/en/reference/libxml/functions/libxml-get-errors.xml:1.1 
phpdoc/en/reference/libxml/functions/libxml-get-errors.xml:1.2
--- phpdoc/en/reference/libxml/functions/libxml-get-errors.xml:1.1      Mon Feb 
14 13:01:01 2005
+++ phpdoc/en/reference/libxml/functions/libxml-get-errors.xml  Tue Feb 15 
12:20:43 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
 <refentry id="function.libxml-get-errors">
  <refnamediv>
   <refname>libxml_get_errors</refname>
@@ -10,71 +10,107 @@
  <refsect1 role="description">
   &reftitle.description;
   <methodsynopsis>
-   <type>object</type><methodname>libxml_get_errors</methodname>
+   <type>array</type><methodname>libxml_get_errors</methodname>
    <void/>
   </methodsynopsis>
-
-  &warn.undocumented.func;
-
- </refsect1>
- <refsect1 role="parameters">
-  &reftitle.parameters;
   <para>
+   Retrieve array of errors.
   </para>
  </refsect1>
+
  <refsect1 role="returnvalues">
   &reftitle.returnvalues;
   <para>
-   What the function returns, first on success, then on failure. See
-   also the &return.success; entity
+   Returns an array with <type>LibXMLError</type> objects if there are any
+   errors in the buffer, or an empty array otherwise.
   </para>
  </refsect1>
 
- <!-- Use when examples exist
  <refsect1 role="examples">
   &reftitle.examples;
   <para>
    <example>
-    <title><function>A libxml-get-errors example</title>
+    <title>A <function>libxml_get_errors</function> example</title>
     <para>
-     Any text that describes the purpose of the example, or
-     what goes on in the example should go here (inside the
-     <example> tag, not out
+     This example demonstrates how to build a simple libxml error handler.
     </para>
     <programlisting role="php">
 <![CDATA[
 <?php
-if ($anexample === true) {
-    echo 'Use the PEAR Coding Standards';
+
+libxml_use_internal_errors(true);
+
+$xmlstr = <<< XML
+<?xml version='1.0' standalone='yes'?>
+<movies>
+ <movie>
+  <titles>PHP: Behind the Parser</title>
+ </movie>
+</movies>
+XML;
+
+$doc = simplexml_load_string($xmlstr);
+
+if (!$doc) {
+    $errors = libxml_get_errors();
+
+    foreach ($errors as $error) {
+        echo display_xml_error($error);
+    }
+
+    libxml_clear_errors();
+}
+
+
+function display_xml_error($error) {
+
+    switch ($error->level) {
+        case LIBXML_ERR_WARNING:
+            $return = "Warning $error->code: ";
+            break;
+         case LIBXML_ERR_ERROR:
+            $return = "Error $error->code: ";
+            break;
+        case LIBXML_ERR_FATAL:
+            $return = "Fatal Error $error->code: ";
+            break;
+    }
+
+    $return .= trim($error->message) .
+               "\n  Line: $error->line" .
+               "\n  Column: $error->column";
+
+    if ($error->file) {
+        $return .= "\n  File: $error->file";
+    }
+
+    return "$return\n";
 }
+
 ?>
 ]]>
     </programlisting>
     &example.outputs;
     <screen>
 <![CDATA[
-Use the PEAR Coding Standards
+Fatal Error 76: Opening and ending tag mismatch: titles line 4 and title
+  Line: 4
+  Column: 0
 ]]>
     </screen>
    </example>
   </para>
  </refsect1>
- -->
-
 
- <!-- Use when adding See Also links
  <refsect1 role="seealso">
   &reftitle.seealso;
   <para>
    <simplelist>
-    <member><function></function></member>
-    <member>Or <link linkend="somethingelse">something else</link></member>
+    <member><function>libxml_get_last_error</function></member>
+    <member><function>libxml_clear_errors</function></member>
    </simplelist>
   </para>
  </refsect1>
- -->
-
-
 </refentry>
 
 <!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/libxml/functions/libxml-get-last-error.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/libxml/functions/libxml-get-last-error.xml
diff -u phpdoc/en/reference/libxml/functions/libxml-get-last-error.xml:1.1 
phpdoc/en/reference/libxml/functions/libxml-get-last-error.xml:1.2
--- phpdoc/en/reference/libxml/functions/libxml-get-last-error.xml:1.1  Mon Feb 
14 13:01:01 2005
+++ phpdoc/en/reference/libxml/functions/libxml-get-last-error.xml      Tue Feb 
15 12:20:43 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
 <refentry id="function.libxml-get-last-error">
  <refnamediv>
   <refname>libxml_get_last_error</refname>
@@ -10,71 +10,31 @@
  <refsect1 role="description">
   &reftitle.description;
   <methodsynopsis>
-   <type>object</type><methodname>libxml_get_last_error</methodname>
+   <type>LibXMLError</type><methodname>libxml_get_last_error</methodname>
    <void/>
   </methodsynopsis>
-
-  &warn.undocumented.func;
-
- </refsect1>
- <refsect1 role="parameters">
-  &reftitle.parameters;
   <para>
+   Retrieve last error from libxml.
   </para>
  </refsect1>
+
  <refsect1 role="returnvalues">
   &reftitle.returnvalues;
   <para>
-   What the function returns, first on success, then on failure. See
-   also the &return.success; entity
+   Returns a <type>LibXMLError</type> object if there is any error in the
+   buffer, &false; otherwise.
   </para>
  </refsect1>
 
- <!-- Use when examples exist
- <refsect1 role="examples">
-  &reftitle.examples;
-  <para>
-   <example>
-    <title><function>A libxml-get-last-error example</title>
-    <para>
-     Any text that describes the purpose of the example, or
-     what goes on in the example should go here (inside the
-     <example> tag, not out
-    </para>
-    <programlisting role="php">
-<![CDATA[
-<?php
-if ($anexample === true) {
-    echo 'Use the PEAR Coding Standards';
-}
-?>
-]]>
-    </programlisting>
-    &example.outputs;
-    <screen>
-<![CDATA[
-Use the PEAR Coding Standards
-]]>
-    </screen>
-   </example>
-  </para>
- </refsect1>
- -->
-
-
- <!-- Use when adding See Also links
  <refsect1 role="seealso">
   &reftitle.seealso;
   <para>
    <simplelist>
-    <member><function></function></member>
-    <member>Or <link linkend="somethingelse">something else</link></member>
+    <member><function>libxml_get_errors</function></member>
+    <member><function>libxml_clear_errors</function></member>
    </simplelist>
   </para>
  </refsect1>
- -->
-
-
 </refentry>
 
 <!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/libxml/functions/libxml-set-streams-context.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/libxml/functions/libxml-set-streams-context.xml
diff -u phpdoc/en/reference/libxml/functions/libxml-set-streams-context.xml:1.1 
phpdoc/en/reference/libxml/functions/libxml-set-streams-context.xml:1.2
--- phpdoc/en/reference/libxml/functions/libxml-set-streams-context.xml:1.1     
Mon Feb 14 13:01:01 2005
+++ phpdoc/en/reference/libxml/functions/libxml-set-streams-context.xml Tue Feb 
15 12:20:43 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
 <refentry id="function.libxml-set-streams-context">
  <refnamediv>
   <refname>libxml_set_streams_context</refname>
@@ -13,10 +13,11 @@
    <type>void</type><methodname>libxml_set_streams_context</methodname>
    
<methodparam><type>resource</type><parameter>streams_context</parameter></methodparam>
   </methodsynopsis>
-
-  &warn.undocumented.func;
-
+  <para>
+   Sets the streams context for the next libxml document load or write.
+  </para>
  </refsect1>
+
  <refsect1 role="parameters">
   &reftitle.parameters;
   <para>
@@ -25,66 +26,58 @@
      <term><parameter>streams_context</parameter></term>
       <listitem>
        <para>
-        Its description
+        The stream context resource (created with
+        <function>stream_context_create</function>)
        </para>
       </listitem>
      </varlistentry>
    </variablelist>
   </para>
  </refsect1>
+
  <refsect1 role="returnvalues">
   &reftitle.returnvalues;
   <para>
-   What the function returns, first on success, then on failure. See
-   also the &return.success; entity
+   &return.void;
   </para>
  </refsect1>
 
- <!-- Use when examples exist
  <refsect1 role="examples">
   &reftitle.examples;
   <para>
    <example>
-    <title><function>A libxml-set-streams-context example</title>
-    <para>
-     Any text that describes the purpose of the example, or
-     what goes on in the example should go here (inside the
-     <example> tag, not out
-    </para>
+    <title>A <function>libxml_set_streams_context</function> example</title>
     <programlisting role="php">
 <![CDATA[
 <?php
-if ($anexample === true) {
-    echo 'Use the PEAR Coding Standards';
-}
+
+$opts = array(
+    'http' => array(
+        'user_agent' => 'PHP libxml agent',
+    )
+);
+
+$context = stream_context_create($opts);
+libxml_set_streams_context($context);
+
+// request a file through HTTP
+$doc = DOMDocument::load('http://www.example.com/file.xml');
+
 ?>
 ]]>
     </programlisting>
-    &example.outputs;
-    <screen>
-<![CDATA[
-Use the PEAR Coding Standards
-]]>
-    </screen>
    </example>
   </para>
  </refsect1>
- -->
 
-
- <!-- Use when adding See Also links
  <refsect1 role="seealso">
   &reftitle.seealso;
   <para>
    <simplelist>
-    <member><function></function></member>
-    <member>Or <link linkend="somethingelse">something else</link></member>
+    <member><function>stream_context_create</function></member>
    </simplelist>
   </para>
  </refsect1>
- -->
-
-
 </refentry>
 
 <!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/libxml/functions/libxml-use-internal-errors.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/libxml/functions/libxml-use-internal-errors.xml
diff -u phpdoc/en/reference/libxml/functions/libxml-use-internal-errors.xml:1.2 
phpdoc/en/reference/libxml/functions/libxml-use-internal-errors.xml:1.3
--- phpdoc/en/reference/libxml/functions/libxml-use-internal-errors.xml:1.2     
Tue Feb 15 08:47:10 2005
+++ phpdoc/en/reference/libxml/functions/libxml-use-internal-errors.xml Tue Feb 
15 12:20:43 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
 <refentry id="function.libxml-use-internal-errors">
  <refnamediv>
   <refname>libxml_use_internal_errors</refname>
@@ -50,7 +50,7 @@
     <title>A <function>libxml_use_internal_errors</function> example</title>
     <para>
      This example demonstrates the basic usage of libxml errors and the value
-     returned by <function>libxml_use_internal_errors</function>.
+     returned by this function.
     </para>
     <programlisting role="php">
 <![CDATA[
@@ -62,12 +62,12 @@
 $doc = DOMDocument::load('file.xml');
 
 if (!$doc) {
-  $errors = libxml_get_errors();
-  foreach ($errors as $error) {
-       // handle errors here
-  }
+    $errors = libxml_get_errors();
+    foreach ($errors as $error) {
+        // handle errors here
+    }
 
-  libxml_clear_errors();
+    libxml_clear_errors();
 }
 
 ?>

Reply via email to