In This Article

Parsing and Parse Data

The XML language uses an advanced parser that has been constructed using the Actipro LL(*) Parser Framework, and provides functionality for building ASTs, reporting parse errors, and more.

The IXmlParseData results returned by this parser are consumed by multiple other features of the language, such as automated IntelliPrompt, code outlining, parse error display, etc.

AST Construction

A complete AST of parsed documents is generated by the parser, with structured element nodes and lists of the attributes on each element. It is passed back in the IXmlParseData.Ast property.

This information is used when building the context for an offset.

Parse Errors

Parse errors are reported from the parser and the validator. They are passed back in the IXmlParseData.Errors property.

The parser reports errors as it performs syntax and semantic analysis of document text. The validator for the language can also report errors when the XML doesn't conform to the schemas loaded in the schema resolver.

When the language is used in a SyntaxEditor control, the parse errors will have squiggle lines under them and mouse hovering over the squiggle lines will show IntelliPrompt quick info tips with error descriptions.

Parse errors can also be consumed by applications that wish to show the parse errors in a tool window.

Well-Formed Flag

The IXmlParseData.IsWellFormed property indicates whether the XML is well-formed.

Retrieving Parse Data

As long as an ambient parse request dispatcher has been set up, all parsing and validation is performed in a worker thread. The processing occurs after any text changes are made to documents using the language. Since the work occurs in a worker thread, the results are returned asynchronously and may not be in perfect sync with the document text. Although since the parse data includes the ITextSnapshot instance that was parsed, if known, you can easily translate offsets from the parse data snapshot to the current snapshot in a SyntaxEditor view or document.

Once a parsing operation completes, the IXmlParseData results are placed into the ParseData property of the document that was parsed and its ParseDataChanged event fires. The latest parse data results can be obtained at any time from that property.

See the Parsers topic for more detailed information on the parsing workflow and parse data.

Parsing a Text String

See the Parsers for details on how to easily parse a text string using a language's parser, such as this one.