01: package net.sf.saxon.event;
02:
03: /**
04: * A Receiver that can be inserted into an event pipeline to copy location information.
05: * The class acts as a LocationProvider, so it supports getSystemId() and getLineNumber() methods;
06: * the location returned can vary for each node, and is set by the class generating the events.
07: * The class is used when it is necessary to copy a subtree along with its location information;
08: * for example, when copying an inline schema within a stylesheet to a separate schema document.
09: */
10:
11: public class LocationCopier extends ProxyReceiver implements
12: LocationProvider {
13:
14: public int lineNumber;
15:
16: public void setPipelineConfiguration(PipelineConfiguration pipe) {
17: PipelineConfiguration pipe2 = new PipelineConfiguration(pipe);
18: pipe2.setLocationProvider(this );
19: super .setPipelineConfiguration(pipe2);
20: }
21:
22: public void setLineNumber(int lineNumber) {
23: this .lineNumber = lineNumber;
24: }
25:
26: public int getColumnNumber() {
27: return -1;
28: }
29:
30: public int getLineNumber() {
31: return lineNumber;
32: }
33:
34: public String getPublicId() {
35: return null;
36: }
37:
38: public String getSystemId(int locationId) {
39: return getSystemId();
40: }
41:
42: public int getLineNumber(int locationId) {
43: return getLineNumber();
44: }
45: }
46:
47: //
48: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
49: // you may not use this file except in compliance with the License. You may obtain a copy of the
50: // License at http://www.mozilla.org/MPL/
51: //
52: // Software distributed under the License is distributed on an "AS IS" basis,
53: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
54: // See the License for the specific language governing rights and limitations under the License.
55: //
56: // The Original Code is: all this file.
57: //
58: // The Initial Developer of the Original Code is Michael H. Kay.
59: //
60: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
61: //
62: // Contributor(s): None
63: //
|