Rules for entering XML search strings
Adhere to the following rules while configuring XML search strings.
- The XML element (tag) name must contain only supported string literals. You cannot use regular expressions in the element name. However, you can use valid regular expressions in the element content to match the element content, as shown below:
- <level>ERROR\\|INFO
|SEVERE</level> - <class>com.bmc.</class>*
- <pid>.</pid>*
- <level>ERROR\\|INFO
- You must provide an element name in an XML search string in the same hierarchy as that of the file that you want to monitor.
- You must use the <bmc_reg_ex> element to differentiate the OR such as |, AND such as &, and parentheses such as ( and )regular expressions only, between elements as follows:
- <bmc_reg_ex>&</bmc_reg_ex>
- <bmc_reg_ex>|</bmc_reg_ex>
<bmc_reg_ex>(</bmc_reg_ex>
The sequence of special characters makes the combination of elements a regular expression.
Following is an example of an XML file with element structure:<rec> <vm>log_server</vm> <ts>2008-06-20 11:34:42.253 CEST</ts> <level>INFO</level> <class>com.bmc.log.XmlReader</class> <method>loadCeb</method> <ctx> <pid>WLSStartUpUser</pid> <appid>System</appid> <cname>StartUpManager</cname> <reqid>0</reqid> <sesid>NOSESSIONID</sesid> </ctx> <msg> <![CDATA[ *** Test message. ***]]> </msg> </rec>
The following examples show valid/invalid search strings:
- Search String:
<rec><vm>log_server</vm></rec>
This search string returns all instances of the <vm> element contents as log_server.
- Search string with the .* regular expression:
<rec><class>com\.bmc\.log\.XmlReader.*</class></rec>
This search string returns instances of the <class> element that begin with com.bmc.log.XmlReader.
- Search string with the OR condition in the element content:
<rec><ctx><pid>anonymous\|A288796</pid></ctx></rec>
This search string returns instances of the <pid> element whose content is anonymous or A288796.
- Search string with the OR regular expression:
<rec><level>INFO</level><bmc_reg_ex>|</bmc_reg_ex><ctx><pid>
WLSStartUpUser</pid></ctx></rec>
This search string uses an OR operator to return instances of the <level> element whose content is INFO or instances of the <pid> element whose content is WLSStartUpUser and which is within the <ctx> element.
Note
The <level> and <ctx> elements are at the same level in the hierarchy and <pid> is a child of <ctx>, so <pid> must appear after <ctx> in the search string.
- Search string with the AND regular expression:
<rec><method>unknown</method><bmc_reg_ex>&</bmc_reg_ex><ctx>
<pid>anonymous</pid></ctx></rec>
This search string uses the AND operator to return instances of the <method> element whose content is unknown and instances of the <pid> element whose content is anonymous and which is within the <ctx> element.
- Search string with OR and AND regular expressions:
<rec><vm>log_server</vm><bmc_reg_ex>|</bmc_reg_ex><level>SEVERE
</level><bmc_reg_ex>&</bmc_reg_ex><class>com.bmc.log.XmlReader
</class></rec>
This search string returns matches based on the precedence of AND over OR.
- Search string with OR, AND, and parentheses regular expressions:
<rec><vm>log_server.*</vm><bmc_reg_ex>&</bmc_reg_ex><level>
ERROR\|SEVERE</level><bmc_reg_ex>&</bmc_reg_ex><ctx><bmc_reg_ex>
(</bmc_reg_ex><appid>logKM.*</appid><bmc_reg_ex>|</bmc_reg_ex>
<cname>StartUpManager</cname><bmc_reg_ex>)</bmc_reg_ex></ctx>
<bmc_reg_ex>|</bmc_reg_ex><msg>.*</msg></rec>
You can combine the expression between elements and the regular expression provided for element content. You can provide complex expressions between elements involving only &, |, (, and ).
The expression that you obtain by replacing the search pattern for each element with 1 or 0 (matched or not matched) should be a valid arithmetic expression; if not, the respective search criterion is discarded from the search. This search string returns matches based on the result of the arithmetic expression.
Hierarchy in the search criteria:
In an XML instance, all the search criteria must have the same hierarchy.
The following shows an invalid hierarchy:
Criteria 1:<rec><vm>.*</vm></rec>
Criteria 2:
<ctx><pid>.*</pid></ctx>
If Criteria 1 and 2 are provided for the same XML instance they may not return expected results. However, they would return appropriate results if they are under two separate instances. Following are the examples for valid hierarchy:
Criteria 1:<rec><vm>.*</vm></rec>
Criteria 2:
<rec><ctx><pid>.*</pid></ctx><rec>
- Invalid search string:
<*pid>.*java.*</*pid>
The above search string is invalid because the element name contains a regular expression.
Comments
Log in or register to comment.