Before analyzing XML syntax, it is necessary to understand the basic rules of XML syntax: Lexical features: 1) XML case sensitive, if the element name must be in the same case as mytag/mytag in the open and closed tags, the reserved string of XML should be in the case of a request.
Before analyzing XML syntax, it is necessary to understand the basic rules of XML syntax:
Lexical features: 1) XML is case-sensitive. for example, the element names must be case-sensitive when being opened or closed. ... , The reserved string of XML should meet the case-insensitive request ....
2) XML reserved markup characters: <>&, reserved characters are not allowed to be displayed in the element name, element text, attribute name, and attribute value. <user open markup> is used for closed markup, & for conversion, common conversion means & lt by nature <, & gt by nature>, & amp by nature &, & apos by nature ', & quot by nature"
3) an element name can contain letters, numbers, periods, hyphens, underscores, colons, and extended characters in other languages, element names cannot contain space characters (grid operators, jump characters, line breaks, and carriage returns). element names can be prefixed by domain names. For example: Element text can be a collection of characters other than the reserved characters in XML, such My money is $2000.
4) the attribute name rules are the same as the element name. the attribute value is enclosed by single or double quotation marks and can be composed of strings other than the XML reserved characters, for example: . The attribute name has the xmlns prefix, indicating that the attribute defines a domain name, for example:
Syntax features: 1) an XML document consists of an XML clarification, multiple optional documents clarification, multiple optional XML instructions, multiple optional XML annotations, and a data body of a root element, in addition, CDATA segments embedded in statements can also be included, such:
Reference content is as follows:
/* XML clarification */
/* XML document clarification */
/* XML comment */
/* XML command */
/* Root data element */
...…
2) XML clarification Mark-closed, including the version, encoding, and other optional clarification, such:
3) the XML document clarifies that Closed, such:
4) XML commands Closed, such:
5) XML annotation Closed, such:
6) The XML element consists <元素名> Open, by/>, or Closed: The opening and closing tags of elements match each other, as shown in figure Or ...XML elements are allowed to be nested. Therefore, Hierarchical matching should be maintained, as shown in figure .. .
7) CDTATA>打开,由Closed to avoid XML parsing rules. For example: select * from mytable where thefield <= ‘100’
Based on the above XML syntax features, the regular expression used for lexical analysis and the downstream Active Server structure used for syntax analysis can be structured.
XML lexical regular expression:
# Define digit [1, 2 ,..., 9]/* digit character */
# Define letter [a, B ,..., Z, A, B ,..., Z]/* letter */
# Define signs [~, ! , @, #, %, ^ ,&,*,(,),?, :,;, ", ',.,/,-, _, =, |, \]/* Symbol character */
# Define ascii2 [0x80 ,..., 0xFF]/* ASCII chart2 expanded character */
# Define space [0x20, \ t, \ r, \ n]/* space character, grid character, carriage return character, line break */
# Define reserve [<,>, &]/* XML reserved characters */
1) regular expression of element name:
Element_name-> (_ | letter | ascii2) (ε | _ |-|: |. | digit | letter | signs | ascii2 )*
2) regular expression of element text:
Element_text-> (ε | not reserve )*
3) regular expression of the attribute name:
Proper_name-> (_ | letter | ascii2) (ε | _ |-|: |. | digit | letter | signs | ascii2 )*
4) regular expression of attribute text:
Proper_value-> (ε | not reserve )*