< prev index next >
src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java
Print this page
rev 1063 : 8172974: [JAXP] XALAN: Wrong result when transforming namespace unaware StAX Input
*** 1,7 ****
/*
! * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
--- 1,7 ----
/*
! * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
*** 93,109 ****
* @author Morten Jorgensen
* @author G. Todd Miller
* @author Santiago Pericas-Geertsen
*/
public final class TransformerImpl extends Transformer
! implements DOMCache, ErrorListener
! {
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";
/**
* Namespace prefixes feature for {@link XMLReader}.
*/
private static final String NAMESPACE_PREFIXES_FEATURE =
--- 93,106 ----
* @author Morten Jorgensen
* @author G. Todd Miller
* @author Santiago Pericas-Geertsen
*/
public final class TransformerImpl extends Transformer
! implements DOMCache, ErrorListener {
private final static String LEXICAL_HANDLER_PROPERTY =
"http://xml.org/sax/properties/lexical-handler";
/**
* Namespace prefixes feature for {@link XMLReader}.
*/
private static final String NAMESPACE_PREFIXES_FEATURE =
*** 158,168 ****
* Number of indent spaces to add when indentation is on.
*/
private int _indentNumber = -1;
/**
! * A reference to the transformer factory that this templates
* object belongs to.
*/
private TransformerFactoryImpl _tfactory = null;
/**
--- 155,165 ----
* Number of indent spaces to add when indentation is on.
*/
private int _indentNumber = -1;
/**
! * A reference to the transformer factory that this transformer
* object belongs to.
*/
private TransformerFactoryImpl _tfactory = null;
/**
*** 180,194 ****
* A reference to an object that creates and caches XMLReader objects.
*/
private XMLReaderManager _readerManager;
/**
- * A flag indicating whether we use incremental building of the DTM.
- */
- //private boolean _isIncremental = false;
-
- /**
* A flag indicating whether this transformer implements the identity
* transform.
*/
private boolean _isIdentity = false;
--- 177,186 ----
*** 198,220 ****
private boolean _isSecureProcessing = false;
/**
* Indicates whether implementation parts should use
* service loader (or similar).
! * Note the default value (false) is the safe option..
*/
private boolean _useServicesMechanism;
/**
- * protocols allowed for external references set by the stylesheet processing instruction, Import and Include element.
- */
- private String _accessExternalStylesheet = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
- /**
* protocols allowed for external DTD references in source file and/or stylesheet.
*/
private String _accessExternalDTD = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
private XMLSecurityManager _securityManager;
/**
* A map to store parameters for the identity transform. These
* are not needed during the transformation, but we must keep track of
* them to be fully complaint with the JAXP API.
*/
--- 190,210 ----
private boolean _isSecureProcessing = false;
/**
* Indicates whether implementation parts should use
* service loader (or similar).
! * Note the default value (false) is the safe option.
*/
private boolean _useServicesMechanism;
+
/**
* protocols allowed for external DTD references in source file and/or stylesheet.
*/
private String _accessExternalDTD = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
private XMLSecurityManager _securityManager;
+
/**
* A map to store parameters for the identity transform. These
* are not needed during the transformation, but we must keep track of
* them to be fully complaint with the JAXP API.
*/
*** 244,255 ****
@Override
public void displayMessage(String msg) {
if(_errorListener == null) {
System.err.println(msg);
! }
! else {
try {
_errorListener.warning(new TransformerException(msg));
}
catch (TransformerException e) {
// ignored
--- 234,244 ----
@Override
public void displayMessage(String msg) {
if(_errorListener == null) {
System.err.println(msg);
! } else {
try {
_errorListener.warning(new TransformerException(msg));
}
catch (TransformerException e) {
// ignored
*** 261,271 ****
protected TransformerImpl(Properties outputProperties, int indentNumber,
TransformerFactoryImpl tfactory)
{
this(null, outputProperties, indentNumber, tfactory);
_isIdentity = true;
- // _properties.put(OutputKeys.METHOD, "xml");
}
protected TransformerImpl(Translet translet, Properties outputProperties,
int indentNumber, TransformerFactoryImpl tfactory)
{
--- 250,259 ----
*** 273,283 ****
_properties = createOutputProperties(outputProperties);
_propertiesClone = (Properties) _properties.clone();
_indentNumber = indentNumber;
_tfactory = tfactory;
_useServicesMechanism = _tfactory.useServicesMechnism();
- _accessExternalStylesheet = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET);
_accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD);
_securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER);
_readerManager = XMLReaderManager.getInstance(_useServicesMechanism);
_readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
_readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
--- 261,270 ----
*** 293,303 ****
if (catalogFiles != null) {
_readerManager.setFeature(XMLConstants.USE_CATALOG, _useCatalog);
_readerManager.setProperty(JdkXmlFeatures.CATALOG_FEATURES, _catalogFeatures);
}
}
- //_isIncremental = tfactory._incremental;
}
/**
* Return the state of the secure processing feature.
*/
--- 280,289 ----
*** 594,605 ****
_translet.prepassDocument(dom);
}
return dom;
! }
! catch (Exception e) {
if (_errorListener != null) {
postErrorToListener(e.getMessage());
}
throw new TransformerException(e);
}
--- 580,590 ----
_translet.prepassDocument(dom);
}
return dom;
! } catch (Exception e) {
if (_errorListener != null) {
postErrorToListener(e.getMessage());
}
throw new TransformerException(e);
}
*** 851,872 ****
// ignored - transformation cannot be continued
}
}
/**
- * Inform TrAX error listener of a warning
- */
- private void postWarningToListener(String message) {
- try {
- _errorListener.warning(new TransformerException(message));
- }
- catch (TransformerException e) {
- // ignored - transformation cannot be continued
- }
- }
-
- /**
* Implements JAXP's Transformer.getOutputProperties().
* Returns a copy of the output properties for the transformation. This is
* a set of layered properties. The first layer contains properties set by
* calls to setOutputProperty() and setOutputProperties() on this class,
* and the output settings defined in the stylesheet's <xsl:output>
--- 836,845 ----
*** 912,922 ****
@Override
public void setOutputProperties(Properties properties)
throws IllegalArgumentException
{
if (properties != null) {
! final Enumeration names = properties.propertyNames();
while (names.hasMoreElements()) {
final String name = (String) names.nextElement();
// Ignore lower layer properties
--- 885,895 ----
@Override
public void setOutputProperties(Properties properties)
throws IllegalArgumentException
{
if (properties != null) {
! final Enumeration<?> names = properties.propertyNames();
while (names.hasMoreElements()) {
final String name = (String) names.nextElement();
// Ignore lower layer properties
*** 965,975 ****
{
// Return right now if no properties are set
if (_properties == null) return;
// Get a list of all the defined properties
! Enumeration names = _properties.propertyNames();
while (names.hasMoreElements()) {
// Note the use of get() instead of getProperty()
String name = (String) names.nextElement();
String value = (String) _properties.get(name);
--- 938,948 ----
{
// Return right now if no properties are set
if (_properties == null) return;
// Get a list of all the defined properties
! Enumeration<?> names = _properties.propertyNames();
while (names.hasMoreElements()) {
// Note the use of get() instead of getProperty()
String name = (String) names.nextElement();
String value = (String) _properties.get(name);
*** 1044,1054 ****
String doctypePublic = null;
String doctypeSystem = null;
// Get a list of all the defined properties
! Enumeration names = _properties.propertyNames();
while (names.hasMoreElements()) {
// Note the use of get() instead of getProperty()
String name = (String) names.nextElement();
String value = (String) _properties.get(name);
--- 1017,1027 ----
String doctypePublic = null;
String doctypeSystem = null;
// Get a list of all the defined properties
! Enumeration<?> names = _properties.propertyNames();
while (names.hasMoreElements()) {
// Note the use of get() instead of getProperty()
String name = (String) names.nextElement();
String value = (String) _properties.get(name);
*** 1145,1155 ****
setDefaults(defaults, "xml");
// Copy propeties set in stylesheet to base
final Properties base = new Properties(defaults);
if (outputProperties != null) {
! final Enumeration names = outputProperties.propertyNames();
while (names.hasMoreElements()) {
final String name = (String) names.nextElement();
base.setProperty(name, outputProperties.getProperty(name));
}
}
--- 1118,1128 ----
setDefaults(defaults, "xml");
// Copy propeties set in stylesheet to base
final Properties base = new Properties(defaults);
if (outputProperties != null) {
! final Enumeration<?> names = outputProperties.propertyNames();
while (names.hasMoreElements()) {
final String name = (String) names.nextElement();
base.setProperty(name, outputProperties.getProperty(name));
}
}
*** 1182,1192 ****
private void setDefaults(Properties props, String method)
{
final Properties method_props =
OutputPropertiesFactory.getDefaultMethodProperties(method);
{
! final Enumeration names = method_props.propertyNames();
while (names.hasMoreElements())
{
final String name = (String)names.nextElement();
props.setProperty(name, method_props.getProperty(name));
}
--- 1155,1165 ----
private void setDefaults(Properties props, String method)
{
final Properties method_props =
OutputPropertiesFactory.getDefaultMethodProperties(method);
{
! final Enumeration<?> names = method_props.propertyNames();
while (names.hasMoreElements())
{
final String name = (String)names.nextElement();
props.setProperty(name, method_props.getProperty(name));
}
< prev index next >