Determining the Current Context in an XSLT Application

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XPath Developer's Guide

Determining the Current Context in an XSLT Application

Any XML Path Language (XPath) expression referencing some nodes in a source document is evaluated according to conditions that are true at the time the evaluation occurs. When XPath is being used for a linking application, the context in most cases will not change; each link carries its own context with it. In XSLT applications, however, understanding the context is critical because a number of factors may cause the context to change at various points in the style sheet.

There are two general kinds factors of: static and dynamic.

Static context

The static context includes two general conditions that are true depending on the XPath expression's placement in the XSLT file.

  • Namespaces: A given XPath expression found at two different points in an XSLT file may have two completely different meanings if the namespaces in effect at those two points are different.
  • Variable declarations: An XPath expression, if it refers to a variable, correctly interpreting the expression depends on the declaration of that variable.

Dynamic context

The dynamic context does not depend on the location of the XPath expression in the XSLT file, but on the state of processing at the time the expression is evaluated. Four factors are included in the dynamic context: the context node, context size, context position, and current node.

See Also

Using XSLT Variables and Parameters | Determining the Context Node | Determining the Context Size | Determining the Context Position | Determining the Current Node