| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.expr.parser; |
| 9 | |
| 10 | import org.xml.sax.Locator; |
| 11 | |
| 12 | import javax.xml.transform.SourceLocator; |
| 13 | |
| 14 | /** |
| 15 | * Saxon interface to represent a location, typically the location of an expression within a query |
| 16 | * or stylesheet. The interface combines the two JAXP interfaces SourceLocator and Locator. |
| 17 | */ |
| 18 | |
| 19 | public interface Location extends SourceLocator, Locator { |
| 20 | |
| 21 | /** |
| 22 | * Get the system ID. This should be the system identifier of an XML external entity; if a stylesheet module |
| 23 | * comprises multiple external entities, the distinction should be retained. This means, for example, that |
| 24 | * an instruction in a stylesheet can have a different system identifier from its parent instruction. However, |
| 25 | * SAX parsers only provide location information at the element level, so when part of an XPath expression |
| 26 | * is in a different external entity from other parts of the same expression, this distinction is lost. |
| 27 | * |
| 28 | * <p>The system identifier of a node is in general not the same as its base URI. The base URI is affected |
| 29 | * by xml:base attributes; the system identifier is not.</p> |
| 30 | * |
| 31 | * @return the system ID, or null if the information is not available. |
| 32 | */ |
| 33 | |
| 34 | String getSystemId(); |
| 35 | |
| 36 | /** |
| 37 | * Get the Public ID |
| 38 | * |
| 39 | * @return usually null |
| 40 | */ |
| 41 | |
| 42 | String getPublicId(); |
| 43 | |
| 44 | /** |
| 45 | * Get the line number. This line number is relative to the external entity identified by the system identifier. |
| 46 | * Line numbers start at 1. The value may be an approximation; SAX parsers only provide line number information |
| 47 | * at the level of element nodes. |
| 48 | * |
| 49 | * @return the line number, or -1 if the information is not available. |
| 50 | */ |
| 51 | |
| 52 | int getLineNumber(); |
| 53 | |
| 54 | /** |
| 55 | * Get the column number. This column number is relative to the line identified by the line number. |
| 56 | * Column numbers start at 1. |
| 57 | * |
| 58 | * @return the column number, or -1 if the information is not available. |
| 59 | */ |
| 60 | |
| 61 | int getColumnNumber(); |
| 62 | |
| 63 | /** |
| 64 | * Get an immutable copy of this Location object. By default Location objects may be mutable, so they |
| 65 | * should not be saved for later use. The result of this operation holds the same location information, |
| 66 | * but in an immutable form. |
| 67 | */ |
| 68 | |
| 69 | Location saveLocation(); |
| 70 | |
| 71 | |
| 72 | } |