cvs: peardoc /en/package/xml/xml-serializer/xml-unserializer options.xml
| From: | Chuck Burgess | Date: | Fri, 19 Sep 2008 11:09:25 +0000 |
| Subject: | cvs: peardoc /en/package/xml/xml-serializer/xml-unserializer options.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-11093@lists.php.net to get a copy of this message | ||
ashnazg Fri Sep 19 11:09:25 2008 UTC
Modified files:
/peardoc/en/package/xml/xml-serializer/xml-unserializer options.xml
Log:
add all the OPTIONS constant names; add missing options; add examples using OPTIONS constants;
grammar-check the descriptions
http://cvs.php.net/viewvc.cgi/peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml?r1=1.5&r2=1.6&diff_format=u Index: peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml diff -u peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml:1.5 peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml:1.6 --- peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml:1.5 Tue May 20 18:47:31 2008 +++ peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml Fri Sep 19 11:09:25 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry id="package.xml.xml-serializer.xml-unserializer.options"> <refnamediv> <refname>XML_Unserializer Options</refname> @@ -7,9 +7,9 @@ <refsect1 id="package.xml.xml-serializer.xml-unserializer.options.refsect1"> <title>Introduction to options</title> <para> - Options let you influence, how XML_Unserializer treats the parsed XML. - It allows you to define, whether attributes should be parsed, whether - to use associative arrays or objects for complex data types and more. + Options let you influence how XML_Unserializer treats the parsed XML. + It allows you to define whether attributes should be parsed, whether + to use associative arrays or objects for complex data types, and more. </para> <para> Options can be passed as an associative array to the @@ -30,7 +30,8 @@ <tgroup cols="4"> <thead> <row> - <entry>Option</entry> + <entry>XML_UNSERIALIZER_OPTION_ Name</entry> + <entry>Alternate Key for $options Array</entry> <entry>Possible values</entry> <entry>Default</entry> <entry>Description</entry> @@ -38,27 +39,35 @@ </thead> <tbody> <row> + <entry>_COMPLEXTYPE</entry> <entry>complexType</entry> <entry>'array' or 'object'</entry> <entry>'array'</entry> - <entry>Defines, whether nested tags should be returned as associative arrays or objects</entry> + <entry>Defines whether nested tags should be returned as associative arrays or objects.</entry> </row> <row> + <entry>_TAG_AS_CLASSNAME</entry> <entry>tagAsClass</entry> <entry>&true; or &false;</entry> <entry>&true;</entry> <entry> - Defines, whether the tag name should be used as the class name if complexType is set to 'object'. - If no class with the name of the tag exists, that class defined by 'defaultClass' is used. + Defines whether the tag name should be used as the class name + if complexType is set to 'object'. If no class with the name + of the tag exists, the class defined by 'defaultClass' is used. </entry> </row> <row> + <entry>_DEFAULT_CLASS</entry> <entry>defaultClass</entry> <entry>any string</entry> <entry>stdClass</entry> - <entry>Defines the class that is used to create objects, if the complexType option is set to 'object'.</entry> + <entry> + Defines the class that is used to create objects, if the complexType option + is set to 'object'. + </entry> </row> <row> + <entry>_ATTRIBUTE_KEY</entry> <entry>keyAttribute</entry> <entry>any string or array</entry> <entry>'_originalKey'</entry> @@ -70,94 +79,164 @@ </entry> </row> <row> + <entry>_ATTRIBUTE_TYPE</entry> <entry>typeAttribute</entry> <entry>any string</entry> <entry>'_type'</entry> - <entry>If this attribute exists for a tag, the tag content will be converted to the specified type. Possible types are: string, integer, float, boolean, array and object</entry> + <entry> + If this attribute exists for a tag, the tag content will be converted + to the specified type. Possible types are: string, integer, float, + boolean, array, and object. + </entry> </row> <row> + <entry>_ATTRIBUTE_CLASS</entry> <entry>classAttribute</entry> <entry>any string</entry> <entry>'_class'</entry> <entry> - If XML_Unserializer creates an object, it will be an instance of the value specified with the defaultClass - option, unless the tag has the attribute specified in this option. If it is set, the classname stored in - the attribute value will be used. + If XML_Unserializer creates an object, it will be an instance of the value + specified with the defaultClass option, unless the tag has the attribute + specified in this option. If it is set, the classname stored in the attribute + value will be used. </entry> </row> <row> + <entry>_ATTRIBUTES_PARSE</entry> <entry>parseAttributes</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> - <entry>With this option, you may tell XML_Unserializer to also parse the attributes of the tags. The next two options define how to treat the parsed attributes.</entry> + <entry> + With this option, you may tell XML_Unserializer to also parse the attributes of + the tags. The next two options define how to treat the parsed attributes. + </entry> </row> <row> + <entry>_ATTRIBUTES_ARRAYKEY</entry> <entry>attributesArray</entry> <entry>&false; or any string</entry> <entry>&false;</entry> - <entry>If set to false, the attributes will be treated like nested tags. If you set it to a string, a new aray will be created and stored in the parent structure using key you specified in this option</entry> + <entry> + If set to false, the attributes will be treated like nested tags. If you set it to a string, + a new aray will be created and stored in the parent structure using key you specified in this option. + </entry> </row> <row> + <entry>_ATTRIBUTES_PREPEND</entry> <entry>prependAttributes</entry> <entry>any string</entry> <entry>''</entry> - <entry>Allows you to specify a prefix for attribute names.</entry> + <entry> + Allows you to specify a prefix for attribute names. + </entry> </row> <row> + <entry>_CONTENT_KEY</entry> <entry>contentName</entry> <entry>any string</entry> <entry>'_content'</entry> - <entry>If you decide to parse attributes or a tag contains cdata and tags, then the cdata will be stored in the index specified here.</entry> + <entry> + If you decide to parse attributes or a tag contains cdata and tags, + then the cdata will be stored in the index specified here. + </entry> </row> <row> + <entry>_TAG_MAP</entry> <entry>tagMap</entry> <entry>associative array</entry> <entry>array()</entry> - <entry>This allows you to map tag names to PHP classes. The names of the tags have to be in the keys and the values contain the class names to use for each tag.</entry> + <entry> + This allows you to map tag names to PHP classes. The names of the tags have to be + in the keys and the values contain the class names to use for each tag. + </entry> </row> <row> + <entry>_FORCE_ENUM</entry> <entry>forceEnum</entry> <entry>indexed array</entry> <entry>array()</entry> <entry> This allows you to specify a list of tags which will automatically be converted to an indexed array, - independent of the number of repetitions of the tag. This can save you a some if conditions in your - code. + independent of the number of repetitions of the tag. This can save you some IF conditions in your code. </entry> </row> <row> + <entry>_ENCODING_SOURCE</entry> <entry>encoding</entry> - <entry>any valid encoding string</entry> + <entry>any valid encoding string (accepted by XML_Parser)</entry> <entry>null</entry> <entry> Defines the encoding of the original document. </entry> </row> <row> + <entry>_ENCODING_TARGET</entry> <entry>targetEncoding</entry> - <entry>any valid encoding string</entry> + <entry>any valid encoding string (accepted by XML_Parser)</entry> <entry>null</entry> <entry> Defines the target encoding of the resulting data. </entry> </row> <row> + <entry>_DECODE_FUNC</entry> <entry>decodeFunction</entry> <entry>any valid PHP callback</entry> <entry>null</entry> <entry> This option allows you to define a callback function or method, that will be applied to all character data - and attributes in the document before they are stored in the result. This allows you to decode any decoded data - in the XML or convert all content to lowercase. + and attributes in the document before they are stored in the result. This allows you to decode any decoded + data in the XML or convert all content to lowercase. </entry> </row> <row> + <entry>_RETURN_RESULT</entry> <entry>returnResult</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> - If set to &true; <function>XML_Unserializer::unserialize</function> will return the result if the - document could be unserialized instead of just &true;. + If set to &true; <function>XML_Unserializer::unserialize</function> will return the result + if the document could be unserialized instead of just &true;. + </entry> + </row> + <row> + <entry>_WHITESPACE</entry> + <entry>whitespace</entry> + <entry>_WHITESPACE_KEEP, _WHITESPACE_TRIM, _WHITESPACE_NORMALIZE</entry> + <entry>_WHITESPACE_TRIM</entry> + <entry> + Defines how whitespace in the document will be treated: + keep it all, trim it, or normalize it. + </entry> + </row> + <row> + <entry>_IGNORE_KEYS</entry> + <entry>ignoreKeys</entry> + <entry>any array</entry> + <entry>array()</entry> + <entry> + List of tags whose contents will be passed to the parent tag + instead of creating a new tag. + </entry> + </row> + <row> + <entry>_GUESS_TYPES</entry> + <entry>guessTypes</entry> + <entry>&true; or &false;</entry> + <entry>&false;</entry> + <entry> + Whether or not to enable automatic type guessing + for character data and attributes. + </entry> + </row> + <row> + <entry>_OVERRIDE_OPTIONS</entry> + <entry>overrideOptions</entry> + <entry>&true; or &false;</entry> + <entry>&false;</entry> + <entry> + Allows you to override the options already set + on this unserializer object. </entry> </row> </tbody> @@ -166,17 +245,18 @@ </para> </refsect1> <refsect1 id="package.xml.xml-serializer.xml-unserializer.options.example1"> - <title>Options example</title> + <title>Options via XML_UNSERIALIZER_OPTION Constants example</title> <simpara> - The following examples shows how to set options for XML_Unserializer. + The following examples shows how to set options for XML_Unserializer, + using the available XML_UNSERIALIZER_OPTION constants. </simpara> <example> <title>Using the constructor</title> <programlisting role="php"> <![CDATA[require_once "XML/Unserializer.php"; $options = array( - 'complexType' => 'array' - ); + XML_UNSERIALIZER_OPTION_COMPLEXTYPE => 'array' +); $us = new XML_Unserializer($options); $result = $us->unserialize('example.xml', true); @@ -185,6 +265,7 @@ </example> <simpara> The following example shows how to set options for XML_Unserializer, + using the available XML_UNSERIALIZER_OPTION constants, if the instance already has been created. </simpara> <example> @@ -193,9 +274,49 @@ <![CDATA[require_once "XML/Unserializer.php"; $us = new XML_Unserializer(); $options = array( - 'tagMap' => array( 'util' => 'XML_Util' ), - 'classAttribute' => '_classname' - ); + XML_UNSERIALIZER_OPTION_TAG_MAP => array( 'util' => 'XML_Util' ), + XML_UNSERIALIZER_OPTION_ATTRIBUTE_CLASS => '_classname' +); + +$us->setOptions($options); +$us->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object'); +$result = $us->unserialize('example.xml', true); +]]> + </programlisting> + </example> + </refsect1> + <refsect1 id="package.xml.xml-serializer.xml-unserializer.options.example2"> + <title>Options via $options examples</title> + <simpara> + The following example shows how to set options for XML_Unserializer, + using an $options array. + </simpara> + <example> + <title>Using the constructor</title> + <programlisting role="php"> + <![CDATA[require_once "XML/Unserializer.php"; +$options = array( + 'complexType' => 'array' +); + +$us = new XML_Unserializer($options); +$result = $us->unserialize('example.xml', true); +]]> + </programlisting> + </example> + <simpara> + The following example shows how to set options for XML_Unserializer, + using an $options array, if the instance already has been created. + </simpara> + <example> + <title>Using setOption() and setOptions()</title> + <programlisting role="php"> + <![CDATA[require_once "XML/Unserializer.php"; +$us = new XML_Unserializer(); +$options = array( + 'tagMap' => array( 'util' => 'XML_Util' ), + 'classAttribute' => '_classname' +); $us->setOptions($options); $us->setOption('complexType', 'object');
http://cvs.php.net/viewvc.cgi/peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml?r1=1.5&r2=1.6&diff_format=u Index: peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml diff -u peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml:1.5 peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml:1.6 --- peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml:1.5 Tue May 20 18:47:31 2008 +++ peardoc/en/package/xml/xml-serializer/xml-unserializer/options.xml Fri Sep 19 11:09:25 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry id="package.xml.xml-serializer.xml-unserializer.options"> <refnamediv> <refname>XML_Unserializer Options</refname> @@ -7,9 +7,9 @@ <refsect1 id="package.xml.xml-serializer.xml-unserializer.options.refsect1"> <title>Introduction to options</title> <para> - Options let you influence, how XML_Unserializer treats the parsed XML. - It allows you to define, whether attributes should be parsed, whether - to use associative arrays or objects for complex data types and more. + Options let you influence how XML_Unserializer treats the parsed XML. + It allows you to define whether attributes should be parsed, whether + to use associative arrays or objects for complex data types, and more. </para> <para> Options can be passed as an associative array to the @@ -30,7 +30,8 @@ <tgroup cols="4"> <thead> <row> - <entry>Option</entry> + <entry>XML_UNSERIALIZER_OPTION_ Name</entry> + <entry>Alternate Key for $options Array</entry> <entry>Possible values</entry> <entry>Default</entry> <entry>Description</entry> @@ -38,27 +39,35 @@ </thead> <tbody> <row> + <entry>_COMPLEXTYPE</entry> <entry>complexType</entry> <entry>'array' or 'object'</entry> <entry>'array'</entry> - <entry>Defines, whether nested tags should be returned as associative arrays or objects</entry> + <entry>Defines whether nested tags should be returned as associative arrays or objects.</entry> </row> <row> + <entry>_TAG_AS_CLASSNAME</entry> <entry>tagAsClass</entry> <entry>&true; or &false;</entry> <entry>&true;</entry> <entry> - Defines, whether the tag name should be used as the class name if complexType is set to 'object'. - If no class with the name of the tag exists, that class defined by 'defaultClass' is used. + Defines whether the tag name should be used as the class name + if complexType is set to 'object'. If no class with the name + of the tag exists, the class defined by 'defaultClass' is used. </entry> </row> <row> + <entry>_DEFAULT_CLASS</entry> <entry>defaultClass</entry> <entry>any string</entry> <entry>stdClass</entry> - <entry>Defines the class that is used to create objects, if the complexType option is set to 'object'.</entry> + <entry> + Defines the class that is used to create objects, if the complexType option + is set to 'object'. + </entry> </row> <row> + <entry>_ATTRIBUTE_KEY</entry> <entry>keyAttribute</entry> <entry>any string or array</entry> <entry>'_originalKey'</entry> @@ -70,94 +79,164 @@ </entry> </row> <row> + <entry>_ATTRIBUTE_TYPE</entry> <entry>typeAttribute</entry> <entry>any string</entry> <entry>'_type'</entry> - <entry>If this attribute exists for a tag, the tag content will be converted to the specified type. Possible types are: string, integer, float, boolean, array and object</entry> + <entry> + If this attribute exists for a tag, the tag content will be converted + to the specified type. Possible types are: string, integer, float, + boolean, array, and object. + </entry> </row> <row> + <entry>_ATTRIBUTE_CLASS</entry> <entry>classAttribute</entry> <entry>any string</entry> <entry>'_class'</entry> <entry> - If XML_Unserializer creates an object, it will be an instance of the value specified with the defaultClass - option, unless the tag has the attribute specified in this option. If it is set, the classname stored in - the attribute value will be used. + If XML_Unserializer creates an object, it will be an instance of the value + specified with the defaultClass option, unless the tag has the attribute + specified in this option. If it is set, the classname stored in the attribute + value will be used. </entry> </row> <row> + <entry>_ATTRIBUTES_PARSE</entry> <entry>parseAttributes</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> - <entry>With this option, you may tell XML_Unserializer to also parse the attributes of the tags. The next two options define how to treat the parsed attributes.</entry> + <entry> + With this option, you may tell XML_Unserializer to also parse the attributes of + the tags. The next two options define how to treat the parsed attributes. + </entry> </row> <row> + <entry>_ATTRIBUTES_ARRAYKEY</entry> <entry>attributesArray</entry> <entry>&false; or any string</entry> <entry>&false;</entry> - <entry>If set to false, the attributes will be treated like nested tags. If you set it to a string, a new aray will be created and stored in the parent structure using key you specified in this option</entry> + <entry> + If set to false, the attributes will be treated like nested tags. If you set it to a string, + a new aray will be created and stored in the parent structure using key you specified in this option. + </entry> </row> <row> + <entry>_ATTRIBUTES_PREPEND</entry> <entry>prependAttributes</entry> <entry>any string</entry> <entry>''</entry> - <entry>Allows you to specify a prefix for attribute names.</entry> + <entry> + Allows you to specify a prefix for attribute names. + </entry> </row> <row> + <entry>_CONTENT_KEY</entry> <entry>contentName</entry> <entry>any string</entry> <entry>'_content'</entry> - <entry>If you decide to parse attributes or a tag contains cdata and tags, then the cdata will be stored in the index specified here.</entry> + <entry> + If you decide to parse attributes or a tag contains cdata and tags, + then the cdata will be stored in the index specified here. + </entry> </row> <row> + <entry>_TAG_MAP</entry> <entry>tagMap</entry> <entry>associative array</entry> <entry>array()</entry> - <entry>This allows you to map tag names to PHP classes. The names of the tags have to be in the keys and the values contain the class names to use for each tag.</entry> + <entry> + This allows you to map tag names to PHP classes. The names of the tags have to be + in the keys and the values contain the class names to use for each tag. + </entry> </row> <row> + <entry>_FORCE_ENUM</entry> <entry>forceEnum</entry> <entry>indexed array</entry> <entry>array()</entry> <entry> This allows you to specify a list of tags which will automatically be converted to an indexed array, - independent of the number of repetitions of the tag. This can save you a some if conditions in your - code. + independent of the number of repetitions of the tag. This can save you some IF conditions in your code. </entry> </row> <row> + <entry>_ENCODING_SOURCE</entry> <entry>encoding</entry> - <entry>any valid encoding string</entry> + <entry>any valid encoding string (accepted by XML_Parser)</entry> <entry>null</entry> <entry> Defines the encoding of the original document. </entry> </row> <row> + <entry>_ENCODING_TARGET</entry> <entry>targetEncoding</entry> - <entry>any valid encoding string</entry> + <entry>any valid encoding string (accepted by XML_Parser)</entry> <entry>null</entry> <entry> Defines the target encoding of the resulting data. </entry> </row> <row> + <entry>_DECODE_FUNC</entry> <entry>decodeFunction</entry> <entry>any valid PHP callback</entry> <entry>null</entry> <entry> This option allows you to define a callback function or method, that will be applied to all character data - and attributes in the document before they are stored in the result. This allows you to decode any decoded data - in the XML or convert all content to lowercase. + and attributes in the document before they are stored in the result. This allows you to decode any decoded + data in the XML or convert all content to lowercase. </entry> </row> <row> + <entry>_RETURN_RESULT</entry> <entry>returnResult</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> - If set to &true; <function>XML_Unserializer::unserialize</function> will return the result if the - document could be unserialized instead of just &true;. + If set to &true; <function>XML_Unserializer::unserialize</function> will return the result + if the document could be unserialized instead of just &true;. + </entry> + </row> + <row> + <entry>_WHITESPACE</entry> + <entry>whitespace</entry> + <entry>_WHITESPACE_KEEP, _WHITESPACE_TRIM, _WHITESPACE_NORMALIZE</entry> + <entry>_WHITESPACE_TRIM</entry> + <entry> + Defines how whitespace in the document will be treated: + keep it all, trim it, or normalize it. + </entry> + </row> + <row> + <entry>_IGNORE_KEYS</entry> + <entry>ignoreKeys</entry> + <entry>any array</entry> + <entry>array()</entry> + <entry> + List of tags whose contents will be passed to the parent tag + instead of creating a new tag. + </entry> + </row> + <row> + <entry>_GUESS_TYPES</entry> + <entry>guessTypes</entry> + <entry>&true; or &false;</entry> + <entry>&false;</entry> + <entry> + Whether or not to enable automatic type guessing + for character data and attributes. + </entry> + </row> + <row> + <entry>_OVERRIDE_OPTIONS</entry> + <entry>overrideOptions</entry> + <entry>&true; or &false;</entry> + <entry>&false;</entry> + <entry> + Allows you to override the options already set + on this unserializer object. </entry> </row> </tbody> @@ -166,17 +245,18 @@ </para> </refsect1> <refsect1 id="package.xml.xml-serializer.xml-unserializer.options.example1"> - <title>Options example</title> + <title>Options via XML_UNSERIALIZER_OPTION Constants example</title> <simpara> - The following examples shows how to set options for XML_Unserializer. + The following examples shows how to set options for XML_Unserializer, + using the available XML_UNSERIALIZER_OPTION constants. </simpara> <example> <title>Using the constructor</title> <programlisting role="php"> <![CDATA[require_once "XML/Unserializer.php"; $options = array( - 'complexType' => 'array' - ); + XML_UNSERIALIZER_OPTION_COMPLEXTYPE => 'array' +); $us = new XML_Unserializer($options); $result = $us->unserialize('example.xml', true); @@ -185,6 +265,7 @@ </example> <simpara> The following example shows how to set options for XML_Unserializer, + using the available XML_UNSERIALIZER_OPTION constants, if the instance already has been created. </simpara> <example> @@ -193,9 +274,49 @@ <![CDATA[require_once "XML/Unserializer.php"; $us = new XML_Unserializer(); $options = array( - 'tagMap' => array( 'util' => 'XML_Util' ), - 'classAttribute' => '_classname' - ); + XML_UNSERIALIZER_OPTION_TAG_MAP => array( 'util' => 'XML_Util' ), + XML_UNSERIALIZER_OPTION_ATTRIBUTE_CLASS => '_classname' +); + +$us->setOptions($options); +$us->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object'); +$result = $us->unserialize('example.xml', true); +]]> + </programlisting> + </example> + </refsect1> + <refsect1 id="package.xml.xml-serializer.xml-unserializer.options.example2"> + <title>Options via $options examples</title> + <simpara> + The following example shows how to set options for XML_Unserializer, + using an $options array. + </simpara> + <example> + <title>Using the constructor</title> + <programlisting role="php"> + <![CDATA[require_once "XML/Unserializer.php"; +$options = array( + 'complexType' => 'array' +); + +$us = new XML_Unserializer($options); +$result = $us->unserialize('example.xml', true); +]]> + </programlisting> + </example> + <simpara> + The following example shows how to set options for XML_Unserializer, + using an $options array, if the instance already has been created. + </simpara> + <example> + <title>Using setOption() and setOptions()</title> + <programlisting role="php"> + <![CDATA[require_once "XML/Unserializer.php"; +$us = new XML_Unserializer(); +$options = array( + 'tagMap' => array( 'util' => 'XML_Util' ), + 'classAttribute' => '_classname' +); $us->setOptions($options); $us->setOption('complexType', 'object');