Package net.sf.saxon.expr.parser
Class XPathParser.NestedLocation
- java.lang.Object
-
- net.sf.saxon.expr.parser.XPathParser.NestedLocation
-
- All Implemented Interfaces:
javax.xml.transform.SourceLocator
,Location
,org.xml.sax.Locator
- Enclosing class:
- XPathParser
public static class XPathParser.NestedLocation extends java.lang.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 Summary
Constructors Constructor Description NestedLocation(Location containingLocation, int localLineNumber, int localColumnNumber, java.lang.String nearbyText)
Create a NestedLocation
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getColumnNumber()
Get the column number of the error within the expression or queryLocation
getContainingLocation()
Get the location of the container.int
getLineNumber()
Get the line number within the containing entity.int
getLocalLineNumber()
Get the local line number, that is the line number relative to the start of the expression or query.java.lang.String
getNearbyText()
Get text appearing near to the error (typically a syntax error) within the source text of the expression or query.java.lang.String
getPublicId()
Get the public identifier.java.lang.String
getSystemId()
Get the system identifier of the expression's container.Location
saveLocation()
Save an immutable copy of the location information.
-
-
-
Constructor Detail
-
NestedLocation
public NestedLocation(Location containingLocation, int localLineNumber, int localColumnNumber, java.lang.String nearbyText)
Create a NestedLocation- Parameters:
containingLocation
- the location of the containing construct, typically an attribute or text node in an XML documentlocalLineNumber
- the line number within the containing construct, starting at zerolocalColumnNumber
- the column number within the containing construct, starting at zeronearbyText
- text appearing in the vicinity of the error location
-
-
Method Detail
-
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 interfaceLocation
- Specified by:
getColumnNumber
in interfaceorg.xml.sax.Locator
- Specified by:
getColumnNumber
in interfacejavax.xml.transform.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 java.lang.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 interfaceLocation
- Specified by:
getSystemId
in interfaceorg.xml.sax.Locator
- Specified by:
getSystemId
in interfacejavax.xml.transform.SourceLocator
- Returns:
- the system identifier of the expression's container, or null if not known
-
getPublicId
public java.lang.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 interfaceLocation
- Specified by:
getPublicId
in interfaceorg.xml.sax.Locator
- Specified by:
getPublicId
in interfacejavax.xml.transform.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 interfaceLocation
- Specified by:
getLineNumber
in interfaceorg.xml.sax.Locator
- Specified by:
getLineNumber
in interfacejavax.xml.transform.SourceLocator
- Returns:
- the line number within the containing entity, or -1 if unknown.
-
getNearbyText
public java.lang.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 interfaceLocation
- Returns:
- immutable location information.
-
-