InvalidCharacterPosition (XmlDoc function)

From m204wiki
Revision as of 00:13, 7 December 2010 by 198.242.244.47 (talk) (Created page with "<span style="font-size:120%; color:black"><b>Detect invalid characters</b></span> InvalidCharacterPosition function Category:XmlDoc API methods [[...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Detect invalid characters

InvalidCharacterPosition is a member of the XmlDoc class.

This shared function validates whether the characters in a string may be used as the value of an Element or Attribute node. The method checks the characters in its value argument and returns 0 if they are all valid; otherwise, it returns the position of the first invalid character.

Syntax

  %pos = %(XmlDoc):InvalidCharacterPosition( value           -
                                          [, AllowNull=bool] )

Syntax Terms

%pos
The numeric position of the first character that is not valid to be used as the value of an Element or Attribute node; otherwise, 0 if all characters are valid.
%(XmlDoc)
The class name in parentheses denotes a shared method and is one way to invoke the method. See the “Usage Notes,” below for more about invoking this method.
value
The input string whose characters are to be validated. As of Sirius Mods version 7.6, this may be a Unicode string or an EBCDIC string. Formerly, only EBCDIC was allowed.
AllowNull=bool
This Boolean, name required, optional parameter determines whether an input null character is considered invalid. The default value of AllowNull is False, which causes an input null character to be treated as invalid. If AllowNull is True, an input null is valid. AllowNull is available as of Sirius Mods version 7.6.

Usage Notes

  • InvalidCharacterPosition returns zero if its argument string is:
    • Unicode, and all characters are legal in an XML document (that is, it does not contain any null characters).
    • EBCDIC, and all characters are translatable to Unicode characters other than the null character.

    Otherwise, it returns the character position of the first character that does not meet these criteria.

    Prior to Sirius Mods 7.6, the invalid characters of an Element or Attribute node were the EBCDIC “control characters.”

  • Like any shared method, the method object here can be an object of the class of the method (XmlDoc), null or not, or it can simply be a class name qualifier:
        %pos = %myDoc:InvalidCharacterPosition(%str)
    
        %pos = %(XmlDoc):InvalidCharacterPosition(%str)
    

    Note: The first type of invocation is not meant to imply that the method actually operates on %doc.

  • With the introduction of this method, the IsValidString function is deprecated.
  • This method was actually introduced into version 6.9 of Janus SOAP, but its documentation first appeared in version 7.0.