AllowXmlElement (XmlDoc property): Difference between revisions
m (edits, tags and links) |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{Template:XmlDoc:AllowXmlElement subtitle}} | {{Template:XmlDoc:AllowXmlElement subtitle}} | ||
The <var>AllowXmlElement </var> property indicates whether or not the method object <var>XmlDoc</var> allows the deserialization of an XML document that contains Elements that begin with the character sequence <code>xml</code> (regardless of case). | The <var>AllowXmlElement </var> property indicates whether or not the method object <var>XmlDoc</var> allows the deserialization of an XML document that contains Elements that begin with the character sequence <code>xml</code> (regardless of case). | ||
A [[Boolean]] value of < | A <var>[[Boolean]]</var> value of <var>True</var> allows such deserializations. The default value, <code>False</code>, cancels the request if such a deserialization is attempted. | ||
==Syntax== | ==Syntax== | ||
{{Template:XmlDoc:AllowXmlElement syntax}} | {{Template:XmlDoc:AllowXmlElement syntax}} | ||
Line 15: | Line 15: | ||
<td>The <var>Boolean</var> value to assign to <var class="term">doc</var>'s <var>AllowXmlElement</var> property.</td></tr> | <td>The <var>Boolean</var> value to assign to <var class="term">doc</var>'s <var>AllowXmlElement</var> property.</td></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
Line 23: | Line 23: | ||
</ul> | </ul> | ||
Therefore, you should use care with element names: using an element name such as <code>XML</code> makes you vulnerable to a change in the standards that would leave your document incompatible with them. | Therefore, you should use care with element names: using an element name such as <code>XML</code> makes you vulnerable to a change in the standards that would leave your document incompatible with them. | ||
'''Note:''' This property does not allow the AddElement method to add an element with a name that starts with "xml". However, as shown the | '''Note:''' This property does not allow the <var>[[AddElement_(XmlDoc/XmlNode_function)|AddElement]]</var> method to add an element with a name that starts with "xml". However, as shown in the [[#Adding an element to a document|"Adding an element to a document"]] example below, it is easy to use the <var>[[LoadXml_(XmlDoc/XmlNode_function)|LoadXml]]</var> method to accomplish this. | ||
<li>The <var>AllowXmlElement</var> method was introduced in <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.3, and it has also been provided by maintenance for Version 6.8 and Version 7.2. | <li>The <var>AllowXmlElement</var> method was introduced in <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.3, and it has also been provided by maintenance for Version 6.8 and Version 7.2. | ||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
===Displaying the property=== | |||
The following example obtains the string value of the <var>AllowXmlElement</var> property: | |||
<p class="code">%str = %doc: | <p class="code">%str = %doc:AllowXmlElement:ToString | ||
</p> | </p> | ||
Taking advantage of the implicit-[[ToString]] feature | Taking advantage of the implicit-[[ToString]] feature, you can print this value directly by using this: | ||
<p class="code">print %doc: | <p class="code">print %doc:AllowXmlElement | ||
</p> | </p> | ||
===Deserializing an entire XML document=== | |||
The following request: | |||
<p class="code">begin | <p class="code">begin | ||
%d object xmlDoc auto new | %d object xmlDoc auto new | ||
Line 49: | Line 50: | ||
'''Note:''' Using the PrintText statement is described in <var>[[PrintText statement|printText]]</var>. | '''Note:''' Using the PrintText statement is described in <var>[[PrintText statement|printText]]</var>. | ||
Printing an enumeration value without a <var>ToString</var> method is described in the first "Note" in [[??]] refid=crenums.. | Printing an enumeration value without a <var>ToString</var> method is described in the first "Note" in [[??]] refid=crenums.. | ||
</ | ===Adding an element to a document=== | ||
<li>The following request: | |||
<p class="code">begin | |||
%d object xmlDoc auto new | |||
%n object xmlNode | |||
%n = %d:addElement('xyz') | |||
%d:allowXmlElement = true | |||
%n:LoadXml('<xmlElt/>') | |||
%d:print | |||
end | |||
</p> | |||
prints | |||
<p class="output"><nowiki><xyz> | |||
<xmlElt/> | |||
</xyz> | |||
</nowik></p> | |||
==Request-Cancellation Errors (for set method)== | ==Request-Cancellation Errors (for set method)== | ||
<ul> | <ul> | ||
<li><var class="term">newBoolean</var> is an invalid value (ie: not a [[Boolean Enumeration]]). | <li><var class="term">newBoolean</var> is an invalid value (ie: not a <var>[[Boolean Enumeration|Boolean]]</var> value). | ||
</ul> | </ul> | ||
==See also== | ==See also== | ||
{{Template:XmlDoc:AllowXmlElement footer}} | {{Template:XmlDoc:AllowXmlElement footer}} |
Revision as of 15:58, 13 May 2011
May Element names begin with "xml"? (XmlDoc class)
The AllowXmlElement property indicates whether or not the method object XmlDoc allows the deserialization of an XML document that contains Elements that begin with the character sequence xml
(regardless of case).
A Boolean value of True allows such deserializations. The default value, False
, cancels the request if such a deserialization is attempted.
Syntax
%currentBoolean = doc:AllowXmlElement doc:AllowXmlElement = newBoolean
Syntax terms
%currentBoolean | The Boolean enumeration value of doc's AllowXmlElement property. For more information about these enumerations, see Using Boolean enumerations. |
---|---|
doc | An XmlDoc object expression. |
newBoolean | The Boolean value to assign to doc's AllowXmlElement property. |
Usage notes
- Deserializing Elements whose name begins with "xml" was restricted due to the following excerpt from the XML standard:
- Names beginning with the string "xml", or any string which would match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization in this or future versions of this specification.
Therefore, you should use care with element names: using an element name such as
XML
makes you vulnerable to a change in the standards that would leave your document incompatible with them.Note: This property does not allow the AddElement method to add an element with a name that starts with "xml". However, as shown in the "Adding an element to a document" example below, it is easy to use the LoadXml method to accomplish this.
- The AllowXmlElement method was introduced in "Sirius Mods" Version 7.3, and it has also been provided by maintenance for Version 6.8 and Version 7.2.
Examples
Displaying the property
The following example obtains the string value of the AllowXmlElement property:
%str = %doc:AllowXmlElement:ToString
Taking advantage of the implicit-ToString feature, you can print this value directly by using this:
print %doc:AllowXmlElement
Deserializing an entire XML document
The following request:
begin %d object xmlDoc auto new %d:AllowXmlElement = true %d:loadXml('<t>Test<xmlnode></xmlnode></t>') printText{~} is {%d:allowXmlElement} end
prints
%d:allowXmlElement is True
Note: Using the PrintText statement is described in printText. Printing an enumeration value without a ToString method is described in the first "Note" in ?? refid=crenums..
Adding an element to a document
begin %d object xmlDoc auto new %n object xmlNode %n = %d:addElement('xyz') %d:allowXmlElement = true %n:LoadXml('<xmlElt/>') %d:print end
prints
<nowiki><xyz> <xmlElt/> </xyz> </nowik>
Request-Cancellation Errors (for set method)
- newBoolean is an invalid value (ie: not a Boolean value).