net.sf.saxon.event
Class LocationCopier

java.lang.Object
  extended by net.sf.saxon.event.LocationCopier
All Implemented Interfaces:
CopyInformee, LocationProvider, SourceLocationProvider

public class LocationCopier
extends Object
implements CopyInformee, SourceLocationProvider

A Receiver that can be inserted into an event pipeline to copy location information. The class acts as a LocationProvider, so it supports getSystemId() and getLineNumber() methods; the location returned can vary for each node, and is set by the class generating the events. The class is used when it is necessary to copy a subtree along with its location information; for example, when copying an inline schema within a stylesheet to a separate schema document.

Note: prior to 9.2, the LocationCopier was a ProxyReceiver that passed all events on the pipeline unchanged. It no longer does this, instead it is found as the LocationProvider on a pipeline, but does not itself see the pipeline events.


Constructor Summary
LocationCopier(boolean wholeDocument)
           
 
Method Summary
 int getColumnNumber(long locationId)
          Get the column number within the document, entity, or module containing a particular location
 int getLineNumber(long locationId)
          Get the line number within the document, entity or module containing a particular location
 String getSystemId(long locationId)
          Get the URI of the document, entity, or module containing a particular location
 int notifyElementNode(NodeInfo element)
          Provide information about the node being copied.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocationCopier

public LocationCopier(boolean wholeDocument)
Method Detail

notifyElementNode

public int notifyElementNode(NodeInfo element)
Provide information about the node being copied. This method is called immediately before the startElement call for the element node in question.

Specified by:
notifyElementNode in interface CopyInformee
Parameters:
element - the node being copied, which must be an element node
Returns:
int a locationId to be used when referring to this element in the pipeline

getSystemId

public String getSystemId(long locationId)
Description copied from interface: LocationProvider
Get the URI of the document, entity, or module containing a particular location

Specified by:
getSystemId in interface LocationProvider
Parameters:
locationId - identifier of the location in question (as passed down the Receiver pipeline)
Returns:
the URI of the document, XML entity or module. For a SourceLocationProvider this will be the URI of the document or entity (the URI that would be the base URI if there were no xml:base attributes). In other cases it may identify the query or stylesheet module currently being executed.

getLineNumber

public int getLineNumber(long locationId)
Description copied from interface: LocationProvider
Get the line number within the document, entity or module containing a particular location

Specified by:
getLineNumber in interface LocationProvider
Parameters:
locationId - identifier of the location in question (as passed down the Receiver pipeline)
Returns:
the line number within the document, entity or module, or -1 if no information is available.

getColumnNumber

public int getColumnNumber(long locationId)
Description copied from interface: LocationProvider
Get the column number within the document, entity, or module containing a particular location

Specified by:
getColumnNumber in interface LocationProvider
Parameters:
locationId - identifier of the location in question (as passed down the Receiver pipeline)
Returns:
the column number within the document, entity, or module, or -1 if this is not available


Copyright (c) Saxonica Limited. All rights reserved.