cvs: phpdoc /en/functions xml.xml

From: Date: Sat, 28 Oct 2000 06:41:22 +0000
Subject: cvs: phpdoc /en/functions xml.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969332683@lists.php.net to get a copy of this message
jmcastagnetto Fri Oct 27 23:41:22 2000 EDT Modified files: /phpdoc/en/functions xml.xml Log: Fixed entities in examples s/>/>/

Index: phpdoc/en/functions/xml.xml diff -u phpdoc/en/functions/xml.xml:1.12 phpdoc/en/functions/xml.xml:1.13 --- phpdoc/en/functions/xml.xml:1.12 Mon Aug 21 01:02:45 2000 +++ phpdoc/en/functions/xml.xml Fri Oct 27 23:41:22 2000 @@ -24,8 +24,8 @@ default, you can use this make rule for that: <programlisting role="makefile"> libexpat.a: $(OBJS) - ar -rc $@ $(OBJS) - ranlib $@ + ar -rc $@ $(OBJS) + ranlib $@ </programlisting> A source RPM package of expat can be found at <ulink url="&url.expat.rpm;">&url.expat.rpm;</ulink>. @@ -77,84 +77,84 @@ <table> <title>Supported XML handlers</title> <tgroup cols="2"> - <thead> - <row> - <entry>PHP function to set handler</entry> - <entry>Event description</entry> - </row> - </thead> - <tbody> - <row> - <entry><function>xml_set_element_handler</function></entry> - <entry> - Element events are issued whenever the XML parser - encounters start or end tags. There are separate handlers - for start tags and end tags. - </entry> - </row> - <row> - <entry> - <function>xml_set_character_data_handler</function> - </entry> - <entry> - Character data is roughly all the non-markup contents of - XML documents, including whitespace between tags. Note - that the XML parser does not add or remove any whitespace, - it is up to the application (you) to decide whether - whitespace is significant. - </entry> - </row> - <row> - <entry> - <function>xml_set_processing_instruction_handler</function> - </entry> - <entry> - PHP programmers should be familiar with processing - instructions (PIs) already. &lt;?php ?&gt; is a processing - instruction, where <replaceable>php</replaceable> is called - the "PI target". The handling of these are - application-specific, except that all PI targets starting - with "XML" are reserved. - </entry> - </row> - <row> - <entry><function>xml_set_default_handler</function></entry> - <entry> - What goes not to another handler goes to the default - handler. You will get things like the XML and document - type declarations in the default handler. - </entry> - </row> - <row> - <entry> - <function>xml_set_unparsed_entity_decl_handler</function> - </entry> - <entry> - This handler will be called for declaration of an unparsed - (NDATA) entity. - </entry> - </row> - <row> - <entry> - <function>xml_set_notation_decl_handler</function> - </entry> - <entry> - This handler is called for declaration of a notation. - </entry> - </row> - <row> - <entry> - <function>xml_set_external_entity_ref_handler</function> - </entry> - <entry> - This handler is called when the XML parser finds a - reference to an external parsed general entity. This can - be a reference to a file or URL, for example. See <link - linkend="example.xml-external-entity">the external entity - example</link> for a demonstration. - </entry> - </row> - </tbody> + <thead> + <row> + <entry>PHP function to set handler</entry> + <entry>Event description</entry> + </row> + </thead> + <tbody> + <row> + <entry><function>xml_set_element_handler</function></entry> + <entry> + Element events are issued whenever the XML parser + encounters start or end tags. There are separate handlers + for start tags and end tags. + </entry> + </row> + <row> + <entry> + <function>xml_set_character_data_handler</function> + </entry> + <entry> + Character data is roughly all the non-markup contents of + XML documents, including whitespace between tags. Note + that the XML parser does not add or remove any whitespace, + it is up to the application (you) to decide whether + whitespace is significant. + </entry> + </row> + <row> + <entry> + <function>xml_set_processing_instruction_handler</function> + </entry> + <entry> + PHP programmers should be familiar with processing + instructions (PIs) already. &lt;?php ?&gt; is a processing + instruction, where <replaceable>php</replaceable> is called + the "PI target". The handling of these are + application-specific, except that all PI targets starting + with "XML" are reserved. + </entry> + </row> + <row> + <entry><function>xml_set_default_handler</function></entry> + <entry> + What goes not to another handler goes to the default + handler. You will get things like the XML and document + type declarations in the default handler. + </entry> + </row> + <row> + <entry> + <function>xml_set_unparsed_entity_decl_handler</function> + </entry> + <entry> + This handler will be called for declaration of an unparsed + (NDATA) entity. + </entry> + </row> + <row> + <entry> + <function>xml_set_notation_decl_handler</function> + </entry> + <entry> + This handler is called for declaration of a notation. + </entry> + </row> + <row> + <entry> + <function>xml_set_external_entity_ref_handler</function> + </entry> + <entry> + This handler is called when the XML parser finds a + reference to an external parsed general entity. This can + be a reference to a file or URL, for example. See <link + linkend="example.xml-external-entity">the external entity + example</link> for a demonstration. + </entry> + </row> + </tbody> </tgroup> </table> </para> @@ -313,29 +313,29 @@ <example> <title>Map XML to HTML</title> <para> - This example maps tags in an XML document directly to HTML - tags. Elements not found in the "map array" are ignored. Of - course, this example will only work with a specific XML - document type. - <programlisting role="php"> + This example maps tags in an XML document directly to HTML + tags. Elements not found in the "map array" are ignored. Of + course, this example will only work with a specific XML + document type. + <programlisting role="php"> $file = "data.xml"; $map_array = array( - "BOLD" => "B", - "EMPHASIS" => "I", - "LITERAL" => "TT" + "BOLD" =&gt; "B", + "EMPHASIS" =&gt; "I", + "LITERAL" =&gt; "TT" ); function startElement($parser, $name, $attrs) { global $map_array; if ($htmltag = $map_array[$name]) { - print "&lt;$htmltag>"; + print "&lt;$htmltag&gt;"; } } function endElement($parser, $name) { global $map_array; if ($htmltag = $map_array[$name]) { - print "&lt;/$htmltag>"; + print "&lt;/$htmltag&gt;"; } } @@ -360,7 +360,7 @@ } } xml_parser_free($xml_parser); - </programlisting> + </programlisting> </para> </example> </para> @@ -501,7 +501,7 @@ print "parse complete\n"; xml_parser_free($xml_parser); -?> +?&gt; </programlisting> </example> </para> @@ -509,33 +509,33 @@ <example> <title>xmltest.xml</title> <programlisting role="xml"> -&lt;?xml version='1.0'?> +&lt;?xml version='1.0'?&gt; &lt;!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [ -&lt;!ENTITY plainEntity "FOO entity"> -&lt;!ENTITY systemEntity SYSTEM "xmltest2.xml"> -]> -&lt;chapter> - &lt;TITLE>Title &amp;plainEntity;&lt;/TITLE> - &lt;para> - &lt;informaltable> - &lt;tgroup cols="3"> - &lt;tbody> - &lt;row>&lt;entry>a1&lt;/entry>&lt;entry morerows="1">b1&lt;/entry>&lt;entry>c1&lt;/entry>&lt;/row> - &lt;row>&lt;entry>a2&lt;/entry>&lt;entry>c2&lt;/entry>&lt;/row> - &lt;row>&lt;entry>a3&lt;/entry>&lt;entry>b3&lt;/entry>&lt;entry>c3&lt;/entry>&lt;/row> - &lt;/tbody> - &lt;/tgroup> - &lt;/informaltable> - &lt;/para> +&lt;!ENTITY plainEntity "FOO entity"&gt; +&lt;!ENTITY systemEntity SYSTEM "xmltest2.xml"&gt; +]&gt; +&lt;chapter&gt; + &lt;TITLE&gt;Title &amp;plainEntity;&lt;/TITLE&gt; + &lt;para&gt; + &lt;informaltable&gt; + &lt;tgroup cols="3"&gt; + &lt;tbody&gt; + &lt;row&gt;&lt;entry&gt;a1&lt;/entry&gt;&lt;entry morerows="1"&gt;b1&lt;/entry&gt;&lt;entry&gt;c1&lt;/entry&gt;&lt;/row&gt; + &lt;row&gt;&lt;entry&gt;a2&lt;/entry&gt;&lt;entry&gt;c2&lt;/entry&gt;&lt;/row&gt; + &lt;row&gt;&lt;entry&gt;a3&lt;/entry&gt;&lt;entry&gt;b3&lt;/entry&gt;&lt;entry&gt;c3&lt;/entry&gt;&lt;/row&gt; + &lt;/tbody&gt; + &lt;/tgroup&gt; + &lt;/informaltable&gt; + &lt;/para&gt; &amp;systemEntity; - &lt;sect1 id="about"> - &lt;title>About this Document&lt;/title> - &lt;para> - &lt;!-- this is a comment --> - &lt;?php print 'Hi! This is PHP version '.phpversion(); ?> - &lt;/para> - &lt;/sect1> -&lt;/chapter> + &lt;sect1 id="about"&gt; + &lt;title&gt;About this Document&lt;/title&gt; + &lt;para&gt; + &lt;!-- this is a comment --&gt; + &lt;?php print 'Hi! This is PHP version '.phpversion(); ?&gt; + &lt;/para&gt; + &lt;/sect1&gt; +&lt;/chapter&gt; </programlisting> </example> </para> @@ -544,15 +544,15 @@ <example> <title>xmltest2.xml</title> <programlisting role="xml"> -&lt;?xml version="1.0"?> +&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE foo [ -&lt;!ENTITY testEnt "test entity"> -]> -&lt;foo> - &lt;element attrib="value"/> +&lt;!ENTITY testEnt "test entity"&gt; +]&gt; +&lt;foo&gt; + &lt;element attrib="value"/&gt; &amp;testEnt; - &lt;?php print "This is some more PHP code being executed."; ?> -&lt;/foo> + &lt;?php print "This is some more PHP code being executed."; ?&gt; +&lt;/foo&gt; </programlisting> </example> </para> @@ -580,15 +580,15 @@ <varlistentry> <term><parameter>encoding</parameter> (optional)</term> <listitem> - <para> - Which character encoding the parser should use. The - following character encodings are supported: - <simplelist> - <member><literal>ISO-8859-1</literal> (default)</member> - <member><literal>US-ASCII</literal></member> - <member><literal>UTF-8</literal></member> - </simplelist> - </para> + <para> + Which character encoding the parser should use. The + following character encodings are supported: + <simplelist> + <member><literal>ISO-8859-1</literal> (default)</member> + <member><literal>US-ASCII</literal></member> + <member><literal>UTF-8</literal></member> + </simplelist> + </para> </listitem> </varlistentry> </variablelist> @@ -625,14 +625,14 @@ var $parser; function xml() { - $this->parser = xml_parser_create(); - xml_set_object($this->parser,&amp;$this); - xml_set_element_handler($this->parser,"tag_open","tag_close"); - xml_set_character_data_handler($this->parser,"cdata"); + $this-&gt;parser = xml_parser_create(); + xml_set_object($this-&gt;parser,&amp;$this); + xml_set_element_handler($this-&gt;parser,"tag_open","tag_close"); + xml_set_character_data_handler($this-&gt;parser,"cdata"); } function parse($data) { - xml_parse($this->parser,$data); + xml_parse($this-&gt;parser,$data); } function tag_open($parser,$tag,$attributes) { @@ -650,8 +650,8 @@ } // end of class xml $xml_parser = new xml(); -$xml_parser->parse("&lt;A ID=\"hallo\">PHP&lt;/A>"); -?> +$xml_parser-&gt;parse("&lt;A ID=\"hallo\"&gt;PHP&lt;/A&gt;"); +?&gt; </programlisting> </refsect1> </refentry> @@ -701,43 +701,43 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - The first parameter, <replaceable>parser</replaceable>, is a - reference to the XML parser calling the - handler. - </simpara> + <simpara> + The first parameter, <replaceable>parser</replaceable>, is a + reference to the XML parser calling the + handler. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>name</parameter></term> <listitem> - <simpara> - The second parameter, <parameter>name</parameter>, contains - the name of the element for which this handler is called. If - <link linkend="xml.case-folding">case-folding</link> is in - effect for this parser, the element name will be in uppercase - letters. - </simpara> + <simpara> + The second parameter, <parameter>name</parameter>, contains + the name of the element for which this handler is called. If + <link linkend="xml.case-folding">case-folding</link> is in + effect for this parser, the element name will be in uppercase + letters. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>attribs</parameter></term> <listitem> - <simpara> - The third parameter, <parameter>attribs</parameter>, contains - an associative array with the element's attributes (if any). - The keys of this array are the attribute names, the values - are the attribute values. Attribute names are <link - linkend="xml.case-folding">case-folded</link> on the same - criteria as element names. Attribute values are - <emphasis>not</emphasis> case-folded. - </simpara> - <simpara> - The original order of the attributes can be retrieved by - walking through <parameter>attribs</parameter> the normal - way, using <function>each</function>. The first key in the - array was the first attribute, and so on. - </simpara> + <simpara> + The third parameter, <parameter>attribs</parameter>, contains + an associative array with the element's attributes (if any). + The keys of this array are the attribute names, the values + are the attribute values. Attribute names are <link + linkend="xml.case-folding">case-folded</link> on the same + criteria as element names. Attribute values are + <emphasis>not</emphasis> case-folded. + </simpara> + <simpara> + The original order of the attributes can be retrieved by + walking through <parameter>attribs</parameter> the normal + way, using <function>each</function>. The first key in the + array was the first attribute, and so on. + </simpara> </listitem> </varlistentry> </variablelist> @@ -756,23 +756,23 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - The first parameter, <replaceable>parser</replaceable>, is a - reference to the XML parser calling the - handler. - </simpara> + <simpara> + The first parameter, <replaceable>parser</replaceable>, is a + reference to the XML parser calling the + handler. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>name</parameter></term> <listitem> - <simpara> - The second parameter, <parameter>name</parameter>, contains - the name of the element for which this handler is called. If - <link linkend="xml.case-folding">case-folding</link> is in - effect for this parser, the element name will be in uppercase - letters. - </simpara> + <simpara> + The second parameter, <parameter>name</parameter>, contains + the name of the element for which this handler is called. If + <link linkend="xml.case-folding">case-folding</link> is in + effect for this parser, the element name will be in uppercase + letters. + </simpara> </listitem> </varlistentry> </variablelist> @@ -829,19 +829,19 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - The first parameter, <replaceable>parser</replaceable>, is a - reference to the XML parser calling the handler. - </simpara> + <simpara> + The first parameter, <replaceable>parser</replaceable>, is a + reference to the XML parser calling the handler. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>data</parameter></term> <listitem> - <simpara> - The second parameter, <parameter>data</parameter>, contains - the character data as a string. - </simpara> + <simpara> + The second parameter, <parameter>data</parameter>, contains + the character data as a string. + </simpara> </listitem> </varlistentry> </variablelist></para> @@ -923,14 +923,14 @@ <varlistentry> <term><parameter>target</parameter></term> <listitem><simpara> - The second parameter, <parameter>target</parameter>, contains - the PI target.</simpara></listitem> + The second parameter, <parameter>target</parameter>, contains + the PI target.</simpara></listitem> </varlistentry> <varlistentry> <term><parameter>data</parameter></term> <listitem><simpara> - The third parameter, <parameter>data</parameter>, contains - the PI data.</simpara></listitem> + The third parameter, <parameter>data</parameter>, contains + the PI data.</simpara></listitem> </varlistentry> </variablelist></para> <para> @@ -984,27 +984,27 @@ <variablelist> <varlistentry> <term> - <parameter>parser</parameter> + <parameter>parser</parameter> </term> <listitem> - <simpara> - The first parameter, <replaceable>parser</replaceable>, is a - reference to the XML parser calling the - handler. - </simpara> + <simpara> + The first parameter, <replaceable>parser</replaceable>, is a + reference to the XML parser calling the + handler. + </simpara> </listitem> </varlistentry> <varlistentry> <term> - <parameter>data</parameter> + <parameter>data</parameter> </term> <listitem> - <simpara> - The second parameter, <parameter>data</parameter>, contains - the character data. This may be the XML declaration, - document type declaration, entities or other data for which - no other handler exists. - </simpara> + <simpara> + The second parameter, <parameter>data</parameter>, contains + the character data. This may be the XML declaration, + document type declaration, entities or other data for which + no other handler exists. + </simpara> </listitem> </varlistentry> </variablelist> @@ -1080,54 +1080,54 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - The first parameter, <replaceable>parser</replaceable>, is a - reference to the XML parser calling the - handler. - </simpara> + <simpara> + The first parameter, <replaceable>parser</replaceable>, is a + reference to the XML parser calling the + handler. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>entityName</parameter></term> <listitem> - <simpara> - The name of the entity that is about to be defined. - </simpara> + <simpara> + The name of the entity that is about to be defined. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>base</parameter></term> <listitem><simpara> - This is the base for resolving the system identifier - (<parameter>systemId</parameter>) of the external - entity. Currently this parameter will always be set to - an empty string. - </simpara> + This is the base for resolving the system identifier + (<parameter>systemId</parameter>) of the external + entity. Currently this parameter will always be set to + an empty string. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>systemId</parameter></term> <listitem> - <simpara> - System identifier for the external entity. - </simpara> + <simpara> + System identifier for the external entity. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>publicId</parameter></term> <listitem> - <simpara> - Public identifier for the external entity. - </simpara> + <simpara> + Public identifier for the external entity. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>notationName</parameter></term> <listitem> - <simpara> - Name of the notation of this entity (see - <function>xml_set_notation_decl_handler</function>). - </simpara> + <simpara> + Name of the notation of this entity (see + <function>xml_set_notation_decl_handler</function>). + </simpara> </listitem> </varlistentry> </variablelist></para> @@ -1194,56 +1194,56 @@ <variablelist> <varlistentry> <term> - <parameter>parser</parameter> + <parameter>parser</parameter> </term> <listitem> - <simpara> - The first parameter, <replaceable>parser</replaceable>, is a - reference to the XML parser calling the - handler. - </simpara> + <simpara> + The first parameter, <replaceable>parser</replaceable>, is a + reference to the XML parser calling the + handler. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>notationName</parameter></term> <listitem> - <simpara> - This is the notation's <parameter>name</parameter>, as per - the notation format described above. - </simpara> + <simpara> + This is the notation's <parameter>name</parameter>, as per + the notation format described above. + </simpara> </listitem> </varlistentry> <varlistentry> <term> - <parameter>base</parameter> + <parameter>base</parameter> </term> <listitem> - <simpara> - This is the base for resolving the system identifier - (<parameter>systemId</parameter>) of the notation - declaration. Currently this parameter will always be set to - an empty string. - </simpara> + <simpara> + This is the base for resolving the system identifier + (<parameter>systemId</parameter>) of the notation + declaration. Currently this parameter will always be set to + an empty string. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>systemId</parameter></term> <listitem> - <simpara> - System identifier of the external notation - declaration. - </simpara> + <simpara> + System identifier of the external notation + declaration. + </simpara> </listitem> </varlistentry> <varlistentry> <term> - <parameter>publicId</parameter> + <parameter>publicId</parameter> </term> <listitem> - <simpara> - Public identifier of the external notation - declaration. - </simpara> + <simpara> + Public identifier of the external notation + declaration. + </simpara> </listitem> </varlistentry> </variablelist> @@ -1311,53 +1311,53 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - The first parameter, <replaceable>parser</replaceable>, is a - reference to the XML parser calling the handler. - </simpara> + <simpara> + The first parameter, <replaceable>parser</replaceable>, is a + reference to the XML parser calling the handler. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>openEntityNames</parameter></term> <listitem> - <simpara> - The second parameter, <parameter>openEntityNames</parameter>, - is a space-separated list of the names of the entities that - are open for the parse of this entity (including the name of - the referenced entity). - </simpara> + <simpara> + The second parameter, <parameter>openEntityNames</parameter>, + is a space-separated list of the names of the entities that + are open for the parse of this entity (including the name of + the referenced entity). + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>base</parameter></term> <listitem> - <simpara> - This is the base for resolving the system identifier - (<parameter>systemid</parameter>) of the external entity. - Currently this parameter will always be set to an empty - string. - </simpara> + <simpara> + This is the base for resolving the system identifier + (<parameter>systemid</parameter>) of the external entity. + Currently this parameter will always be set to an empty + string. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>systemId</parameter></term> <listitem> - <simpara> - The fourth parameter, <parameter>systemId</parameter>, is the - system identifier as specified in the entity declaration. - </simpara> + <simpara> + The fourth parameter, <parameter>systemId</parameter>, is the + system identifier as specified in the entity declaration. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>publicId</parameter></term> <listitem> - <simpara> - The fifth parameter, <parameter>publicId</parameter>, is the - public identifier as specified in the entity declaration, or - an empty string if none was specified; the whitespace in the - public identifier will have been normalized as required by - the XML spec. - </simpara> + <simpara> + The fifth parameter, <parameter>publicId</parameter>, is the + public identifier as specified in the entity declaration, or + an empty string if none was specified; the whitespace in the + public identifier will have been normalized as required by + the XML spec. + </simpara> </listitem> </varlistentry> </variablelist> @@ -1401,29 +1401,29 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - A reference to the XML parser to use. - </simpara> + <simpara> + A reference to the XML parser to use. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>data</parameter></term> <listitem> - <simpara> - Chunk of data to parse. A document may be parsed piece-wise - by calling <function>xml_parse</function> several times with - new data, as long as the <parameter>isFinal</parameter> - parameter is set and true when the last data is parsed. - </simpara> + <simpara> + Chunk of data to parse. A document may be parsed piece-wise + by calling <function>xml_parse</function> several times with + new data, as long as the <parameter>isFinal</parameter> + parameter is set and true when the last data is parsed. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>isFinal</parameter> (optional)</term> <listitem> - <simpara> - If set and true, <parameter>data</parameter> is the last - piece of data sent in this parse. - </simpara> + <simpara> + If set and true, <parameter>data</parameter> is the last + piece of data sent in this parse. + </simpara> </listitem> </varlistentry> </variablelist> @@ -1464,9 +1464,9 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - A reference to the XML parser to get error code from. - </simpara> + <simpara> + A reference to the XML parser to get error code from. + </simpara> </listitem> </varlistentry> </variablelist> @@ -1498,9 +1498,9 @@ <varlistentry> <term><parameter>code</parameter></term> <listitem> - <simpara> - An error code from <function>xml_get_error_code</function>. - </simpara> + <simpara> + An error code from <function>xml_get_error_code</function>. + </simpara> </listitem> </varlistentry> </variablelist> @@ -1532,9 +1532,9 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - A reference to the XML parser to get line number from. - </simpara> + <simpara> + A reference to the XML parser to get line number from. + </simpara> </listitem> </varlistentry> </variablelist> @@ -1569,9 +1569,9 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - A reference to the XML parser to get column number from. - </simpara> + <simpara> + A reference to the XML parser to get column number from. + </simpara> </listitem> </varlistentry> </variablelist> @@ -1606,9 +1606,9 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - A reference to the XML parser to get byte index from. - </simpara> + <simpara> + A reference to the XML parser to get byte index from. + </simpara> </listitem> </varlistentry> </variablelist> @@ -1637,21 +1637,21 @@ <paramdef>array <parameter>&amp;index</parameter></paramdef> </funcprototype> </funcsynopsis> + <para> + This function parses an XML file into 2 parallel array + structures, one (<parameter>index</parameter>) containing pointers + to the location of the appropriate values in the + <parameter>values</parameter> array. These last two parameters + must be passed by reference. + </para> <para> - This function parses an XML file into 2 parallel array - structures, one (<parameter>index</parameter>) containing pointers - to the location of the appropriate values in the - <parameter>values</parameter> array. These last two parameters - must be passed by reference. - </para> - <para> - Below is an example that illustrates the internal structure of - the arrays being generated by the function. We use a simple - <literal>note</literal> tag embeded inside a - <literal>para</literal> tag, and then we parse this an print out - the structures generated: - <informalexample> - <programlisting> + Below is an example that illustrates the internal structure of + the arrays being generated by the function. We use a simple + <literal>note</literal> tag embeded inside a + <literal>para</literal> tag, and then we parse this an print out + the structures generated: + <informalexample> + <programlisting> $simple = &quot;&lt;para&gt;&lt;note&gt;simple note&lt;/note&gt;&lt;/para&gt;&quot;; $p = xml_parser_create(); xml_parse_into_struct($p,$simple,&amp;$vals,&amp;$index); @@ -1660,11 +1660,11 @@ print_r($index); echo "\nVals array\n"; print_r($vals); - </programlisting> - </informalexample> - When we run that code, the output will be: - <informalexample> - <programlisting> + </programlisting> + </informalexample> + When we run that code, the output will be: + <informalexample> + <programlisting> Index array Array ( @@ -1707,93 +1707,93 @@ ) ) - </programlisting> - </informalexample> - </para> - <para> - Event-driven parsing (based on the expat library) can get - complicated when you have an XML document that is complex. - This function does not produce a DOM style object, but it - generates structures amenable of being transversed in a tree - fashion. Thus, we can create objects representing the data - in the XML file easily. Let's consider the following XML file - representing a small database of aminoacids information: - <example> - <title>moldb.xml - small database of molecular information</title> - <programlisting> + </programlisting> + </informalexample> + </para> + <para> + Event-driven parsing (based on the expat library) can get + complicated when you have an XML document that is complex. + This function does not produce a DOM style object, but it + generates structures amenable of being transversed in a tree + fashion. Thus, we can create objects representing the data + in the XML file easily. Let's consider the following XML file + representing a small database of aminoacids information: + <example> + <title>moldb.xml - small database of molecular information</title> + <programlisting> &lt;?xml version=&quot;1.0&quot;?&gt; &lt;moldb&gt; - &lt;molecule&gt; - &lt;name&gt;Alanine&lt;/name&gt; - &lt;symbol&gt;ala&lt;/symbol&gt; - &lt;code&gt;A&lt;/code&gt; - &lt;type&gt;hydrophobic&lt;/type&gt; - &lt;/molecule&gt; - - &lt;molecule&gt; - &lt;name&gt;Lysine&lt;/name&gt; - &lt;symbol&gt;lys&lt;/symbol&gt; - &lt;code&gt;K&lt;/code&gt; - &lt;type&gt;charged&lt;/type&gt; - &lt;/molecule&gt; + &lt;molecule&gt; + &lt;name&gt;Alanine&lt;/name&gt; + &lt;symbol&gt;ala&lt;/symbol&gt; + &lt;code&gt;A&lt;/code&gt; + &lt;type&gt;hydrophobic&lt;/type&gt; + &lt;/molecule&gt; + + &lt;molecule&gt; + &lt;name&gt;Lysine&lt;/name&gt; + &lt;symbol&gt;lys&lt;/symbol&gt; + &lt;code&gt;K&lt;/code&gt; + &lt;type&gt;charged&lt;/type&gt; + &lt;/molecule&gt; &lt;/moldb&gt; - </programlisting> - </example> - And some code to parse the document and generate the appropriate - objects: - <example> - <title> - parsemoldb.php - parses moldb.xml into and array of - molecular objects - </title> - <programlisting role="php"> + </programlisting> + </example> + And some code to parse the document and generate the appropriate + objects: + <example> + <title> + parsemoldb.php - parses moldb.xml into and array of + molecular objects + </title> + <programlisting role="php"> &lt;?php class AminoAcid { - var $name; // aa name - var $symbol; // three letter symbol - var $code; // one letter code - var $type; // hydrophobic, charged or neutral - - function AminoAcid ($aa) { - foreach ($aa as $k=&gt;$v) - $this-&gt;$k = $aa[$k]; - } + var $name; // aa name + var $symbol; // three letter symbol + var $code; // one letter code + var $type; // hydrophobic, charged or neutral + + function AminoAcid ($aa) { + foreach ($aa as $k=&gt;$v) + $this-&gt;$k = $aa[$k]; + } } function readDatabase($filename) { - // read the xml database of aminoacids - $data = implode(&quot;&quot;,file($filename)); - $parser = xml_parser_create(); - xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); - xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1); - xml_parse_into_struct($parser,$data,&amp;$values,&amp;$tags); - xml_parser_free($parser); - - // loop through the structures - foreach ($tags as $key=&gt;$val) { - if ($key == &quot;molecule&quot;) { - $molranges = $val; - // each contiguous pair of array entries are the - // lower and upper range for each molecule definition - for ($i=0; $i &lt; count($molranges); $i+=2) { - $offset = $molranges[$i] + 1; - $len = $molranges[$i + 1] - $offset; - $tdb[] = parseMol(array_slice($values, $offset, $len)); - } - } else { - continue; - } - } - return $tdb; + // read the xml database of aminoacids + $data = implode(&quot;&quot;,file($filename)); + $parser = xml_parser_create(); + xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); + xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1); + xml_parse_into_struct($parser,$data,&amp;$values,&amp;$tags); + xml_parser_free($parser); + + // loop through the structures + foreach ($tags as $key=&gt;$val) { + if ($key == &quot;molecule&quot;) { + $molranges = $val; + // each contiguous pair of array entries are the + // lower and upper range for each molecule definition + for ($i=0; $i &lt; count($molranges); $i+=2) { + $offset = $molranges[$i] + 1; + $len = $molranges[$i + 1] - $offset; + $tdb[] = parseMol(array_slice($values, $offset, $len)); + } + } else { + continue; + } + } + return $tdb; } function parseMol($mvalues) { - for ($i=0; $i &lt; count($mvalues); $i++) - $mol[$mvalues[$i][&quot;tag&quot;]] = $mvalues[$i][&quot;value&quot;]; - return new AminoAcid($mol); + for ($i=0; $i &lt; count($mvalues); $i++) + $mol[$mvalues[$i][&quot;tag&quot;]] = $mvalues[$i][&quot;value&quot;]; + return new AminoAcid($mol); } $db = readDatabase(&quot;moldb.xml&quot;); @@ -1801,14 +1801,14 @@ print_r($db); ?&gt; - </programlisting> - </example> - After executing <filename>parsemoldb.php</filename>, the variable - <varname>$db</varname> contains an array of - <classname>AminoAcid</classname> objects, and the output of the - script confirms that: - <informalexample> - <programlisting> + </programlisting> + </example> + After executing <filename>parsemoldb.php</filename>, the variable + <varname>$db</varname> contains an array of + <classname>AminoAcid</classname> objects, and the output of the + script confirms that: + <informalexample> + <programlisting> ** Database of AminoAcid objects: Array ( @@ -1829,9 +1829,9 @@ ) ) - </programlisting> - </informalexample> - </para> + </programlisting> + </informalexample> + </para> </refsect1> </refentry> @@ -1853,9 +1853,9 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - A reference to the XML parser to free. - </simpara> + <simpara> + A reference to the XML parser to free. + </simpara> </listitem> </varlistentry> </variablelist></para> @@ -1887,25 +1887,25 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - A reference to the XML parser to set an option in. - </simpara> + <simpara> + A reference to the XML parser to set an option in. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>option</parameter></term> <listitem> - <simpara> - Which option to set. See below. - </simpara> + <simpara> + Which option to set. See below. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>value</parameter></term> <listitem> - <simpara> - The option's new value. - </simpara> + <simpara> + The option's new value. + </simpara> </listitem> </varlistentry> </variablelist> @@ -1921,34 +1921,34 @@ <title>XML parser options</title> <tgroup cols="3"> <thead> - <row> - <entry>Option constant</entry> - <entry>Data type</entry> - <entry>Description</entry> - </row> + <row> + <entry>Option constant</entry> + <entry>Data type</entry> + <entry>Description</entry> + </row> </thead> <tbody> - <row> - <entry>XML_OPTION_CASE_FOLDING</entry> - <entry>integer</entry> - <entry> - Controls whether <link - linkend="xml.case-folding">case-folding</link> is enabled - for this XML parser. Enabled by default. - </entry> - </row> - <row> - <entry>XML_OPTION_TARGET_ENCODING</entry> - <entry>string</entry> - <entry> - Sets which <link linkend="xml.encoding">target - encoding</link> to use in this XML parser. By default, it - is set to the same as the source encoding used by - <function>xml_parser_create</function>. Supported target - encodings are <literal>ISO-8859-1</literal>, - <literal>US-ASCII</literal> and <literal>UTF-8</literal>. - </entry> - </row> + <row> + <entry>XML_OPTION_CASE_FOLDING</entry> + <entry>integer</entry> + <entry> + Controls whether <link + linkend="xml.case-folding">case-folding</link> is enabled + for this XML parser. Enabled by default. + </entry> + </row> + <row> + <entry>XML_OPTION_TARGET_ENCODING</entry> + <entry>string</entry> + <entry> + Sets which <link linkend="xml.encoding">target + encoding</link> to use in this XML parser. By default, it + is set to the same as the source encoding used by + <function>xml_parser_create</function>. Supported target + encodings are <literal>ISO-8859-1</literal>, + <literal>US-ASCII</literal> and <literal>UTF-8</literal>. + </entry> + </row> </tbody> </tgroup> </table> @@ -1977,20 +1977,20 @@ <varlistentry> <term><parameter>parser</parameter></term> <listitem> - <simpara> - A reference to the XML parser to get an option - from. - </simpara> + <simpara> + A reference to the XML parser to get an option + from. + </simpara> </listitem> </varlistentry> <varlistentry> <term><parameter>option</parameter></term> <listitem> - <simpara> - Which option to fetch. See - <function>xml_parser_set_option</function> for a list of - options. - </simpara> + <simpara> + Which option to fetch. See + <function>xml_parser_set_option</function> for a list of + options. + </simpara> </listitem> </varlistentry> </variablelist> @@ -2064,33 +2064,33 @@ <title>UTF-8 encoding</title> <tgroup cols="3"> <thead> - <row> - <entry>bytes</entry> - <entry>bits</entry> - <entry>representation</entry> - </row> + <row> + <entry>bytes</entry> + <entry>bits</entry> + <entry>representation</entry> + </row> </thead> <tbody> - <row> - <entry>1</entry> - <entry>7</entry> - <entry>0bbbbbbb</entry> - </row> - <row> - <entry>2</entry> - <entry>11</entry> - <entry>110bbbbb 10bbbbbb</entry> - </row> - <row> - <entry>3</entry> - <entry>16</entry> - <entry>1110bbbb 10bbbbbb 10bbbbbb</entry> - </row> - <row> - <entry>4</entry> - <entry>21</entry> - <entry>11110bbb 10bbbbbb 10bbbbbb 10bbbbbb</entry> - </row> + <row> + <entry>1</entry> + <entry>7</entry> + <entry>0bbbbbbb</entry> + </row> + <row> + <entry>2</entry> + <entry>11</entry> + <entry>110bbbbb 10bbbbbb</entry> + </row> + <row> + <entry>3</entry> + <entry>16</entry> + <entry>1110bbbb 10bbbbbb 10bbbbbb</entry> + </row> + <row> + <entry>4</entry> + <entry>21</entry> + <entry>11110bbb 10bbbbbb 10bbbbbb 10bbbbbb</entry> + </row> </tbody> </tgroup> </table>
« previous php.doc (#969332683) next »