GoFiler Legato Script Reference
Legato v 1.5b Application v 5.24b
|
Table of Contents | < < Previous | Next >> |
Chapter Five — General Functions (continued)
Overview
The GetTagAttributes function returns the attributes from an SGML style tag in the form of an array.
Syntax/Parameters
Syntax
string[] = GetTagAttributes ( string tag, [boolean case], [int limit] );
Parameters
tag
A string containing an SGML style tag
case
An optional boolean value. When non-zero or TRUE forces the case of the attribute keys to lower case. The default, FALSE, is not to adjust the attribute/key names.
limit
An optional int specifying a limit to the number of return array elements. The default value is 1,024 elements. The
Return Value
Returns a string array containing the key/data as names and attribute values or empty array on failure. Use the GetLastError function to retrieve error information. Note that if the array element limit is reached, or there is a problem with an attribute or property name, an error will be set but the array will contain all elements up to the point of the limit.
Remarks
This function is a “quick and dirty” method of retrieving SGML information from tags without the complexity of setting up an SGML element object or a DTD. Very little error and syntax checking is performed. To access the attributes, enumerate through the array and key names. Note that duplicate attributes will result in a single key name with the last data item present.
An example:
string aa[20]; string s1, s2, s3; int ix, size; s1 = "<element p1='param_a' p2=param_b p3=\"param_c\" p4=D1234>"; aa = GetTagAttributes(s1); size = ArrayGetAxisDepth(aa); ix = 0; while (ix < size) { s2 = aa[ix]; s3 = ArrayGetKeyName(aa, ix); AddMessage("%3d %-12s %s", ix, s3, s2); ix++; }
This script will produce the following in the results log:
0 p1 param_a 1 p2 param_b 2 p3 param_c 3 p4 D1234
If the case of the attributes is unknown, the case parameter makes it easy to have predictable key names as lower case. For example, when used, the incoming attributes ‘HREF’ ‘href’ and ‘hRef’ will all be converted to the consistent key name ‘href’.
Attributes as QNames (XML ‘prefix:name’) are passed in to the key name intact as a complete name.
The empty elements designator, for example <abc a="1" b="2"/>, is ignored and not including in the array.
Attribute and property names must be valid array key names or they will be ignored and an error set. Resulting duplicate key names are ignored and an error set. In both cases, the remaining validly named items are added to the array.
The number of attributes is limited to 1,024. If there are more that this number, the function will fail with a ERROR_OVERFLOW error. If the receiving array is too small, a runtime error can occur. The returned number of elements can be limited using the limit parameter. This allows for smaller practical fixed arrays without a risk of a runtime error.
Related Functions
Platform Support
Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL
Legato IDE, Legato Basic
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.