4. A method for parsing a document that includes data structures conforming to a document specification, the method comprising: accepting a set of rules defining valid data structures in terms of a regular expression comprising one or more nested references to respective referenced regular expressions; replacing the nested references in the regular expression with the respective referenced regular expressions, so as to provide a modified regular expression that does not contain a reference to another regular expression and so as to provide a modified set of rules comprising the modified regular expression; and parsing the document using the modified regular expression that does not contain a reference to another regular expression and accordingly to the modified set of rules.
4. A method for parsing a document that includes data structures conforming to a document specification, the method comprising: accepting a set of rules defining valid data structures in terms of a regular expression comprising one or more nested references to respective referenced regular expressions; replacing the nested references in the regular expression with the respective referenced regular expressions, so as to provide a modified regular expression that does not contain a reference to another regular expression and so as to provide a modified set of rules comprising the modified regular expression; and parsing the document using the modified regular expression that does not contain a reference to another regular expression and accordingly to the modified set of rules. 6. The method according to claim 4 , wherein the document specification comprises an Extensible Markup Language (XML) specification.