src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java
Print this page
*** 97,110 ****
* @author Santiago Pericas-Geertsen
*/
public final class TransformerImpl extends Transformer
implements DOMCache, ErrorListener
{
- private final static String EMPTY_STRING = "";
- private final static String NO_STRING = "no";
- private final static String YES_STRING = "yes";
- private final static String XML_STRING = "xml";
private final static String LEXICAL_HANDLER_PROPERTY =
"http://xml.org/sax/properties/lexical-handler";
private static final String NAMESPACE_FEATURE =
"http://xml.org/sax/features/namespaces";
--- 97,106 ----
*** 154,164 ****
* A reference to an output handler factory.
*/
private TransletOutputHandlerFactory _tohFactory = null;
/**
! * A reference to a internal DOM represenation of the input.
*/
private DOM _dom = null;
/**
* Number of indent spaces to add when indentation is on.
--- 150,160 ----
* A reference to an output handler factory.
*/
private TransletOutputHandlerFactory _tohFactory = null;
/**
! * A reference to a internal DOM representation of the input.
*/
private DOM _dom = null;
/**
* Number of indent spaces to add when indentation is on.
*** 236,245 ****
--- 232,242 ----
public MessageHandler(ErrorListener errorListener) {
_errorListener = errorListener;
}
+ @Override
public void displayMessage(String msg) {
if(_errorListener == null) {
System.err.println(msg);
}
else {
*** 321,330 ****
--- 318,328 ----
*
* @param source Contains the input XML document
* @param result Will contain the output from the transformation
* @throws TransformerException
*/
+ @Override
public void transform(Source source, Result result)
throws TransformerException
{
if (!_isIdentity) {
if (_translet == null) {
*** 463,473 ****
}
// System Id may be in one of several forms, (1) a uri
// that starts with 'file:', (2) uri that starts with 'http:'
// or (3) just a filename on the local system.
! URL url = null;
if (systemId.startsWith("file:")) {
// if StreamResult(File) or setSystemID(File) was used,
// the systemId will be URI encoded as a result of File.toURI(),
// it must be decoded for use by URL
try{
--- 461,471 ----
}
// System Id may be in one of several forms, (1) a uri
// that starts with 'file:', (2) uri that starts with 'http:'
// or (3) just a filename on the local system.
! URL url;
if (systemId.startsWith("file:")) {
// if StreamResult(File) or setSystemID(File) was used,
// the systemId will be URI encoded as a result of File.toURI(),
// it must be decoded for use by URL
try{
*** 535,545 ****
/**
* Builds an internal DOM from a TrAX Source object
*/
private DOM getDOM(Source source) throws TransformerException {
try {
! DOM dom = null;
if (source != null) {
DTMWSFilter wsfilter;
if (_translet != null && _translet instanceof StripFilter) {
wsfilter = new DOMWSFilter(_translet);
--- 533,543 ----
/**
* Builds an internal DOM from a TrAX Source object
*/
private DOM getDOM(Source source) throws TransformerException {
try {
! DOM dom;
if (source != null) {
DTMWSFilter wsfilter;
if (_translet != null && _translet instanceof StripFilter) {
wsfilter = new DOMWSFilter(_translet);
*** 550,561 ****
boolean hasIdCall = (_translet != null) ? _translet.hasIdCall()
: false;
if (_dtmManager == null) {
_dtmManager =
! (XSLTCDTMManager)_tfactory.getDTMManagerClass()
! .newInstance();
_dtmManager.setServicesMechnism(_useServicesMechanism);
}
dom = (DOM)_dtmManager.getDTM(source, false, wsfilter, true,
false, false, 0, hasIdCall);
} else if (_dom != null) {
--- 548,558 ----
boolean hasIdCall = (_translet != null) ? _translet.hasIdCall()
: false;
if (_dtmManager == null) {
_dtmManager =
! _tfactory.createNewDTMManagerInstance();
_dtmManager.setServicesMechnism(_useServicesMechanism);
}
dom = (DOM)_dtmManager.getDTM(source, false, wsfilter, true,
false, false, 0, hasIdCall);
} else if (_dom != null) {
*** 674,685 ****
_readerManager.releaseXMLReader(reader);
}
}
} else if (source instanceof StAXSource) {
final StAXSource staxSource = (StAXSource)source;
! StAXEvent2SAX staxevent2sax = null;
! StAXStream2SAX staxStream2SAX = null;
if (staxSource.getXMLEventReader() != null) {
final XMLEventReader xmlEventReader = staxSource.getXMLEventReader();
staxevent2sax = new StAXEvent2SAX(xmlEventReader);
staxevent2sax.setContentHandler(handler);
staxevent2sax.parse();
--- 671,682 ----
_readerManager.releaseXMLReader(reader);
}
}
} else if (source instanceof StAXSource) {
final StAXSource staxSource = (StAXSource)source;
! StAXEvent2SAX staxevent2sax;
! StAXStream2SAX staxStream2SAX;
if (staxSource.getXMLEventReader() != null) {
final XMLEventReader xmlEventReader = staxSource.getXMLEventReader();
staxevent2sax = new StAXEvent2SAX(xmlEventReader);
staxevent2sax.setContentHandler(handler);
staxevent2sax.parse();
*** 768,777 ****
--- 765,775 ----
* Implements JAXP's Transformer.getErrorListener()
* Get the error event handler in effect for the transformation.
*
* @return The error event handler currently in effect
*/
+ @Override
public ErrorListener getErrorListener() {
return _errorListener;
}
/**
*** 781,790 ****
--- 779,789 ----
* xsl:messages to error listener.
*
* @param listener The error event listener to use
* @throws IllegalArgumentException
*/
+ @Override
public void setErrorListener(ErrorListener listener)
throws IllegalArgumentException {
if (listener == null) {
ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR,
"Transformer");
*** 828,838 ****
*/
private String makeCDATAString(Hashtable cdata) {
// Return a 'null' string if no CDATA section elements were specified
if (cdata == null) return null;
! StringBuffer result = new StringBuffer();
// Get an enumeration of all the elements in the hashtable
Enumeration elements = cdata.keys();
if (elements.hasMoreElements()) {
result.append((String)elements.nextElement());
--- 827,837 ----
*/
private String makeCDATAString(Hashtable cdata) {
// Return a 'null' string if no CDATA section elements were specified
if (cdata == null) return null;
! final StringBuilder result = new StringBuilder();
// Get an enumeration of all the elements in the hashtable
Enumeration elements = cdata.keys();
if (elements.hasMoreElements()) {
result.append((String)elements.nextElement());
*** 855,864 ****
--- 854,864 ----
* element makes up the second level, while the default XSLT output
* settings are returned on the third level.
*
* @return Properties in effect for this Transformer
*/
+ @Override
public Properties getOutputProperties() {
return (Properties) _properties.clone();
}
/**
*** 868,877 ****
--- 868,878 ----
* or it may be a property specified in the stylesheet.
*
* @param name A non-null string that contains the name of the property
* @throws IllegalArgumentException if the property name is not known
*/
+ @Override
public String getOutputProperty(String name)
throws IllegalArgumentException
{
if (!validOutputProperty(name)) {
ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNKNOWN_PROP_ERR, name);
*** 887,896 ****
--- 888,898 ----
* Unrecognised properties will be quitely ignored.
*
* @param properties The properties to use for the Transformer
* @throws IllegalArgumentException Never, errors are ignored
*/
+ @Override
public void setOutputProperties(Properties properties)
throws IllegalArgumentException
{
if (properties != null) {
final Enumeration names = properties.propertyNames();
*** 923,932 ****
--- 925,935 ----
*
* @param name The name of the property to set
* @param value The value to assign to the property
* @throws IllegalArgumentException Never, errors are ignored
*/
+ @Override
public void setOutputProperty(String name, String value)
throws IllegalArgumentException
{
if (!validOutputProperty(name)) {
ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNKNOWN_PROP_ERR, name);
*** 1203,1212 ****
--- 1206,1216 ----
* parameters are quitely ignored by the translet.
*
* @param name The name of the parameter
* @param value The value to assign to the parameter
*/
+ @Override
public void setParameter(String name, Object value) {
if (value == null) {
ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_INVALID_SET_PARAM_VALUE, name);
throw new IllegalArgumentException(err.toString());
*** 1226,1235 ****
--- 1230,1240 ----
/**
* Implements JAXP's Transformer.clearParameters()
* Clear all parameters set with setParameter. Clears the translet's
* parameter stack.
*/
+ @Override
public void clearParameters() {
if (_isIdentity && _parameters != null) {
_parameters.clear();
}
else {
*** 1243,1252 ****
--- 1248,1258 ----
* keep values for parameters that were not defined in the stylesheet.
*
* @param name The name of the parameter
* @return An object that contains the value assigned to the parameter
*/
+ @Override
public final Object getParameter(String name) {
if (_isIdentity) {
return (_parameters != null) ? _parameters.get(name) : null;
}
else {
*** 1258,1277 ****
--- 1264,1285 ----
* Implements JAXP's Transformer.getURIResolver()
* Set the object currently used to resolve URIs used in document().
*
* @return The URLResolver object currently in use
*/
+ @Override
public URIResolver getURIResolver() {
return _uriResolver;
}
/**
* Implements JAXP's Transformer.setURIResolver()
* Set an object that will be used to resolve URIs used in document().
*
* @param resolver The URIResolver to use in document()
*/
+ @Override
public void setURIResolver(URIResolver resolver) {
_uriResolver = resolver;
}
/**
*** 1286,1295 ****
--- 1294,1304 ----
*
* @param baseURI The base URI used by the document call.
* @param href The href argument passed to the document function.
* @param translet A reference to the translet requesting the document
*/
+ @Override
public DOM retrieveDocument(String baseURI, String href, Translet translet) {
try {
// Argument to document function was: document('');
if (href.length() == 0) {
href = baseURI;
*** 1328,1337 ****
--- 1337,1347 ----
* @param e The warning information encapsulated in a transformer
* exception.
* @throws TransformerException if the application chooses to discontinue
* the transformation (always does in our case).
*/
+ @Override
public void error(TransformerException e)
throws TransformerException
{
Throwable wrapped = e.getException();
if (wrapped != null) {
*** 1356,1365 ****
--- 1366,1376 ----
* @param e The warning information encapsulated in a transformer
* exception.
* @throws TransformerException if the application chooses to discontinue
* the transformation (always does in our case).
*/
+ @Override
public void fatalError(TransformerException e)
throws TransformerException
{
Throwable wrapped = e.getException();
if (wrapped != null) {
*** 1384,1393 ****
--- 1395,1405 ----
* @param e The warning information encapsulated in a transformer
* exception.
* @throws TransformerException if the application chooses to discontinue
* the transformation (never does in our case).
*/
+ @Override
public void warning(TransformerException e)
throws TransformerException
{
Throwable wrapped = e.getException();
if (wrapped != null) {
*** 1404,1413 ****
--- 1416,1426 ----
* This method resets the Transformer to its original configuration
* Transformer code is reset to the same state it was when it was
* created
* @since 1.5
*/
+ @Override
public void reset() {
_method = null;
_encoding = null;
_sourceSystemId = null;