Class XPathParser.NestedLocation

java.lang.Object
net.sf.saxon.expr.parser.XPathParser.NestedLocation
All Implemented Interfaces:
SourceLocator, Location, Locator
Enclosing class:
XPathParser

public static class XPathParser.NestedLocation extends Object implements Location
A nested location: for use with XPath expressions and queries nested within some larger document. The location information comes in two parts: the location of the query or expression within the containing document, and the location of an error within the query or XPath expression.
  • Constructor Details

    • NestedLocation

      public NestedLocation(Location containingLocation, int localLineNumber, int localColumnNumber, String nearbyText)
      Create a NestedLocation
      Parameters:
      containingLocation - the location of the containing construct, typically an attribute or text node in an XML document
      localLineNumber - the line number within the containing construct, starting at zero
      localColumnNumber - the column number within the containing construct, starting at zero
      nearbyText - text appearing in the vicinity of the error location
  • Method Details

    • getContainingLocation

      public Location getContainingLocation()
      Get the location of the container. This is normally used for expressions nested within an XML document, where the container location gives the location of the attribute or text node holding the XPath expression as a whole
      Returns:
      the location of the containing expression or query
    • getColumnNumber

      public int getColumnNumber()
      Get the column number of the error within the expression or query
      Specified by:
      getColumnNumber in interface Location
      Specified by:
      getColumnNumber in interface Locator
      Specified by:
      getColumnNumber in interface SourceLocator
      Returns:
      the column number. This is generally maintained only during parsing, so it will be returned as -1 (meaning not available) in the case of dynamic errors. Column numbers start at 0. For expressions held within XML attributes, the position is within the attribute after XML attribute-value normalization, which replaces newlines by spaces and expands entity references.
    • getSystemId

      public String getSystemId()
      Get the system identifier of the expression's container. This will normally be the URI of the document (or external entity) in which the expression appears.
      Specified by:
      getSystemId in interface Location
      Specified by:
      getSystemId in interface Locator
      Specified by:
      getSystemId in interface SourceLocator
      Returns:
      the system identifier of the expression's container, or null if not known
    • getPublicId

      public String getPublicId()
      Get the public identifier. This will normally be null, but is provided for compatibility with SAX and JAXP interfaces
      Specified by:
      getPublicId in interface Location
      Specified by:
      getPublicId in interface Locator
      Specified by:
      getPublicId in interface SourceLocator
      Returns:
      the public identifier - usually null
    • getLocalLineNumber

      public int getLocalLineNumber()
      Get the local line number, that is the line number relative to the start of the expression or query. For expressions held within XML attributes, the position is within the attribute after XML attribute-value normalization, which replaces newlines by spaces and expands entity references; the value will therefore in many cases not be usable. Local line numbers start at 0.
      Returns:
      the local line number within the expression or query. Set to -1 if not known.
    • getLineNumber

      public int getLineNumber()
      Get the line number within the containing entity. This is the sum of the containing location's line number, plus the local line number. Returns -1 if unknown.
      Specified by:
      getLineNumber in interface Location
      Specified by:
      getLineNumber in interface Locator
      Specified by:
      getLineNumber in interface SourceLocator
      Returns:
      the line number within the containing entity, or -1 if unknown.
    • getNearbyText

      public String getNearbyText()
      Get text appearing near to the error (typically a syntax error) within the source text of the expression or query.
      Returns:
      nearby text to the error. May be null.
    • saveLocation

      public Location saveLocation()
      Save an immutable copy of the location information. This implementation does nothing, because the object is already immutable
      Specified by:
      saveLocation in interface Location
      Returns:
      immutable location information.