|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<refentry xml:id="dom-attr.rename" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 3 | + <refnamediv> |
| 4 | + <refname>Dom\Attr::rename</refname> |
| 5 | + <refpurpose>Changes the qualified name or namespace of an attribute</refpurpose> |
| 6 | + </refnamediv> |
| 7 | + |
| 8 | + <refsect1 role="description"> |
| 9 | + &reftitle.description; |
| 10 | + <methodsynopsis role="Dom\\Attr"> |
| 11 | + <modifier>public</modifier> <type>void</type><methodname>Dom\Attr::rename</methodname> |
| 12 | + <methodparam><type class="union"><type>string</type><type>null</type></type><parameter>namespaceURI</parameter></methodparam> |
| 13 | + <methodparam><type>string</type><parameter>qualifiedName</parameter></methodparam> |
| 14 | + </methodsynopsis> |
| 15 | + <simpara> |
| 16 | + This method changes the qualified name or namespace of an attribute. |
| 17 | + </simpara> |
| 18 | + </refsect1> |
| 19 | + |
| 20 | + <refsect1 role="parameters"> |
| 21 | + &reftitle.parameters; |
| 22 | + <para> |
| 23 | + <variablelist> |
| 24 | + <varlistentry> |
| 25 | + <term><parameter>namespaceURI</parameter></term> |
| 26 | + <listitem> |
| 27 | + <simpara> |
| 28 | + The new namespace <acronym>URI</acronym> of the attribute. |
| 29 | + </simpara> |
| 30 | + </listitem> |
| 31 | + </varlistentry> |
| 32 | + <varlistentry> |
| 33 | + <term><parameter>qualifiedName</parameter></term> |
| 34 | + <listitem> |
| 35 | + <simpara> |
| 36 | + The new qualified name of the attribute. |
| 37 | + </simpara> |
| 38 | + </listitem> |
| 39 | + </varlistentry> |
| 40 | + </variablelist> |
| 41 | + </para> |
| 42 | + </refsect1> |
| 43 | + |
| 44 | + <refsect1 role="returnvalues"> |
| 45 | + &reftitle.returnvalues; |
| 46 | + <para> |
| 47 | + &return.void; |
| 48 | + </para> |
| 49 | + </refsect1> |
| 50 | + |
| 51 | + <refsect1 role="errors"> |
| 52 | + &reftitle.errors; |
| 53 | + <variablelist> |
| 54 | + <varlistentry> |
| 55 | + <term><classname>DOMException</classname> with code <constant>Dom\NAMESPACE_ERR</constant></term> |
| 56 | + <listitem> |
| 57 | + <simpara> |
| 58 | + Raised if there is an error with the namespace, as determined by |
| 59 | + <parameter>qualifiedName</parameter>. |
| 60 | + </simpara> |
| 61 | + </listitem> |
| 62 | + </varlistentry> |
| 63 | + <varlistentry> |
| 64 | + <term><classname>DOMException</classname> with code <constant>Dom\INVALID_MODIFICATION_ERR</constant></term> |
| 65 | + <listitem> |
| 66 | + <simpara> |
| 67 | + Raised if there already exists an attribute in the element with the same |
| 68 | + qualified name. |
| 69 | + </simpara> |
| 70 | + </listitem> |
| 71 | + </varlistentry> |
| 72 | + </variablelist> |
| 73 | + </refsect1> |
| 74 | + |
| 75 | + <refsect1 role="examples"> |
| 76 | + &reftitle.examples; |
| 77 | + <example xml:id="dom-attr.rename.example.basic"> |
| 78 | + <title><methodname>Dom\Attr::rename</methodname> example to change both the namespace and qualified name</title> |
| 79 | + <simpara> |
| 80 | + This changes the qualified name of <literal>my-attr</literal> to |
| 81 | + <literal>my-new-attr</literal> and also changes its namespace to |
| 82 | + <literal>urn:my-ns</literal>. |
| 83 | + </simpara> |
| 84 | + <programlisting role="php"> |
| 85 | +<![CDATA[ |
| 86 | +<?php |
| 87 | +
|
| 88 | +$doc = Dom\XMLDocument::createFromString('<root my-attr="value"/>'); |
| 89 | +
|
| 90 | +$root = $doc->documentElement; |
| 91 | +$attribute = $root->attributes['my-attr']; |
| 92 | +$attribute->rename('urn:my-ns', 'my-new-attr'); |
| 93 | +
|
| 94 | +echo $doc->saveXml(); |
| 95 | +
|
| 96 | +?> |
| 97 | +]]> |
| 98 | + </programlisting> |
| 99 | + &example.outputs; |
| 100 | + <screen> |
| 101 | +<![CDATA[ |
| 102 | +<?xml version="1.0" encoding="UTF-8"?> |
| 103 | +<root xmlns:ns1="urn:my-ns" ns1:my-new-attr="value"/> |
| 104 | +]]> |
| 105 | + </screen> |
| 106 | + </example> |
| 107 | + <example xml:id="dom-attr.rename.example.only-name"> |
| 108 | + <title><methodname>Dom\Attr::rename</methodname> example to change only the qualified name</title> |
| 109 | + <simpara> |
| 110 | + This only changes the qualified name of <literal>my-attr</literal> |
| 111 | + and keeps the namespace <acronym>URI</acronym> the same. |
| 112 | + </simpara> |
| 113 | + <programlisting role="php"> |
| 114 | +<![CDATA[ |
| 115 | +<?php |
| 116 | +
|
| 117 | +$doc = Dom\XMLDocument::createFromString('<root my-attr="value"/>'); |
| 118 | +
|
| 119 | +$root = $doc->documentElement; |
| 120 | +$attribute = $root->attributes['my-attr']; |
| 121 | +$attribute->rename($attribute->namespaceURI, 'my-new-attr'); |
| 122 | +
|
| 123 | +echo $doc->saveXml(); |
| 124 | +
|
| 125 | +?> |
| 126 | +]]> |
| 127 | + </programlisting> |
| 128 | + &example.outputs; |
| 129 | + <screen> |
| 130 | +<![CDATA[ |
| 131 | +<?xml version="1.0" encoding="UTF-8"?> |
| 132 | +<root my-new-attr="value"/> |
| 133 | +]]> |
| 134 | + </screen> |
| 135 | + </example> |
| 136 | + </refsect1> |
| 137 | + |
| 138 | + <refsect1 role="notes"> |
| 139 | + &reftitle.notes; |
| 140 | + <note> |
| 141 | + <simpara> |
| 142 | + It is sometimes necessary to change |
| 143 | + the qualified name and namespace <acronym>URI</acronym> together in one |
| 144 | + step to not break any namespace rules. |
| 145 | + </simpara> |
| 146 | + </note> |
| 147 | + </refsect1> |
| 148 | + |
| 149 | + <refsect1 role="seealso"> |
| 150 | + &reftitle.seealso; |
| 151 | + <simplelist> |
| 152 | + <member><methodname>Dom\Element::rename</methodname></member> |
| 153 | + </simplelist> |
| 154 | + </refsect1> |
| 155 | + |
| 156 | +</refentry> |
| 157 | +<!-- Keep this comment at the end of the file |
| 158 | +Local variables: |
| 159 | +mode: sgml |
| 160 | +sgml-omittag:t |
| 161 | +sgml-shorttag:t |
| 162 | +sgml-minimize-attributes:nil |
| 163 | +sgml-always-quote-attributes:t |
| 164 | +sgml-indent-step:1 |
| 165 | +sgml-indent-data:t |
| 166 | +indent-tabs-mode:nil |
| 167 | +sgml-parent-document:nil |
| 168 | +sgml-default-dtd-file:"~/.phpdoc/manual.ced" |
| 169 | +sgml-exposed-tags:nil |
| 170 | +sgml-local-catalogs:nil |
| 171 | +sgml-local-ecat-files:nil |
| 172 | +End: |
| 173 | +vim600: syn=xml fen fdm=syntax fdl=2 si |
| 174 | +vim: et tw=78 syn=sgml |
| 175 | +vi: ts=1 sw=1 |
| 176 | +--> |
0 commit comments