<< Click to Display Table of Contents >> Navigation: 3. Script Language > XML-Parser > XML-Parser |
Smart Package Robot 's XML-Parser Flags
During the Parsing, the XML-Parser will assign Flags to each byte of the XML-Code.
These flags are the base of nearly all builtin XML-Commands.
You can see these flags using the
XML.Dump
Command. There is an example Output in the picture below.
The SPR-XML-Flags
Here is a complete list with all SPR-XML Flags and their corresponding numbers.
"open bracket" = 1
"close bracket" = 2
"between" = 4
"is sq" = 8
"between sq" = 16 = &H10
"is dq" = 32 = &H20
"between dq" = 64 = &H40
"before eq" = 128 = &H80
"after eq" = 256 = &H100
"outside sdq" = 512 = &H200
"self terminate" = 1024 = &H400
"system tag" = 2048 = &H800
"start name" = 4096 = &H1000
"end name" = 8192 = &H2000
"start attribute" = 16384 = &H4000
"end attribute" = 32768 = &H8000
"start tag" = 65536 = &H10000
"end tag" = 131072 = &H20000
"comment" = 262144 = &H40000
Note that you can specify whether the flag name, or the flag number, or the hexadecimal flag number. You can also combine Flags using the "+" Operator.
How to use this flags:
You can use these flags in several ways.
Assume we are at the Root-Adress and we are looking for the first "=" Sign.
This is also called "EQ" from "Equal Sign".
The other Shortcuts are "DQ" for "Double Quote" and "SQ" for "Single Quote".
In this file, the first real "=" is at position 14. is at position 14 as you can see in the Dump below.
We can use the "Before EQ" Flag to get the position..
like this:
1. You can specify the flag number in a search command,
XML.search all down|128|$$RES
We have specified the "128" here as its the number for this flag.
Example:
512 is the flag number for the "outside sdq" Flag.
128 is the flag number for the "before eq"
You can find these numbers above where the flags are.
2. You can specify a hexadezimal flag number as well:
XML.search all down|&H80|$$RES
PRT.MY new position is: $$RES
3. You can add multiple numbers using the "+" sign to search for combinations of flags:
XML.search all down|&H80+&H200|$$RES
PRT.MY new position is: $$RES
In this case, ALL of the given flags must be available, otherwise the result will be zero.
Like in this example:
XML.search all down|&H80+12|$$RES
PRT.MY new position is: $$RES
We have an AND-Operation, if you use multiple flags,
As you can see, you can intermix hexadezimal and other numbers.
4. You can specify the flag-name for better readablity.
PRT.Actual Position after Parsing is: $$POS
XML.search all down|"before eq"|$$RES
PRT.MY new position is: $$RES
It doesn't matter, if you specify the DQ's or not. You can also write:
XML.search all down|before eq|$$RES
which will do all the same. You can as well add Flags this way, using:
XML.search all down|"before eq","between"|$$RES
or you can do it like this:
XML.search all down|before eq+between|$$RES
theoretically the instructions run a bit slower if you use this text-form then if you use the numbers.
If you are not going to work on hundred thousands of Tags, this should not be of any interest to you.
You can directly access these flags using the command:
XML.gef flags|$$BYT|$$FLG
PRT.Byte Nr.$$BYT contains these flags: $$FLG
Note that these flags are cumulated to one number.
To work on these flags you can also use these commands:
' This will return the Flags as text like with Dump.
XML.gef flags as text|$$BYT|$$FLT
More features:
You can also retrieve the Level of a XML-Address like this:
XML.get level|234|$$LEV
PRT. The Level (234) is: $$LEV
And of course you can retrieve the ASC-Value of any Address:
XML.get asc|234|$$ASC
PRT.The ASC-Value(234) is $$ASC
If you have a flag-value and you want to convert it to the appropriate Flags as text, you can use:
XML.flags to text|$$FLG|$$FTX
PRT.Flags are: $$FTX
Here is a explanation of these flags:
1. This Flag is assigned to any real open bracket "<" from any used tag.
"Open Bracket" = 1
2. This Flag is assigned to any real close bracket ">" from any used tag.
"Close Bracket" = 2
4. This Flag is assigned to any character that is inside a tag. Inside a tag means, between a
open bracket ">" and a close bracket ">".
"Between" = 4
8. This Flag is assigned to any SQ (Single Quote) that encloses an attribute.
This flag is not assigned to other SQ's for example in an data-part or inside an DQ-delimited
value of an attribute.
"Is SQ" = 8
16.. This Flag is assigned to any character that is between SQ as an attribute value.
Between SQ" = 16
32. This Flag is assigned to any real DQ (Double Quote) that encloses an attribute.
This flag is not assigned to other DQ's for example in an data-part or inside an SQ-delimited
"is dq" = 32
64.. This Flag is assigned to any character that is between DQ as an attribute value.
"Between DQ" = 64
128. This Flag is assigned to the last letter (non whitespace character) that is before an
EQ Sign that is interpreted to be part of an attribute.
"before eq" = 128
256. This Flag is assigned to the first SQ or DQ , that is after an
EQ Sign that is interpreted to be part of an attribute.
"after eq" = 256
512. This Flag is assigned to to characters inside tags only. If they are not between SQ or DQ.
This means that they are not part of the value of an attribute, if this flag is set.
"outside sdq" = 512
1024. This Flag is assigned to the open- and to the close-bracket of a self terminated tag.
These are comments, system-tags or dedicated "self terminated" tags.
See example XML-Dump below.
"self terminate" = 1024
2048 This Flag is assigned to the open- and to the close-bracket of a system-tag.
See example XML-Dump below.
"system tag" = 2048
4096. This Flag is assigned to the first letter of the tag name.
See example XML-Dump below.
"start name"=4096
8192. This Flag is assigned to the last letter of the tag name.
"end name" = 8192
16384. This Flag is assigned to the first letter of any found attribute.
See example XML-Dump below.
"start attribute" = 16384
32768. This Flag is assigned to the last letter of any found attribute.
Regularly this is a SQ or a DQ-Sign.
See example XML-Dump below.
"end attribute" = 32768
65536. This Flag is assigned to the first "<" that starts a new Start-Tag. Its the opposite
of an End-Tag-Flag (below). See example XML-Dumps below.
"start tag" = 65536
131072. This Flag is assigned to the first "<" that starts a new End-Tag. Its the opposite
of an Start-Tag-Flag (above). See example XML-Dumps below.
"end tag" = 131072
262144. This Flag is assigned to any character that is inside a comment-tag.
There is an picture below that shows the Dump of an comment tag.
"comment" = 262144
Below is another XML-Dump, where you can see the flags.
' This is a XML-"One-Liner"
$$XML=3k<body attrib="value">Hallo nothing="fake"</body>
' First we need to parse it
XML.parse|$$XML
' Here we check if there was an error during the parsing
JIT.Lab_Err
' Now we display the internal tables
XML.dump
' This is just to wait until want to close the script
MBX.Wait
ENR.
' This is the part that would be called if there would be an error
' during the parsing of the XML
:Lab_Err
XML.get error|$$ERT
DBP.$$ERT
ENR.
Above is the result output of this script.
Below is another XML-Dump showing several SPR XML-Flags.
See also: