InvalidChar (XmlDoc property): Difference between revisions
m (→Syntax terms) |
m (edits, tags and links) |
||
Line 1: | Line 1: | ||
{{Template:XmlDoc:InvalidChar subtitle}} | {{Template:XmlDoc:InvalidChar subtitle}} | ||
''' | '''NOTE:''' As described in the [[#Usage notes|Usage notes]] below, the <var>InvalidChar</var> property was deprecated as of <var class="product">[[Sirius Mods]]</var> Version 7.3, and it is '''invalid''' as of <var class="product">Sirius Mods</var> Version 7.6. | ||
As described in the [[#Usage notes|Usage notes]] | |||
below, the <var>InvalidChar</var> property was deprecated as of <var class="product">Sirius Mods</var> | |||
and it is '''invalid''' as of <var class="product">Sirius Mods</var> | |||
Prior to <var class="product">Sirius Mods</var> 7.3, you use this property to control whether a string | Prior to <var class="product">Sirius Mods</var> Version 7.3, you use this property to control whether a string containing an invalid XML character can be added to an <var>XmlDoc</var>. A character is invalid if it is not one of the valid characters specified in the W3C Recommendation for XML (see [[XML_processing_in_Janus_SOAP#Char_and_Reference|"Char and Reference"]]). Prior to the introduction of this <var>InvalidChar</var> property (<var class="product">Sirius Mods</var> Version 6.8), <var class="product">[[Janus SOAP]]</var> did not permit such characters in an <var>XmlDoc</var>. An example is the “control character” X'01'. | ||
containing an invalid XML character can be added to an <var>XmlDoc</var>. | |||
A character is invalid if it is not one of the valid characters specified in | |||
the W3C Recommendation for XML (see [[ | |||
Prior to the introduction of this <var>InvalidChar</var> property (<var class="product">Sirius Mods</var> | |||
[[Janus SOAP]] did not permit such characters in an <var>XmlDoc</var>. | |||
An example is the & | |||
This property is designed to let | This property is designed to let you use an <var>XmlDoc</var> to contain data that is '''not''' exchanged with other applications, yet whose content cannot be controlled by your application. If you present such a document to a W3C-compliant XML processor, it will be rejected as erroneous. | ||
you use an <var>XmlDoc</var> to contain data that is '''not''' exchanged with other | |||
applications, yet whose content cannot be controlled by your application. | |||
If you present such a document | |||
to a W3C-compliant XML processor, it will be rejected as erroneous. | |||
==Syntax== | ==Syntax== | ||
{{Template:XmlDoc:InvalidChar syntax}} | {{Template:XmlDoc:InvalidChar syntax}} | ||
Line 24: | Line 12: | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%currentXmlInvalidChar</th> | <tr><th>%currentXmlInvalidChar</th> | ||
<td>The <var>XmlInvalidChar</var> enumeration value (see below) of <var class="term">doc</var>'s <var>InvalidChar</var> property. Valid values are < | <td>The <var>XmlInvalidChar</var> enumeration value (see below) of <var class="term">doc</var>'s <var>InvalidChar</var> property. Valid values are <code>Allow</code> and <code>Disallow</code>.</td></tr> | ||
<tr><th>doc</th> | <tr><th>doc</th> | ||
<td>An <var>XmlDoc</var> object expression. </td></tr> | <td>An <var>XmlDoc</var> object expression.</td></tr> | ||
<tr><th><var>newXMLInvalidChar</var></th> | <tr><th><var>newXMLInvalidChar</var></th> | ||
<td>The <var>XmlInvalidChar</var> enumeration value (< | <td>The <var>XmlInvalidChar</var> enumeration value (<code>Allow</code> or <code>Disallow</code>) to assign to <var class="term">doc</var>'s <var>InvalidChar</var> property.</td></tr> | ||
</table> | </table> | ||
===XmlInvalidChar enumeration=== | |||
The values of the <var>XmlInvalidChar</var> property are of type <var>[[Enumerations|Enumeration]]</var> <var>XmlInvalidChar</var>: | The values of the <var>XmlInvalidChar</var> property are of type <var>[[Enumerations|Enumeration]]</var> <var>XmlInvalidChar</var>: | ||
<table> | <table> | ||
Line 42: | Line 31: | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>Pror to <var class="product">Sirius Mods</var> | <li>Pror to <var class="product">Sirius Mods</var> Version 7.3, setting the <var>InvalidChar</var> property to <code>Allow</code> lets you store any EBCDIC character, including the null character and including a character that does not translate to Unicode. However, as of version 7.3: | ||
setting the <var>InvalidChar</var> property to < | |||
EBCDIC character, including the null character and including a character that does not | |||
translate to Unicode. | |||
However, as of version 7.3: | |||
<ul> | <ul> | ||
<li>The XML Element- or Attribute-updating methods allow the storing of any | <li>The XML Element- or Attribute-updating methods allow the storing of any non-null EBCDIC character that translates to Unicode. | ||
non-null EBCDIC character that translates to Unicode. | <li><var>InvalidChar</var> is deprecated, and it has no effect if invoked. Sirius recommends that <var>InvalidChar</var> not be used. See also the discussion below in [[#Examples|"Examples"]]. | ||
<li><var>InvalidChar</var> is deprecated, and it has no effect if invoked. | |||
Sirius recommends that <var>InvalidChar</var> not be used. | |||
See also the discussion below in [[#Examples|"Examples"]]. | |||
</ul> | </ul> | ||
while as of <var class="product">Sirius Mods</var> Version 7.6: | |||
<ul> | <ul> | ||
<li><var>XmlDocs</var> are maintained in Unicode, and | <li><var>XmlDocs</var> are maintained in Unicode, and all Unicode characters can always be stored in an <var>XmlDoc</var>, except null (U+0000), which is prohibited by the XML Recommendation. | ||
all Unicode characters can always be stored in an <var>XmlDoc</var>, except null | <li>The <var>InvalidChar</var> property is no longer supported, and requests containing <var>InvalidChar</var> will fail. If you are using <var>InvalidChar</var> in source code to allow null characters, you can use the <var>[[AllowNull (XmlDoc property)|AllowNull]]</var>) property instead. | ||
(U+0000), which is prohibited by the XML Recommendation. | <li>EBCDIC characters to be stored in an <var>XmlDoc</var> must be translatable to Unicode. If you have EBCDIC strings that may not be translatable, you must handle them before passing them to an <var>XmlDoc</var> | ||
<li>The <var>InvalidChar</var> property is no longer supported, and | update operation. For example, you may be able to use the <var>Untranslatable</var> parameter of the <var>[[EbcdicToUnicode (String function)|EbcdicToUnicode]]</var> function. | ||
requests containing <var>InvalidChar</var> will fail. | |||
If you are using <var>InvalidChar</var> in source code to allow null characters, you | |||
can use the [[AllowNull (XmlDoc property)|AllowNull]]) property instead. | |||
<li>EBCDIC characters to be stored in an <var>XmlDoc</var> | |||
must be translatable to Unicode. | |||
If you have EBCDIC strings that | |||
may not be translatable, you must handle them before passing them to an <var>XmlDoc</var> | |||
update operation. | |||
For example, you may be able to use the <var>Untranslatable</var> parameter | |||
of the <var>[[EbcdicToUnicode (String function)|EbcdicToUnicode]]</var> function. | |||
</ul> | </ul> | ||
<li>The <var>InvalidChar</var> property applies to updates to Element or Attribute | <li>The <var>InvalidChar</var> property applies to updates to <var>Element</var> or <var>Attribute</var> values. If <var>InvalidChar</var> is <code>Allow</code>, an invalid XML string is allowed in these cases: | ||
values. | |||
If <var>InvalidChar</var> is <code>Allow</code>, an invalid XML string is allowed in | |||
these cases: | |||
<ul> | <ul> | ||
<li>As the second argument of the <var> | <li>As the second argument of the <var>[[AddElement_(XmlDoc/XmlNode_function)|addElement]]</var>, <var>[[InsertElementBefore (XmlNode function)|InsertElementBefore]]</var>, <var>[[AddText_(XmlNode_function)|addText]]</var>, <var>[[InsertTextBefore_(XmlNode_function)|insertTextBefore]]</var>, and <var>[[AddAttribute_(XmlNode_function)|AddAttribute]]</var> methods. | ||
<var> | <li>As the right-hand side of an assignment to the <var>[[Value_(XmlDoc/XmlNode_property)|value]]</var> property of an <var>Element</var>, <var>Text</var>, or <var>Attribute</var> node. | ||
and <var>AddAttribute</var> methods | |||
<li>As the right-hand side of an assignment to the <var> | |||
of an <var>Element</var>, <var>Text</var>, or <var>Attribute</var> node | |||
</ul> | </ul> | ||
'''Note:''' | '''Note:''' | ||
The above operations imply that the string contains an EBCDIC value. | The above operations imply that the string contains an EBCDIC value. | ||
<li>This property does ''not'' affect updates to <var>Comment</var> or <var>Pi</var> nodes. | <li>This property does ''not'' affect updates to <var>Comment</var> or <var>Pi</var> nodes. It also does ''not'' affect deserialization operations, such as the <var>[[LoadXml_(XmlDoc/XmlNode_function)|loadXml]]</var> method, although in future versions of var class="product">[[Janus SOAP]]</var> it may be extended to allow invalid <var>Attribute</var> and <var>Element</var> values created with deserialization methods. | ||
It also does ''not'' affect deserialization operations, such as the | <li>If <var>InvalidChar</var> is set to <code>Disallow</code> in the method object of the <var>[[AddSubtree_(XmlDoc/XmlNode_function)|addSubtree]]</var> or <var>[[InsertSubtreeBefore_(XmlNode_function)|insertSubtreeBefore]]</var> methods, the request is cancelled if the source <var>XmlDoc</var> “possibly” has any invalid characters. That is, it is cancelled if the <var>XmlDoc</var> containing the argument <var>XmlNode</var> has been updated (in any form) while its <var>InvalidChar</var> property was set to <code>Allow</code>. This is '''any''' form of update, including, for instance, deserialization, all the <var>Add*</var> and <var>Insert*</var> methods, assigning to the <var>Value</var> property, and assigning a non-null string to the <var>[[SelectionNamespace_(XmlDoc_property)|selectionNamespace]]</var> property. | ||
<var> | <li>You can also check that a string is a valid XML string by using <var>[[InvalidCharacterPosition (XmlDoc function)|InvalidCharacterPosition]]</var>. | ||
extended to allow invalid <var>Attribute</var> and <var>Element</var> values created | <li>If you attempt to add an invalid character, the error message produced by <var>AddElement</var>, for example, contains a fragment of the value that includes the invalid character. | ||
with deserialization methods. | |||
<li>If <var>InvalidChar</var> is set to <code>Disallow</code> in the method object of the | |||
<var> | |||
cancelled if the source <var>XmlDoc</var> & | |||
characters. | |||
That is, it is cancelled if the <var>XmlDoc</var> containing the argument | |||
<var>XmlNode</var> has been updated (in any form) while its <var>InvalidChar</var> | |||
property was set to <code>Allow</code>. | |||
This is '''any''' form of update, | |||
including, for instance, deserialization, all the Add* and Insert* | |||
methods, assigning to the <var>Value</var> property, and assigning a non-null | |||
string to the <var> | |||
<li>You can also check that a string is a valid XML string by using | |||
<var>[[InvalidCharacterPosition (XmlDoc function)|InvalidCharacterPosition]]</var>. | |||
<li>If you attempt to add an invalid character, | |||
the error message produced by <var>AddElement</var>, for example, | |||
contains a fragment of the value that includes the invalid character. | |||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
<ol><li>Prior to <var class="product">Sirius Mods</var> Version 7.3, <var>InvalidChar</var> let you store any EBCDIC character. For example, the following fragment: | |||
Prior to <var class="product">Sirius Mods</var> 7.3, <var>InvalidChar</var> let you store any EBCDIC character. | <p class="code">%doc:invalidChar = Allow | ||
For example, the following fragment: | %doc:[[AddElement_(XmlDoc/XmlNode_function)|addElement]]('A', $X2C('FF00')) | ||
<p class="code" | print 'Value is (hex):' and $C2X(%doc:[[Value_(XmlDoc/XmlNode_property)|value]]) | ||
%doc: | </p> | ||
Produced the following result: | Produced the following result: | ||
<p class="code" | <p class="code">Value is (hex): FF00 | ||
</ | </p> | ||
However, as of <var class="product">Sirius Mods</var> Version 7.3, if <var>AddElement</var> (or another XML “storing” method) contains either the null character (X'00') or any EBCDIC character (such as X'FF') that does not translate to Unicode, it causes a request cancellation. | |||
<li>If you have an <var>XmlDoc</var> with arbitrary EBCDIC byte streams, it is recommended that you store them in the <var>XmlDoc</var> using base-64 encoding. For example: | |||
contains either the null character (X'00') or any EBCDIC character (such as X'FF') | <p class="code">%node:addElement('binaryData', %data:[[StringToBase64_(String_function)|stringToBase64]]) | ||
that does not translate to Unicode, it causes a request cancellation. | |||
If you have an | |||
<var>XmlDoc</var> with arbitrary EBCDIC byte streams, it is | |||
recommended that you store them in the <var>XmlDoc</var> using base-64 encoding. | |||
For example: | |||
<p class="code" | |||
... | ... | ||
%val = %node: | %val = %node:value:[[Base64ToString_(String_function)|base64ToString]] | ||
</ | </p></ol> | ||
==Request-Cancellation Errors== | |||
<ul> | <ul> | ||
<li>InvalidChar has no request cancellation errors. | <li><var>InvalidChar</var> has no request cancellation errors. | ||
</ul> | </ul> | ||
==See also== | ==See also== | ||
{{Template:XmlDoc:InvalidChar footer}} | {{Template:XmlDoc:InvalidChar footer}} |
Revision as of 02:50, 29 May 2011
Allow invalid characters (obsolete) (XmlDoc class)
NOTE: As described in the Usage notes below, the InvalidChar property was deprecated as of Sirius Mods Version 7.3, and it is invalid as of Sirius Mods Version 7.6.
Prior to Sirius Mods Version 7.3, you use this property to control whether a string containing an invalid XML character can be added to an XmlDoc. A character is invalid if it is not one of the valid characters specified in the W3C Recommendation for XML (see "Char and Reference"). Prior to the introduction of this InvalidChar property (Sirius Mods Version 6.8), Janus SOAP did not permit such characters in an XmlDoc. An example is the “control character” X'01'.
This property is designed to let you use an XmlDoc to contain data that is not exchanged with other applications, yet whose content cannot be controlled by your application. If you present such a document to a W3C-compliant XML processor, it will be rejected as erroneous.
Syntax
%currentXmlInvalidChar = doc:InvalidChar doc:InvalidChar = newXmlInvalidChar
Syntax terms
%currentXmlInvalidChar | The XmlInvalidChar enumeration value (see below) of doc's InvalidChar property. Valid values are Allow and Disallow . |
---|---|
doc | An XmlDoc object expression. |
newXMLInvalidChar | The XmlInvalidChar enumeration value (Allow or Disallow ) to assign to doc's InvalidChar property. |
XmlInvalidChar enumeration
The values of the XmlInvalidChar property are of type Enumeration XmlInvalidChar:
Allow | An XmlDoc with this setting allows invalid characters. |
---|---|
Disallow | An XmlDoc with this setting does not allow invalid characters. This is the default setting. |
Usage notes
- Pror to Sirius Mods Version 7.3, setting the InvalidChar property to
Allow
lets you store any EBCDIC character, including the null character and including a character that does not translate to Unicode. However, as of version 7.3:- The XML Element- or Attribute-updating methods allow the storing of any non-null EBCDIC character that translates to Unicode.
- InvalidChar is deprecated, and it has no effect if invoked. Sirius recommends that InvalidChar not be used. See also the discussion below in "Examples".
while as of Sirius Mods Version 7.6:
- XmlDocs are maintained in Unicode, and all Unicode characters can always be stored in an XmlDoc, except null (U+0000), which is prohibited by the XML Recommendation.
- The InvalidChar property is no longer supported, and requests containing InvalidChar will fail. If you are using InvalidChar in source code to allow null characters, you can use the AllowNull) property instead.
- EBCDIC characters to be stored in an XmlDoc must be translatable to Unicode. If you have EBCDIC strings that may not be translatable, you must handle them before passing them to an XmlDoc update operation. For example, you may be able to use the Untranslatable parameter of the EbcdicToUnicode function.
- The InvalidChar property applies to updates to Element or Attribute values. If InvalidChar is
Allow
, an invalid XML string is allowed in these cases:- As the second argument of the addElement, InsertElementBefore, addText, insertTextBefore, and AddAttribute methods.
- As the right-hand side of an assignment to the value property of an Element, Text, or Attribute node.
Note: The above operations imply that the string contains an EBCDIC value.
- This property does not affect updates to Comment or Pi nodes. It also does not affect deserialization operations, such as the loadXml method, although in future versions of var class="product">Janus SOAP it may be extended to allow invalid Attribute and Element values created with deserialization methods.
- If InvalidChar is set to
Disallow
in the method object of the addSubtree or insertSubtreeBefore methods, the request is cancelled if the source XmlDoc “possibly” has any invalid characters. That is, it is cancelled if the XmlDoc containing the argument XmlNode has been updated (in any form) while its InvalidChar property was set toAllow
. This is any form of update, including, for instance, deserialization, all the Add* and Insert* methods, assigning to the Value property, and assigning a non-null string to the selectionNamespace property. - You can also check that a string is a valid XML string by using InvalidCharacterPosition.
- If you attempt to add an invalid character, the error message produced by AddElement, for example, contains a fragment of the value that includes the invalid character.
Examples
- Prior to Sirius Mods Version 7.3, InvalidChar let you store any EBCDIC character. For example, the following fragment:
%doc:invalidChar = Allow %doc:addElement('A', $X2C('FF00')) print 'Value is (hex):' and $C2X(%doc:value)
Produced the following result:
Value is (hex): FF00
However, as of Sirius Mods Version 7.3, if AddElement (or another XML “storing” method) contains either the null character (X'00') or any EBCDIC character (such as X'FF') that does not translate to Unicode, it causes a request cancellation.
- If you have an XmlDoc with arbitrary EBCDIC byte streams, it is recommended that you store them in the XmlDoc using base-64 encoding. For example:
%node:addElement('binaryData', %data:stringToBase64) ... %val = %node:value:base64ToString
Request-Cancellation Errors
- InvalidChar has no request cancellation errors.