AllowXmlAttribute (XmlDoc property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 23: Line 23:
<li>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.
<li>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.
</ul>
</ul>
Therefore, you should use care with attribute names: using an attribute name which starts with "xml" makes you vulnerable to a ch ange in the standards that would leave your document incompatible with them.
Therefore, you should use care with attribute names: using an attribute name which starts with "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 AddAttribute method to add an attribute with a name that starts with "xml".  However, as shown in the [[#Adding an attribute to an element|"Adding an attribute to an element"]] example below, it is easy to use the <var>[[LoadXml_(XmlDoc/XmlNode_function)|LoadXml]]</var> method to accomplish this.
'''Note:''' This property does not allow the AddAttribute method to add an attribute with a name that starts with "xml".  However, as shown in the [[#Adding an attribute to an element|"Adding an attribute to an element"]] example below, it is easy to use the <var>[[LoadXml_(XmlDoc/XmlNode_function)|LoadXml]]</var> method to accomplish this.
==Examples==
==Examples==
===Displaying the property===
===Displaying the property===

Revision as of 15:48, 13 May 2011

May Attribute names begin with "xml"? (XmlDoc class)

[Introduced in Sirius Mods 7.9]

The AllowXmlAttribute property indicates whether or not the method object XmlDoc allows the deserialization of an XML document that contains Attributes that begin with the character sequence xml (regardless of case), other than the standard prefixes of "xml" or "xmlns".

A Boolean value of True allows such deserializations. The default value, False, cancels the request if such a deserialization is attempted.


Syntax

%currentBoolean = doc:AllowXmlAttribute doc:AllowXmlAttribute = newBoolean

Syntax terms

%currentBoolean The Boolean enumeration value of doc's AllowXmlAttribute 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 AllowXmlAttribute property.

Usage notes

  • Deserializing Attributes 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 attribute names: using an attribute name which starts with "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 AddAttribute method to add an attribute with a name that starts with "xml". However, as shown in the "Adding an attribute to an element" example below, it is easy to use the LoadXml method to accomplish this.

    Examples

    Displaying the property

    The following example obtains the string value of the AllowXmlAttribute property:

    %str = %doc:AllowXmlAttribute:ToString

    Taking advantage of the implicit-ToString feature, you can print this value directly by using this:

    print %doc:AllowXmlAttribute

    Deserializing an entire XML document

    The following request:

    begin %d object xmlDoc auto new %d:allowXmlAttribute = true %d:loadXml('<t xmlAtt="x">Test</t>') printText{~} is {%d:allowXmlAttribute} end

    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 attribute to an element

    The following request:

    begin %d object xmlDoc auto new %n1 object xmlNode %n2 object xmlNode %n1 = %d:addElement('xyz') %d:allowXmlAttribute = true %n1:LoadXml('<junk xmlAtt="abc"/>') %n2 = %n1:SelectSingleNode('*/@*') %n1:AddSubtree(%n2) %n1:DeleteSubtree('*') %d:print end

    prints

    <xyz xmlAtt="abc"/>

    Request-Cancellation Errors (for set method)

    • newBoolean is an invalid value (ie: not a Boolean value).

    See also