cvs: peardoc /en/package/xml/xml-serializer/xml-serializer options.xml
| From: | Chuck Burgess | Date: | Fri, 19 Sep 2008 17:13:39 +0000 |
| Subject: | cvs: peardoc /en/package/xml/xml-serializer/xml-serializer options.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-11095@lists.php.net to get a copy of this message | ||
ashnazg Fri Sep 19 17:13:39 2008 UTC
Added files:
/peardoc/en/package/xml/xml-serializer/xml-serializer options.xml
Log:
create Options doc for XML_Serializer
http://cvs.php.net/viewvc.cgi/peardoc/en/package/xml/xml-serializer/xml-serializer/options.xml?view=markup&rev=1.1 Index: peardoc/en/package/xml/xml-serializer/xml-serializer/options.xml +++ peardoc/en/package/xml/xml-serializer/xml-serializer/options.xml <!-- $Revision: 1.1 $ --> <refentry id="package.xml.xml-serializer.xml-serializer.options"> <refnamediv> <refname>XML_Serializer Options</refname> <refpurpose>List of all XML_Serializer options</refpurpose> </refnamediv> <refsect1 id="package.xml.xml-serializer.xml-serializer.options.refsect1"> <title>Introduction to options</title> <para> Options let you influence how XML_Serializer treats the parsed data. It allows you to define whether attributes should be created, what to use for indention and linebreaks, and much more. </para> <para> Options can be passed as an associative array to the <link linkend="package.xml.xml-serializer.xml-serializer.xml-serializer">constructor of XML_Serializer</link>. You may also use <link linkend="package.xml.xml-serializer.xml-serializer.setoption"><function>setOption</function></link>, or <link linkend="package.xml.xml-serializer.xml-serializer.setoptions"><function>setOptions</function></link> to set one or more options after the instance of XML_Serializer has been created. </para> </refsect1> <refsect1 id="package.xml.xml-serializer.xml-serializer.options.refsect2"> <title>All available options</title> <para> Here is a list of all options supported by XML_Serializer. </para> <para> <table> <title>XML_Serializer options</title> <tgroup cols="5"> <thead> <row> <entry>XML_SERIALIZER_OPTION_ Name</entry> <entry>Alternate Key for $options Array</entry> <entry>Possible values</entry> <entry>Default</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry>_INDENT</entry> <entry>indent</entry> <entry>any string</entry> <entry>''</entry> <entry> String used for indentation. </entry> </row> <row> <entry>_LINEBREAKS</entry> <entry>linebreak</entry> <entry>any string</entry> <entry>"\n"</entry> <entry> String used for linebreaks. </entry> </row> <row> <entry>_TYPEHINTS</entry> <entry>typeHints</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether or not to enable type hints. </entry> </row> <row> <entry>_XML_DECL_ENABLED</entry> <entry>addDecl</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether or not to add an XML declaration line. </entry> </row> <row> <entry>_XML_ENCODING</entry> <entry>encoding</entry> <entry>any valid encoding</entry> <entry>null</entry> <entry> Encoding to be specified in the XML declaration. </entry> </row> <row> <entry>_DEFAULT_TAG</entry> <entry>defaultTagName</entry> <entry>any string</entry> <entry>'XML_Serializer_Tag'</entry> <entry> Default name for tags. </entry> </row> <row> <entry>_CLASSNAME_AS_TAGNAME</entry> <entry>classAsTagName</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether or not to use classname for objects in indexed arrays. </entry> </row> <row> <entry>_ATTRIBUTE_KEY</entry> <entry>keyAttribute</entry> <entry>any string</entry> <entry>'_originalKey'</entry> <entry> Attribute where original key is stored. </entry> </row> <row> <entry>_ATTRIBUTE_TYPE</entry> <entry>typeAttribute</entry> <entry>any string</entry> <entry>'_type'</entry> <entry> Attribute for type (only if _TYPEHINTS is &true;) </entry> </row> <row> <entry>_ATTRIBUTE_CLASS</entry> <entry>classAttribute</entry> <entry>any string</entry> <entry>'_class'</entry> <entry> Attribute for class (only if _TYPEHINTS is &true;) </entry> </row> <row> <entry>_SCALAR_AS_ATTRIBUTES</entry> <entry>scalarAsAttributes</entry> <entry>&true;, &false;, or array</entry> <entry>&false;</entry> <entry> Scalar values (strings, ints,..) will be serialized as attributes. </entry> </row> <row> <entry>_PREPEND_ATTRIBUTES</entry> <entry>prependAttributes</entry> <entry>any string</entry> <entry>''</entry> <entry> Prepend string for attributes. </entry> </row> <row> <entry>_INDENT_ATTRIBUTES</entry> <entry>indentAttributes</entry> <entry>&true;,&false;, or '_auto'</entry> <entry>&false;</entry> <entry> Indent the attributes. If set to '_auto', it will indent attributes so they all start at the same column. </entry> </row> <row> <entry>_MODE</entry> <entry>mode</entry> <entry>OPTIONs _DEFAULT or _SIMPLEXML</entry> <entry>_DEFAULT</entry> <entry> The serializing mode to use when serializing indexed arrays. _SIMPLEXML will use the parent name as the tag name. </entry> </row> <row> <entry>_DOCTYPE_ENABLED</entry> <entry>addDoctype</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether or not to add a DOCTYPE declaration. </entry> </row> <row> <entry>_DOCTYPE</entry> <entry>doctype</entry> <entry>string, or array with 'id' and 'url'</entry> <entry>''</entry> <entry> Points to the document declaration file. </entry> </row> <row> <entry>_ROOT_NAME</entry> <entry>rootName</entry> <entry>string</entry> <entry>null</entry> <entry> Name of the root tag. </entry> </row> <row> <entry>_ROOT_ATTRIBS</entry> <entry>rootAttributes</entry> <entry>array</entry> <entry>array()</entry> <entry> Attributes of the root tag. </entry> </row> <row> <entry>_ATTRIBUTES_KEY</entry> <entry>attributesArray</entry> <entry>string</entry> <entry>''</entry> <entry> All values in this key will be treated as attributes. </entry> </row> <row> <entry>_CONTENT_KEY</entry> <entry>contentName</entry> <entry>string</entry> <entry>null</entry> <entry> This value will be used directly as content, instead of creating a new tag. It may only be used in conjunction with _ATTRIBUTES_KEY. </entry> </row> <row> <entry>_COMMENT_KEY</entry> <entry>commentName</entry> <entry>string</entry> <entry>null</entry> <entry> This value will be used in a comment rather than in a tag. </entry> </row> <row> <entry>_TAGMAP</entry> <entry>tagMap</entry> <entry>array</entry> <entry>array()</entry> <entry> Tag names that will be changed. It maps keys and property names to different tag names. </entry> </row> <row> <entry>_ENCODE_FUNC</entry> <entry>encodeFunction</entry> <entry>any valid PHP callback</entry> <entry>null</entry> <entry> Function that will be applied before serializing. </entry> </row> <row> <entry>_NAMESPACE</entry> <entry>namespace</entry> <entry>string</entry> <entry>null</entry> <entry> Namespace to use for the document. </entry> </row> <row> <entry>_ENTITIES</entry> <entry>replaceEntities</entry> <entry>OPTIONs _XML, _NONE, _HTML, or _XML_REQUIRED</entry> <entry>_XML</entry> <entry> Type of entities to replace. </entry> </row> <row> <entry>_RETURN_RESULT</entry> <entry>returnResult</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether to return the result of the serialization. </entry> </row> <row> <entry>_IGNORE_NULL</entry> <entry>ignoreNull</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether to ignore properties that are set to NULL. </entry> </row> <row> <entry>_CDATA_SECTIONS</entry> <entry>cdata</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether to use CDATA sections for character data. </entry> </row> </tbody> </tgroup> </table> </para> </refsect1> <refsect1 id="package.xml.xml-serializer.xml-serializer.options.example1"> <title>Options via XML_SERIALIZER_OPTION Constants example</title> <simpara> The following examples shows how to set options for XML_Serializer, using the available XML_SERIALIZER_OPTION constants. </simpara> <example> <title>Using the constructor</title> <programlisting role="php"> <![CDATA[require_once "XML/Serializer.php"; $options = array( XML_SERIALIZER_OPTION_INDENT => ' ' ); $ser = new XML_Serializer($options); $result = $ser->serialize(array('key' => 'value')); ]]> </programlisting> </example> <simpara> The following example shows how to set options for XML_Serializer, using the available XML_SERIALIZER_OPTION constants, if the instance already has been created. </simpara> <example> <title>Using setOption() and setOptions()</title> <programlisting role="php"> <![CDATA[require_once "XML/Serializer.php"; $us = new XML_Serializer(); $options = array( XML_SERIALIZER_OPTION_TAGMAP => array( 'id' => 'identifier' ), XML_SERIALIZER_OPTION_SCALAR_AS_ATTRIBUTES => true ); $ser->setOptions($options); $ser->setOption(XML_SERIALIZER_OPTION_DOCTYPE_ENABLED, true); $result = $ser->serialize(array('key' => 'value')); ]]> </programlisting> </example> </refsect1> <refsect1 id="package.xml.xml-serializer.xml-serializer.options.example2"> <title>Options via $options examples</title> <simpara> The following example shows how to set options for XML_Serializer, using an $options array. </simpara> <example> <title>Using the constructor</title> <programlisting role="php"> <![CDATA[require_once "XML/Unserializer.php"; $options = array( 'indent' => ' ' ); $ser = new XML_Serializer($options); $result = $ser->serialize(array('key' => 'value')); ]]> </programlisting> </example> <simpara> The following example shows how to set options for XML_Serializer, 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_Serializer(); $options = array( 'tagMap' => array( 'id' => 'identifer' ), 'scalarAsAttributes' => true ); $ser->setOptions($options); $ser->setOption('addDoctype', true); $result = $ser->serialize(array('key' => 'value')); ]]> </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 -->
http://cvs.php.net/viewvc.cgi/peardoc/en/package/xml/xml-serializer/xml-serializer/options.xml?view=markup&rev=1.1 Index: peardoc/en/package/xml/xml-serializer/xml-serializer/options.xml +++ peardoc/en/package/xml/xml-serializer/xml-serializer/options.xml <!-- $Revision: 1.1 $ --> <refentry id="package.xml.xml-serializer.xml-serializer.options"> <refnamediv> <refname>XML_Serializer Options</refname> <refpurpose>List of all XML_Serializer options</refpurpose> </refnamediv> <refsect1 id="package.xml.xml-serializer.xml-serializer.options.refsect1"> <title>Introduction to options</title> <para> Options let you influence how XML_Serializer treats the parsed data. It allows you to define whether attributes should be created, what to use for indention and linebreaks, and much more. </para> <para> Options can be passed as an associative array to the <link linkend="package.xml.xml-serializer.xml-serializer.xml-serializer">constructor of XML_Serializer</link>. You may also use <link linkend="package.xml.xml-serializer.xml-serializer.setoption"><function>setOption</function></link>, or <link linkend="package.xml.xml-serializer.xml-serializer.setoptions"><function>setOptions</function></link> to set one or more options after the instance of XML_Serializer has been created. </para> </refsect1> <refsect1 id="package.xml.xml-serializer.xml-serializer.options.refsect2"> <title>All available options</title> <para> Here is a list of all options supported by XML_Serializer. </para> <para> <table> <title>XML_Serializer options</title> <tgroup cols="5"> <thead> <row> <entry>XML_SERIALIZER_OPTION_ Name</entry> <entry>Alternate Key for $options Array</entry> <entry>Possible values</entry> <entry>Default</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry>_INDENT</entry> <entry>indent</entry> <entry>any string</entry> <entry>''</entry> <entry> String used for indentation. </entry> </row> <row> <entry>_LINEBREAKS</entry> <entry>linebreak</entry> <entry>any string</entry> <entry>"\n"</entry> <entry> String used for linebreaks. </entry> </row> <row> <entry>_TYPEHINTS</entry> <entry>typeHints</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether or not to enable type hints. </entry> </row> <row> <entry>_XML_DECL_ENABLED</entry> <entry>addDecl</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether or not to add an XML declaration line. </entry> </row> <row> <entry>_XML_ENCODING</entry> <entry>encoding</entry> <entry>any valid encoding</entry> <entry>null</entry> <entry> Encoding to be specified in the XML declaration. </entry> </row> <row> <entry>_DEFAULT_TAG</entry> <entry>defaultTagName</entry> <entry>any string</entry> <entry>'XML_Serializer_Tag'</entry> <entry> Default name for tags. </entry> </row> <row> <entry>_CLASSNAME_AS_TAGNAME</entry> <entry>classAsTagName</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether or not to use classname for objects in indexed arrays. </entry> </row> <row> <entry>_ATTRIBUTE_KEY</entry> <entry>keyAttribute</entry> <entry>any string</entry> <entry>'_originalKey'</entry> <entry> Attribute where original key is stored. </entry> </row> <row> <entry>_ATTRIBUTE_TYPE</entry> <entry>typeAttribute</entry> <entry>any string</entry> <entry>'_type'</entry> <entry> Attribute for type (only if _TYPEHINTS is &true;) </entry> </row> <row> <entry>_ATTRIBUTE_CLASS</entry> <entry>classAttribute</entry> <entry>any string</entry> <entry>'_class'</entry> <entry> Attribute for class (only if _TYPEHINTS is &true;) </entry> </row> <row> <entry>_SCALAR_AS_ATTRIBUTES</entry> <entry>scalarAsAttributes</entry> <entry>&true;, &false;, or array</entry> <entry>&false;</entry> <entry> Scalar values (strings, ints,..) will be serialized as attributes. </entry> </row> <row> <entry>_PREPEND_ATTRIBUTES</entry> <entry>prependAttributes</entry> <entry>any string</entry> <entry>''</entry> <entry> Prepend string for attributes. </entry> </row> <row> <entry>_INDENT_ATTRIBUTES</entry> <entry>indentAttributes</entry> <entry>&true;,&false;, or '_auto'</entry> <entry>&false;</entry> <entry> Indent the attributes. If set to '_auto', it will indent attributes so they all start at the same column. </entry> </row> <row> <entry>_MODE</entry> <entry>mode</entry> <entry>OPTIONs _DEFAULT or _SIMPLEXML</entry> <entry>_DEFAULT</entry> <entry> The serializing mode to use when serializing indexed arrays. _SIMPLEXML will use the parent name as the tag name. </entry> </row> <row> <entry>_DOCTYPE_ENABLED</entry> <entry>addDoctype</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether or not to add a DOCTYPE declaration. </entry> </row> <row> <entry>_DOCTYPE</entry> <entry>doctype</entry> <entry>string, or array with 'id' and 'url'</entry> <entry>''</entry> <entry> Points to the document declaration file. </entry> </row> <row> <entry>_ROOT_NAME</entry> <entry>rootName</entry> <entry>string</entry> <entry>null</entry> <entry> Name of the root tag. </entry> </row> <row> <entry>_ROOT_ATTRIBS</entry> <entry>rootAttributes</entry> <entry>array</entry> <entry>array()</entry> <entry> Attributes of the root tag. </entry> </row> <row> <entry>_ATTRIBUTES_KEY</entry> <entry>attributesArray</entry> <entry>string</entry> <entry>''</entry> <entry> All values in this key will be treated as attributes. </entry> </row> <row> <entry>_CONTENT_KEY</entry> <entry>contentName</entry> <entry>string</entry> <entry>null</entry> <entry> This value will be used directly as content, instead of creating a new tag. It may only be used in conjunction with _ATTRIBUTES_KEY. </entry> </row> <row> <entry>_COMMENT_KEY</entry> <entry>commentName</entry> <entry>string</entry> <entry>null</entry> <entry> This value will be used in a comment rather than in a tag. </entry> </row> <row> <entry>_TAGMAP</entry> <entry>tagMap</entry> <entry>array</entry> <entry>array()</entry> <entry> Tag names that will be changed. It maps keys and property names to different tag names. </entry> </row> <row> <entry>_ENCODE_FUNC</entry> <entry>encodeFunction</entry> <entry>any valid PHP callback</entry> <entry>null</entry> <entry> Function that will be applied before serializing. </entry> </row> <row> <entry>_NAMESPACE</entry> <entry>namespace</entry> <entry>string</entry> <entry>null</entry> <entry> Namespace to use for the document. </entry> </row> <row> <entry>_ENTITIES</entry> <entry>replaceEntities</entry> <entry>OPTIONs _XML, _NONE, _HTML, or _XML_REQUIRED</entry> <entry>_XML</entry> <entry> Type of entities to replace. </entry> </row> <row> <entry>_RETURN_RESULT</entry> <entry>returnResult</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether to return the result of the serialization. </entry> </row> <row> <entry>_IGNORE_NULL</entry> <entry>ignoreNull</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether to ignore properties that are set to NULL. </entry> </row> <row> <entry>_CDATA_SECTIONS</entry> <entry>cdata</entry> <entry>&true; or &false;</entry> <entry>&false;</entry> <entry> Whether to use CDATA sections for character data. </entry> </row> </tbody> </tgroup> </table> </para> </refsect1> <refsect1 id="package.xml.xml-serializer.xml-serializer.options.example1"> <title>Options via XML_SERIALIZER_OPTION Constants example</title> <simpara> The following examples shows how to set options for XML_Serializer, using the available XML_SERIALIZER_OPTION constants. </simpara> <example> <title>Using the constructor</title> <programlisting role="php"> <![CDATA[require_once "XML/Serializer.php"; $options = array( XML_SERIALIZER_OPTION_INDENT => ' ' ); $ser = new XML_Serializer($options); $result = $ser->serialize(array('key' => 'value')); ]]> </programlisting> </example> <simpara> The following example shows how to set options for XML_Serializer, using the available XML_SERIALIZER_OPTION constants, if the instance already has been created. </simpara> <example> <title>Using setOption() and setOptions()</title> <programlisting role="php"> <![CDATA[require_once "XML/Serializer.php"; $us = new XML_Serializer(); $options = array( XML_SERIALIZER_OPTION_TAGMAP => array( 'id' => 'identifier' ), XML_SERIALIZER_OPTION_SCALAR_AS_ATTRIBUTES => true ); $ser->setOptions($options); $ser->setOption(XML_SERIALIZER_OPTION_DOCTYPE_ENABLED, true); $result = $ser->serialize(array('key' => 'value')); ]]> </programlisting> </example> </refsect1> <refsect1 id="package.xml.xml-serializer.xml-serializer.options.example2"> <title>Options via $options examples</title> <simpara> The following example shows how to set options for XML_Serializer, using an $options array. </simpara> <example> <title>Using the constructor</title> <programlisting role="php"> <![CDATA[require_once "XML/Unserializer.php"; $options = array( 'indent' => ' ' ); $ser = new XML_Serializer($options); $result = $ser->serialize(array('key' => 'value')); ]]> </programlisting> </example> <simpara> The following example shows how to set options for XML_Serializer, 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_Serializer(); $options = array( 'tagMap' => array( 'id' => 'identifer' ), 'scalarAsAttributes' => true ); $ser->setOptions($options); $ser->setOption('addDoctype', true); $result = $ser->serialize(array('key' => 'value')); ]]> </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 -->