cvs: peardoc /en/package xml.xml /en/package/xml xml-beautifier.xml /en/package/xml/xml-beautifier example.xml intro.xml
/en/package/xml/xml-beautifier/xml-beautifier apiversion.xml

From: Date: Sat, 20 Dec 2003 18:08:10 +0000
Subject: cvs: peardoc /en/package xml.xml /en/package/xml xml-beautifier.xml /en/package/xml/xml-beautifier example.xml intro.xml
/en/package/xml/xml-beautifier/xml-beautifier apiversion.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-2051@lists.php.net to get a copy of this message
schst Sat Dec 20 13:08:10 2003 EDT Added files: /peardoc/en/package/xml xml-beautifier.xml /peardoc/en/package/xml/xml-beautifier example.xml intro.xml /peardoc/en/package/xml/xml-beautifier/xml-beautifier apiversion.xml Modified files: /peardoc/en/package xml.xml Log: added introduction and example for XML_Beautifier

Index: peardoc/en/package/xml.xml diff -u peardoc/en/package/xml.xml:1.9 peardoc/en/package/xml.xml:1.10 --- peardoc/en/package/xml.xml:1.9 Tue Oct 14 18:54:04 2003 +++ peardoc/en/package/xml.xml Sat Dec 20 13:08:08 2003 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <chapter id="package.xml"> <title>XML</title> @@ -7,6 +7,7 @@ Provides Packages for creating and working with XML </para> + &package.xml.xml-beautifier; &package.xml.xml-rddl; &package.xml.xml-rss; &package.xml.xml-serializer; Index: peardoc/en/package/xml/xml-beautifier.xml +++ peardoc/en/package/xml/xml-beautifier.xml <!-- $Revision: 1.1 $ --> <sect1 id="package.xml.xml-beautifier"> <title>XML_Beautifier</title> <para> Package to &quot;beautify&quot; XML documents. This package will add line breaks, indentation and other layout elements to an XML document, so it can be easier read by humans. </para> &package.xml.xml-beautifier.intro; &package.xml.xml-beautifier.example; &package.xml.xml-beautifier.xml-beautifier.apiversion; </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/en/package/xml/xml-beautifier/example.xml +++ peardoc/en/package/xml/xml-beautifier/example.xml <!-- $Revision: 1.1 $ --> <refentry id="package.xml.xml-beautifier.example"> <refnamediv> <refname>Example</refname> <refpurpose>Example for the usage of XML_Beautifier</refpurpose> </refnamediv> <refsect1 id="package.xml.xml-beautifier.example.example1"> <title>Usage example</title> <simpara> The following examples shows how XML_Beautifier can be used to analyze a document. </simpara> <example> <title>Basic example</title> <programlisting role="xml"> <para> Let&apos;s assume, you've got an XML document that is really badly formatted: </para> <![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE page [ <!ENTITY foo SYSTEM "foo.xml"> <!ENTITY bar SYSTEM "bar.xml"> ]> <document title="Current News"> <meta project="none" foo="bar"> <keywords/><description/> <author>Stephan Schmidt</author> <getMetaNav/> </meta> <page label="PHP Application Tools" sublabel="Current News"> <?PHP for($i = 0; $i < count($_GET); $i++) { echo $_GET[$i]."<br>"; } ?> &foo;&bar; <intro> <!-- This Comment has more than one line. --> <introtitle>Welcome to PHP Application Tools &amp; PEAR!</introtitle> <para> If you're new to pat, and would like <!-- This is a comment in a single line that contains an &amp; --> to know what we do here, take a look at <link url= "/about/project.xml"> "About Pat"</link> or check out the <link url="/about/projectsOverview.xml">"projects overview"</link>. Otherwise, you probably know your way around the site already <smiley type="smile"/> </para> </intro> </page> </document> ]]> </programlisting> <para> All you have to do is to use XML_Beautifier, pass the filename of the original file and the filename for the new file: </para> <programlisting role="php"> <![CDATA[require_once "XML/Beautifier.php"; $fmt = new XML_Beautifier(); $result = $fmt->formatFile('originalFile.xml', 'beautifiedFile.xml'); if (PEAR::isError($result)) { echo $result->getMessage(); exit(); } echo "File beautified, awaiting orders!<br />"; ]]> </programlisting> <para> And voila, your document looks nice: </para> <programlisting role="xml"> <![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE page [ <!ENTITY foo SYSTEM "foo.xml"> <!ENTITY bar SYSTEM "bar.xml"> ]> <document title="Current News"> <meta foo="bar" project="none"> <keywords /> <description /> <author>Stephan Schmidt</author> <getMetaNav /> </meta> <page label="PHP Application Tools" sublabel="Current News"> <?PHP for($i = 0; $i < count($_GET); $i++) { echo $_GET[$i]."<br>"; } ?> &foo; &bar; <intro> <!-- This Comment has more than one line. --> <introtitle>Welcome to PHP Application Tools &amp; PEAR!</introtitle> <para> If you&apos;re new to pat, and would like <!-- This is a comment in a single line that contains an &amp; --> to know what we do here, take a look at <link url="/about/project.xml">&quot;About Pat&quot;</link> or check out the <link url="/about/projectsOverview.xml">&quot;projects overview&quot;</link> . Otherwise, you probably know your way around the site already <smiley type="smile" /> </para> </intro> </page> </document> ]]> </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/en/package/xml/xml-beautifier/intro.xml +++ peardoc/en/package/xml/xml-beautifier/intro.xml <!-- $Revision: 1.1 $ --> <refentry id="package.xml.xml-beautifier.intro"> <refnamediv> <refname>Introduction</refname> <refpurpose>Introduction to XML_Beautifier</refpurpose> </refnamediv> <refsect1 id="package.xml.xml-beautifier.intro.refsect1"> <title>Introduction to XML_Beautifier</title> <para> XML_Beautifier is a package, that helps you making XML documents easier to read for human beings. </para> <para> It is able to add line-breaks, indentation, sorts attributes, convert tag cases and wraps long comments. It recognizes tags, character data, comments, XML declarations, processing instructions and external entities and is able to format these tokens nicely. </para> <para> The document is split into these tokens using the XML_Beautifier_Tokenizer class and the expat parser. Then a renderer is used to create the string representation of the document and formats it using the specified options. </para> <para> Currently only one renderer is available, but as XML_Beautifier uses a driver-based architecture, other renderers (like syntax-highlighting) will follow soon. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/en/package/xml/xml-beautifier/xml-beautifier/apiversion.xml +++ peardoc/en/package/xml/xml-beautifier/xml-beautifier/apiversion.xml <!-- $Revision: 1.1 $ --> <refentry id="package.xml.xml-beautifier.xml-beautifier.apiversion"> <refnamediv> <refname><function>XML_Beautifier::apiVersion</function></refname> <refpurpose>return API version</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcsynopsisinfo> require_once 'XML/Beautifier.php'; </funcsynopsisinfo> <funcprototype> <funcdef>string <function>XML_Beautifier::apiVersion</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.xml.xml-beautifier.xml-beautifier.apiversion.desc"> &title.desc; <para> Returns API version of XML_Beautifier. </para> </refsect1> <refsect1 id="package.xml.xml-beautifier.xml-beautifier.apiversion.return"> &title.returns; <para> <emphasis>string</emphasis> API version </para> </refsect1> <refsect1 id="package.xml.xml-beautifier.xml-beautifier.apiversion.note"> &title.note; &note.canstatic; </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.pear.doc (#2051) next »