This commit is contained in:
Lana Steuck 2014-06-12 15:39:03 -07:00
commit 1bf00bfcea
32 changed files with 925 additions and 544 deletions

View File

@ -3,9 +3,11 @@
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /*
* Copyright 2001-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
@ -32,7 +34,6 @@ import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Vector;
import javax.xml.transform.Templates; import javax.xml.transform.Templates;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -51,6 +52,7 @@ import com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex;
import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory; import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
import com.sun.org.apache.xml.internal.serializer.SerializationHandler; import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
import com.sun.org.apache.xml.internal.serializer.ToStream;
/** /**
* @author Jacek Ambroziak * @author Jacek Ambroziak
@ -74,7 +76,7 @@ public abstract class AbstractTranslet implements Translet {
public String _doctypeSystem = null; public String _doctypeSystem = null;
public boolean _indent = false; public boolean _indent = false;
public String _mediaType = null; public String _mediaType = null;
public Vector _cdata = null; public ArrayList<String> _cdata = null;
public int _indentamount = -1; public int _indentamount = -1;
public static final int FIRST_TRANSLET_VERSION = 100; public static final int FIRST_TRANSLET_VERSION = 100;
@ -642,7 +644,7 @@ public abstract class AbstractTranslet implements Translet {
*/ */
public void addCdataElement(String name) { public void addCdataElement(String name) {
if (_cdata == null) { if (_cdata == null) {
_cdata = new Vector(); _cdata = new ArrayList<>();
} }
int lastColon = name.lastIndexOf(':'); int lastColon = name.lastIndexOf(':');
@ -650,11 +652,11 @@ public abstract class AbstractTranslet implements Translet {
if (lastColon > 0) { if (lastColon > 0) {
String uri = name.substring(0, lastColon); String uri = name.substring(0, lastColon);
String localName = name.substring(lastColon+1); String localName = name.substring(lastColon+1);
_cdata.addElement(uri); _cdata.add(uri);
_cdata.addElement(localName); _cdata.add(localName);
} else { } else {
_cdata.addElement(null); _cdata.add(null);
_cdata.addElement(name); _cdata.add(name);
} }
} }

View File

@ -3,9 +3,11 @@
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /*
* Copyright 2001-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
@ -40,7 +42,7 @@ import java.net.UnknownServiceException;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Properties; import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector; import java.util.ArrayList;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
@ -1084,7 +1086,7 @@ public final class TransformerImpl extends Transformer
else if (name.equals(OutputKeys.CDATA_SECTION_ELEMENTS)) { else if (name.equals(OutputKeys.CDATA_SECTION_ELEMENTS)) {
if (value != null) { if (value != null) {
StringTokenizer e = new StringTokenizer(value); StringTokenizer e = new StringTokenizer(value);
Vector uriAndLocalNames = null; ArrayList<String> uriAndLocalNames = null;
while (e.hasMoreTokens()) { while (e.hasMoreTokens()) {
final String token = e.nextToken(); final String token = e.nextToken();
@ -1104,11 +1106,11 @@ public final class TransformerImpl extends Transformer
} }
if (uriAndLocalNames == null) { if (uriAndLocalNames == null) {
uriAndLocalNames = new Vector(); uriAndLocalNames = new ArrayList<>();
} }
// add the uri/localName as a pair, in that order // add the uri/localName as a pair, in that order
uriAndLocalNames.addElement(uri); uriAndLocalNames.add(uri);
uriAndLocalNames.addElement(localName); uriAndLocalNames.add(localName);
} }
handler.setCdataSectionElements(uriAndLocalNames); handler.setCdataSectionElements(uriAndLocalNames);
} }

View File

@ -347,7 +347,7 @@ implements EntityReference {
* @see DocumentTypeImpl * @see DocumentTypeImpl
* @see EntityImpl * @see EntityImpl
*/ */
// The Xerces parser invokes callbacks for startEnityReference // The Xerces parser invokes callbacks for startEntityReference
// the parsed value of the entity EACH TIME, so it is actually // the parsed value of the entity EACH TIME, so it is actually
// easier to create the nodes through the callbacks rather than // easier to create the nodes through the callbacks rather than
// clone the Entity. // clone the Entity.

View File

@ -585,7 +585,7 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
boolean reportEntity = fReportEntity; boolean reportEntity = fReportEntity;
if (name.startsWith("%")) { if (name.startsWith("%")) {
reportEntity = peekReportEntity(); reportEntity = peekReportEntity();
// check well-formedness of the enity // check well-formedness of the entity
int startMarkUpDepth = popPEStack(); int startMarkUpDepth = popPEStack();
// throw fatalError if this entity was incomplete and // throw fatalError if this entity was incomplete and
// was a freestanding decl // was a freestanding decl

View File

@ -2728,7 +2728,7 @@ public class XMLDocumentFragmentScannerImpl
//if the last section was character data //if the last section was character data
if(fLastSectionWasCharacterData){ if(fLastSectionWasCharacterData){
//if we dont encounter any CDATA or ENITY REFERENCE and current state is also not SCANNER_STATE_CHARACTER_DATA //if we dont encounter any CDATA or ENTITY REFERENCE and current state is also not SCANNER_STATE_CHARACTER_DATA
//return the last scanned charactrer data. //return the last scanned charactrer data.
if((fScannerState != SCANNER_STATE_CDATA) && (fScannerState != SCANNER_STATE_REFERENCE) if((fScannerState != SCANNER_STATE_CDATA) && (fScannerState != SCANNER_STATE_REFERENCE)
&& (fScannerState != SCANNER_STATE_CHARACTER_DATA)){ && (fScannerState != SCANNER_STATE_CHARACTER_DATA)){

View File

@ -1218,7 +1218,7 @@ public class XMLDTDValidator
// references appear in the document. // references appear in the document.
// REVISIT: this can be combined to a single check in // REVISIT: this can be combined to a single check in
// startEntity if we add one more argument in // startEntity if we add one more argument in
// startEnity, inAttrValue // startEntity, inAttrValue
String nonNormalizedValue = attributes.getNonNormalizedValue(i); String nonNormalizedValue = attributes.getNonNormalizedValue(i);
if (nonNormalizedValue != null) { if (nonNormalizedValue != null) {
String entityName = getExternalEntityRefInAttrValue(nonNormalizedValue); String entityName = getExternalEntityRefInAttrValue(nonNormalizedValue);

View File

@ -559,11 +559,13 @@ final class ElementSchemePointer implements XPointerPart {
* @param token The token string * @param token The token string
*/ */
private void addToken(String tokenStr) { private void addToken(String tokenStr) {
if (!fTokenNames.containsValue(tokenStr)) { String str = fTokenNames.get(tokenStr);
Integer tokenInt = new Integer(fTokenNames.size()); Integer tokenInt = str == null ? null : Integer.parseInt(str);
if (tokenInt == null) {
tokenInt = new Integer(fTokenNames.size());
fTokenNames.put(tokenInt, tokenStr); fTokenNames.put(tokenInt, tokenStr);
addToken(tokenInt.intValue());
} }
addToken(tokenInt.intValue());
} }
/** /**

View File

@ -524,11 +524,13 @@ public final class XPointerHandler extends XIncludeHandler implements
* @param token The token string * @param token The token string
*/ */
private void addToken(String tokenStr) { private void addToken(String tokenStr) {
if (!fTokenNames.containsValue(tokenStr)) { String str = fTokenNames.get(tokenStr);
Integer tokenInt = new Integer(fTokenNames.size()); Integer tokenInt = str == null ? null : Integer.parseInt(str);
if (tokenInt == null) {
tokenInt = new Integer(fTokenNames.size());
fTokenNames.put(tokenInt, tokenStr); fTokenNames.put(tokenInt, tokenStr);
addToken(tokenInt.intValue());
} }
addToken(tokenInt.intValue());
} }
/** /**
@ -1251,4 +1253,4 @@ public final class XPointerHandler extends XIncludeHandler implements
super.setProperty(propertyId, value); super.setProperty(propertyId, value);
} }
} }

View File

@ -32,7 +32,7 @@ public class DTMConfigurationException extends DTMException {
/** /**
* Create a new <code>DTMConfigurationException</code> with no * Create a new <code>DTMConfigurationException</code> with no
* detail mesage. * detail message.
*/ */
public DTMConfigurationException() { public DTMConfigurationException() {
super("Configuration Error"); super("Configuration Error");

View File

@ -3,9 +3,11 @@
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /*
* Copyright 2003-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
@ -27,7 +29,7 @@ import java.io.OutputStream;
import java.io.Writer; import java.io.Writer;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Properties; import java.util.Properties;
import java.util.Vector; import java.util.ArrayList;
import javax.xml.transform.SourceLocator; import javax.xml.transform.SourceLocator;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
@ -150,9 +152,9 @@ public class EmptySerializer implements SerializationHandler
couldThrowIOException(); couldThrowIOException();
} }
/** /**
* @see SerializationHandler#setCdataSectionElements(java.util.Vector) * @see SerializationHandler#setCdataSectionElements(java.util.ArrayList<String>)
*/ */
public void setCdataSectionElements(Vector URI_and_localNames) public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
{ {
aMethodIsCalled(); aMethodIsCalled();
} }
@ -763,4 +765,25 @@ public class EmptySerializer implements SerializationHandler
aMethodIsCalled(); aMethodIsCalled();
} }
public String getOutputProperty(String name) {
aMethodIsCalled();
return null;
}
public String getOutputPropertyDefault(String name) {
aMethodIsCalled();
return null;
}
public void setOutputProperty(String name, String val) {
aMethodIsCalled();
}
public void setOutputPropertyDefault(String name, String val) {
aMethodIsCalled();
}
} }

View File

@ -3,9 +3,11 @@
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /*
* Copyright 2001-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
@ -23,8 +25,11 @@
package com.sun.org.apache.xml.internal.serializer; package com.sun.org.apache.xml.internal.serializer;
import java.io.IOException; import java.io.IOException;
import java.util.Vector; import java.util.HashMap;
import java.util.Set;
import java.util.ArrayList;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.SourceLocator; import javax.xml.transform.SourceLocator;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
@ -108,12 +113,12 @@ public abstract class SerializerBase
/** /**
* The System ID for the doc type. * The System ID for the doc type.
*/ */
private String m_doctypeSystem; protected String m_doctypeSystem;
/** /**
* The public ID for the doc type. * The public ID for the doc type.
*/ */
private String m_doctypePublic; protected String m_doctypePublic;
/** /**
* Flag to tell that we need to add the doctype decl, which we can't do * Flag to tell that we need to add the doctype decl, which we can't do
@ -121,16 +126,10 @@ public abstract class SerializerBase
*/ */
boolean m_needToOutputDocTypeDecl = true; boolean m_needToOutputDocTypeDecl = true;
/**
* The character encoding. Must match the encoding used for the
* printWriter.
*/
private String m_encoding = null;
/** /**
* Tells if we should write the XML declaration. * Tells if we should write the XML declaration.
*/ */
private boolean m_shouldNotWriteXMLHeader = false; protected boolean m_shouldNotWriteXMLHeader = false;
/** /**
* The standalone value for the doctype. * The standalone value for the doctype.
@ -159,12 +158,12 @@ public abstract class SerializerBase
/** /**
* Tells the XML version, for writing out to the XML decl. * Tells the XML version, for writing out to the XML decl.
*/ */
private String m_version = null; protected String m_version = null;
/** /**
* The mediatype. Not used right now. * The mediatype. Not used right now.
*/ */
private String m_mediatype; protected String m_mediatype;
/** /**
* The transformer that was around when this output handler was created (if * The transformer that was around when this output handler was created (if
@ -172,13 +171,6 @@ public abstract class SerializerBase
*/ */
private Transformer m_transformer; private Transformer m_transformer;
/**
* Pairs of local names and corresponding URIs of CDATA sections. This list
* comes from the cdata-section-elements attribute. Every second one is a
* local name, and every other second one is the URI for the local name.
*/
protected Vector m_cdataSectionElements = null;
/** /**
* Namespace support, that keeps track of currently defined * Namespace support, that keeps track of currently defined
* prefix/uri mappings. As processed elements come and go, so do * prefix/uri mappings. As processed elements come and go, so do
@ -538,16 +530,16 @@ public abstract class SerializerBase
*/ */
public String getEncoding() public String getEncoding()
{ {
return m_encoding; return getOutputProperty(OutputKeys.ENCODING);
} }
/** /**
* Sets the character encoding coming from the xsl:output encoding stylesheet attribute. * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
* @param m_encoding the character encoding * @param m_encoding the character encoding
*/ */
public void setEncoding(String m_encoding) public void setEncoding(String encoding)
{ {
this.m_encoding = m_encoding; setOutputProperty(OutputKeys.ENCODING,encoding);
} }
/** /**
@ -557,7 +549,8 @@ public abstract class SerializerBase
*/ */
public void setOmitXMLDeclaration(boolean b) public void setOmitXMLDeclaration(boolean b)
{ {
this.m_shouldNotWriteXMLHeader = b; String val = b ? "yes":"no";
setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,val);
} }
@ -588,7 +581,7 @@ public abstract class SerializerBase
*/ */
public void setDoctypePublic(String doctypePublic) public void setDoctypePublic(String doctypePublic)
{ {
this.m_doctypePublic = doctypePublic; setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctypePublic);
} }
@ -610,7 +603,7 @@ public abstract class SerializerBase
*/ */
public void setDoctypeSystem(String doctypeSystem) public void setDoctypeSystem(String doctypeSystem)
{ {
this.m_doctypeSystem = doctypeSystem; setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctypeSystem);
} }
/** Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties /** Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
@ -621,8 +614,8 @@ public abstract class SerializerBase
*/ */
public void setDoctype(String doctypeSystem, String doctypePublic) public void setDoctype(String doctypeSystem, String doctypePublic)
{ {
this.m_doctypeSystem = doctypeSystem; setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctypeSystem);
this.m_doctypePublic = doctypePublic; setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctypePublic);
} }
/** /**
@ -634,12 +627,9 @@ public abstract class SerializerBase
*/ */
public void setStandalone(String standalone) public void setStandalone(String standalone)
{ {
if (standalone != null) setOutputProperty(OutputKeys.STANDALONE, standalone);
{
m_standaloneWasSpecified = true;
setStandaloneInternal(standalone);
}
} }
/** /**
* Sets the XSL standalone attribute, but does not remember if this is a * Sets the XSL standalone attribute, but does not remember if this is a
* default or explicite setting. * default or explicite setting.
@ -700,7 +690,7 @@ public abstract class SerializerBase
*/ */
public void setVersion(String version) public void setVersion(String version)
{ {
m_version = version; setOutputProperty(OutputKeys.VERSION, version);
} }
/** /**
@ -712,7 +702,7 @@ public abstract class SerializerBase
*/ */
public void setMediaType(String mediaType) public void setMediaType(String mediaType)
{ {
m_mediatype = mediaType; setOutputProperty(OutputKeys.MEDIA_TYPE,mediaType);
} }
/** /**
@ -741,7 +731,8 @@ public abstract class SerializerBase
*/ */
public void setIndent(boolean doIndent) public void setIndent(boolean doIndent)
{ {
m_doIndent = doIndent; String val = doIndent ? "yes":"no";
setOutputProperty(OutputKeys.INDENT,val);
} }
/** /**
@ -786,59 +777,6 @@ public abstract class SerializerBase
return this; return this;
} }
/**
* Push a boolean state based on if the name of the current element
* is found in the list of qnames. A state is only pushed if
* there were some cdata-section-names were specified.
* <p>
* Hidden parameters are the vector of qualified elements specified in
* cdata-section-names attribute, and the m_cdataSectionStates stack
* onto which whether the current element is in the list is pushed (true or
* false). Other hidden parameters are the current elements namespaceURI,
* localName and qName
*/
protected boolean isCdataSection()
{
boolean b = false;
if (null != m_cdataSectionElements)
{
if (m_elemContext.m_elementLocalName == null)
m_elemContext.m_elementLocalName =
getLocalName(m_elemContext.m_elementName);
if (m_elemContext.m_elementURI == null)
{
String prefix = getPrefixPart(m_elemContext.m_elementName);
if (prefix != null)
m_elemContext.m_elementURI =
m_prefixMap.lookupNamespace(prefix);
}
if ((null != m_elemContext.m_elementURI)
&& m_elemContext.m_elementURI.length() == 0)
m_elemContext.m_elementURI = null;
int nElems = m_cdataSectionElements.size();
// loop through 2 at a time, as these are pairs of URI and localName
for (int i = 0; i < nElems; i += 2)
{
String uri = (String) m_cdataSectionElements.elementAt(i);
String loc = (String) m_cdataSectionElements.elementAt(i + 1);
if (loc.equals(m_elemContext.m_elementLocalName)
&& subPartMatch(m_elemContext.m_elementURI, uri))
{
b = true;
break;
}
}
}
return b;
}
/** /**
* Tell if two strings are equal, without worry if the first string is null. * Tell if two strings are equal, without worry if the first string is null.
* *
@ -1312,12 +1250,11 @@ public abstract class SerializerBase
private void resetSerializerBase() private void resetSerializerBase()
{ {
this.m_attributes.clear(); this.m_attributes.clear();
this.m_cdataSectionElements = null; this.m_StringOfCDATASections = null;
this.m_elemContext = new ElemContext(); this.m_elemContext = new ElemContext();
this.m_doctypePublic = null; this.m_doctypePublic = null;
this.m_doctypeSystem = null; this.m_doctypeSystem = null;
this.m_doIndent = false; this.m_doIndent = false;
this.m_encoding = null;
this.m_indentAmount = 0; this.m_indentAmount = 0;
this.m_inEntityRef = false; this.m_inEntityRef = false;
this.m_inExternalDTD = false; this.m_inExternalDTD = false;
@ -1399,4 +1336,333 @@ public abstract class SerializerBase
// A particular sub-class of SerializerBase provides the implementation (if desired) // A particular sub-class of SerializerBase provides the implementation (if desired)
} }
/**
* The CDATA section names stored in a whitespace separateed list with
* each element being a word of the form "{uri}localName" This list
* comes from the cdata-section-elements attribute.
*
* This field replaces m_cdataSectionElements Vector.
*/
protected String m_StringOfCDATASections = null;
boolean m_docIsEmpty = true;
void initCdataElems(String s)
{
if (s != null)
{
int max = s.length();
// true if we are in the middle of a pair of curly braces that delimit a URI
boolean inCurly = false;
// true if we found a URI but haven't yet processed the local name
boolean foundURI = false;
StringBuilder buf = new StringBuilder();
String uri = null;
String localName = null;
// parse through string, breaking on whitespaces. I do this instead
// of a tokenizer so I can track whitespace inside of curly brackets,
// which theoretically shouldn't happen if they contain legal URLs.
for (int i = 0; i < max; i++)
{
char c = s.charAt(i);
if (Character.isWhitespace(c))
{
if (!inCurly)
{
if (buf.length() > 0)
{
localName = buf.toString();
if (!foundURI)
uri = "";
addCDATAElement(uri,localName);
buf.setLength(0);
foundURI = false;
}
continue;
}
else
buf.append(c); // add whitespace to the URI
}
else if ('{' == c) // starting a URI
inCurly = true;
else if ('}' == c)
{
// we just ended a URI
foundURI = true;
uri = buf.toString();
buf.setLength(0);
inCurly = false;
}
else
{
// append non-whitespace, non-curly to current URI or localName being gathered.
buf.append(c);
}
}
if (buf.length() > 0)
{
// We have one last localName to process.
localName = buf.toString();
if (!foundURI)
uri = "";
addCDATAElement(uri,localName);
}
}
}
protected java.util.HashMap<String, HashMap<String, String>> m_CdataElems = null;
private void addCDATAElement(String uri, String localName)
{
if (m_CdataElems == null) {
m_CdataElems = new java.util.HashMap<>();
}
HashMap<String,String> h = m_CdataElems.get(localName);
if (h == null) {
h = new HashMap<>();
m_CdataElems.put(localName,h);
}
h.put(uri,uri);
}
/**
* Return true if nothing has been sent to this result tree yet.
* <p>
* This is not a public API.
*
* @xsl.usage internal
*/
public boolean documentIsEmpty() {
// If we haven't called startDocument() yet, then this document is empty
return m_docIsEmpty && (m_elemContext.m_currentElemDepth == 0);
}
/**
* Return true if the current element in m_elemContext
* is a CDATA section.
* CDATA sections are specified in the <xsl:output> attribute
* cdata-section-names or in the JAXP equivalent property.
* In any case the format of the value of such a property is:
* <pre>
* "{uri1}localName1 {uri2}localName2 . . . "
* </pre>
*
* <p>
* This method is not a public API, but is only used internally by the serializer.
*/
protected boolean isCdataSection() {
boolean b = false;
if (null != m_StringOfCDATASections) {
if (m_elemContext.m_elementLocalName == null) {
String localName = getLocalName(m_elemContext.m_elementName);
m_elemContext.m_elementLocalName = localName;
}
if ( m_elemContext.m_elementURI == null) {
m_elemContext.m_elementURI = getElementURI();
}
else if ( m_elemContext.m_elementURI.length() == 0) {
if ( m_elemContext.m_elementName == null) {
m_elemContext.m_elementName = m_elemContext.m_elementLocalName;
// leave URI as "", meaning in no namespace
}
else if (m_elemContext.m_elementLocalName.length() < m_elemContext.m_elementName.length()){
// We were told the URI was "", yet the name has a prefix since the name is longer than the localname.
// So we will fix that incorrect information here.
m_elemContext.m_elementURI = getElementURI();
}
}
HashMap<String, String> h = null;
if (m_CdataElems != null) {
h = m_CdataElems.get(m_elemContext.m_elementLocalName);
}
if (h != null) {
Object obj = h.get(m_elemContext.m_elementURI);
if (obj != null)
b = true;
}
}
return b;
}
/**
* Before this call m_elementContext.m_elementURI is null,
* which means it is not yet known. After this call it
* is non-null, but possibly "" meaning that it is in the
* default namespace.
*
* @return The URI of the element, never null, but possibly "".
*/
private String getElementURI() {
String uri = null;
// At this point in processing we have received all the
// namespace mappings
// As we still don't know the elements namespace,
// we now figure it out.
String prefix = getPrefixPart(m_elemContext.m_elementName);
if (prefix == null) {
// no prefix so lookup the URI of the default namespace
uri = m_prefixMap.lookupNamespace("");
} else {
uri = m_prefixMap.lookupNamespace(prefix);
}
if (uri == null) {
// We didn't find the namespace for the
// prefix ... ouch, that shouldn't happen.
// This is a hack, we really don't know
// the namespace
uri = EMPTYSTRING;
}
return uri;
}
/**
* Get the value of an output property,
* the explicit value, if any, otherwise the
* default value, if any, otherwise null.
*/
public String getOutputProperty(String name) {
String val = getOutputPropertyNonDefault(name);
// If no explicit value, try to get the default value
if (val == null)
val = getOutputPropertyDefault(name);
return val;
}
/**
* Get the value of an output property,
* not the default value. If there is a default
* value, but no non-default value this method
* will return null.
* <p>
*
*/
public String getOutputPropertyNonDefault(String name) {
return getProp(name,false);
}
/**
* Get the default value of an xsl:output property,
* which would be null only if no default value exists
* for the property.
*/
public String getOutputPropertyDefault(String name) {
return getProp(name, true);
}
/**
* Set the value for the output property, typically from
* an xsl:output element, but this does not change what
* the default value is.
*/
public void setOutputProperty(String name, String val) {
setProp(name,val,false);
}
/**
* Set the default value for an output property, but this does
* not impact any explicitly set value.
*/
public void setOutputPropertyDefault(String name, String val) {
setProp(name,val,true);
}
/**
* A mapping of keys to explicitly set values, for example if
* and <xsl:output/> has an "encoding" attribute, this
* map will have what that attribute maps to.
*/
private HashMap<String, String> m_OutputProps;
/**
* A mapping of keys to default values, for example if
* the default value of the encoding is "UTF-8" then this
* map will have that "encoding" maps to "UTF-8".
*/
private HashMap<String, String> m_OutputPropsDefault;
Set<String> getOutputPropDefaultKeys() {
return m_OutputPropsDefault.keySet();
}
Set<String> getOutputPropKeys() {
return m_OutputProps.keySet();
}
private String getProp(String name, boolean defaultVal) {
if (m_OutputProps == null) {
m_OutputProps = new HashMap<>();
m_OutputPropsDefault = new HashMap<>();
}
String val;
if (defaultVal)
val = m_OutputPropsDefault.get(name);
else
val = m_OutputProps.get(name);
return val;
}
/**
*
* @param name The name of the property, e.g. "{http://myprop}indent-tabs" or "indent".
* @param val The value of the property, e.g. "4"
* @param defaultVal true if this is a default value being set for the property as
* opposed to a user define on, set say explicitly in the stylesheet or via JAXP
*/
void setProp(String name, String val, boolean defaultVal) {
if (m_OutputProps == null) {
m_OutputProps = new HashMap<>();
m_OutputPropsDefault = new HashMap<>();
}
if (defaultVal)
m_OutputPropsDefault.put(name,val);
else {
if (OutputKeys.CDATA_SECTION_ELEMENTS.equals(name) && val != null) {
initCdataElems(val);
String oldVal = m_OutputProps.get(name);
String newVal;
if (oldVal == null)
newVal = oldVal + ' ' + val;
else
newVal = val;
m_OutputProps.put(name,newVal);
}
else {
m_OutputProps.put(name,val);
}
}
}
/**
* Get the first char of the local name
* @param name Either a local name, or a local name
* preceeded by a uri enclosed in curly braces.
*/
static char getFirstCharLocName(String name) {
final char first;
int i = name.indexOf('}');
if (i < 0)
first = name.charAt(0);
else
first = name.charAt(i+1);
return first;
}
} }

View File

@ -3,9 +3,11 @@
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /*
* Copyright 2001-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
@ -349,84 +351,84 @@ public final class ToHTMLStream extends ToStream
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("A"); elemDesc = (ElemDesc) m_elementFlags.get("a");
elemDesc.setAttr("HREF", ElemDesc.ATTRURL); elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
elemDesc.setAttr("NAME", ElemDesc.ATTRURL); elemDesc.setAttr("NAME", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("AREA"); elemDesc = (ElemDesc) m_elementFlags.get("area");
elemDesc.setAttr("HREF", ElemDesc.ATTRURL); elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
elemDesc.setAttr("NOHREF", ElemDesc.ATTREMPTY); elemDesc.setAttr("NOHREF", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("BASE"); elemDesc = (ElemDesc) m_elementFlags.get("base");
elemDesc.setAttr("HREF", ElemDesc.ATTRURL); elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("BUTTON"); elemDesc = (ElemDesc) m_elementFlags.get("button");
elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY); elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("BLOCKQUOTE"); elemDesc = (ElemDesc) m_elementFlags.get("blockquote");
elemDesc.setAttr("CITE", ElemDesc.ATTRURL); elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("DEL"); elemDesc = (ElemDesc) m_elementFlags.get("del");
elemDesc.setAttr("CITE", ElemDesc.ATTRURL); elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("DIR"); elemDesc = (ElemDesc) m_elementFlags.get("dir");
elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY); elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("DIV"); elemDesc = (ElemDesc) m_elementFlags.get("div");
elemDesc.setAttr("SRC", ElemDesc.ATTRURL); // Netscape 4 extension elemDesc.setAttr("SRC", ElemDesc.ATTRURL); // Netscape 4 extension
elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("DL"); elemDesc = (ElemDesc) m_elementFlags.get("dl");
elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY); elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("FORM"); elemDesc = (ElemDesc) m_elementFlags.get("form");
elemDesc.setAttr("ACTION", ElemDesc.ATTRURL); elemDesc.setAttr("ACTION", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
// Attribution to: "Voytenko, Dimitry" <DVoytenko@SECTORBASE.COM> // Attribution to: "Voytenko, Dimitry" <DVoytenko@SECTORBASE.COM>
elemDesc = (ElemDesc) m_elementFlags.get("FRAME"); elemDesc = (ElemDesc) m_elementFlags.get("frame");
elemDesc.setAttr("SRC", ElemDesc.ATTRURL); elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL); elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
elemDesc.setAttr("NORESIZE",ElemDesc.ATTREMPTY); elemDesc.setAttr("NORESIZE",ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("HEAD"); elemDesc = (ElemDesc) m_elementFlags.get("head");
elemDesc.setAttr("PROFILE", ElemDesc.ATTRURL); elemDesc.setAttr("PROFILE", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("HR"); elemDesc = (ElemDesc) m_elementFlags.get("hr");
elemDesc.setAttr("NOSHADE", ElemDesc.ATTREMPTY); elemDesc.setAttr("NOSHADE", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
// HTML 4.0, section 16.5 // HTML 4.0, section 16.5
elemDesc = (ElemDesc) m_elementFlags.get("IFRAME"); elemDesc = (ElemDesc) m_elementFlags.get("iframe");
elemDesc.setAttr("SRC", ElemDesc.ATTRURL); elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL); elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
// Netscape 4 extension // Netscape 4 extension
elemDesc = (ElemDesc) m_elementFlags.get("ILAYER"); elemDesc = (ElemDesc) m_elementFlags.get("ilayer");
elemDesc.setAttr("SRC", ElemDesc.ATTRURL); elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("IMG"); elemDesc = (ElemDesc) m_elementFlags.get("img");
elemDesc.setAttr("SRC", ElemDesc.ATTRURL); elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL); elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL); elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
elemDesc.setAttr("ISMAP", ElemDesc.ATTREMPTY); elemDesc.setAttr("ISMAP", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("INPUT"); elemDesc = (ElemDesc) m_elementFlags.get("input");
elemDesc.setAttr("SRC", ElemDesc.ATTRURL); elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL); elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
elemDesc.setAttr("CHECKED", ElemDesc.ATTREMPTY); elemDesc.setAttr("CHECKED", ElemDesc.ATTREMPTY);
@ -435,24 +437,24 @@ public final class ToHTMLStream extends ToStream
elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY); elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("INS"); elemDesc = (ElemDesc) m_elementFlags.get("ins");
elemDesc.setAttr("CITE", ElemDesc.ATTRURL); elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
// Netscape 4 extension // Netscape 4 extension
elemDesc = (ElemDesc) m_elementFlags.get("LAYER"); elemDesc = (ElemDesc) m_elementFlags.get("layer");
elemDesc.setAttr("SRC", ElemDesc.ATTRURL); elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("LINK"); elemDesc = (ElemDesc) m_elementFlags.get("link");
elemDesc.setAttr("HREF", ElemDesc.ATTRURL); elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("MENU"); elemDesc = (ElemDesc) m_elementFlags.get("menu");
elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY); elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("OBJECT"); elemDesc = (ElemDesc) m_elementFlags.get("object");
elemDesc.setAttr("CLASSID", ElemDesc.ATTRURL); elemDesc.setAttr("CLASSID", ElemDesc.ATTRURL);
elemDesc.setAttr("CODEBASE", ElemDesc.ATTRURL); elemDesc.setAttr("CODEBASE", ElemDesc.ATTRURL);
elemDesc.setAttr("DATA", ElemDesc.ATTRURL); elemDesc.setAttr("DATA", ElemDesc.ATTRURL);
@ -461,58 +463,58 @@ public final class ToHTMLStream extends ToStream
elemDesc.setAttr("DECLARE", ElemDesc.ATTREMPTY); elemDesc.setAttr("DECLARE", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("OL"); elemDesc = (ElemDesc) m_elementFlags.get("ol");
elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY); elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("OPTGROUP"); elemDesc = (ElemDesc) m_elementFlags.get("optgroup");
elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY); elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("OPTION"); elemDesc = (ElemDesc) m_elementFlags.get("option");
elemDesc.setAttr("SELECTED", ElemDesc.ATTREMPTY); elemDesc.setAttr("SELECTED", ElemDesc.ATTREMPTY);
elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY); elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("Q"); elemDesc = (ElemDesc) m_elementFlags.get("q");
elemDesc.setAttr("CITE", ElemDesc.ATTRURL); elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("SCRIPT"); elemDesc = (ElemDesc) m_elementFlags.get("script");
elemDesc.setAttr("SRC", ElemDesc.ATTRURL); elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
elemDesc.setAttr("FOR", ElemDesc.ATTRURL); elemDesc.setAttr("FOR", ElemDesc.ATTRURL);
elemDesc.setAttr("DEFER", ElemDesc.ATTREMPTY); elemDesc.setAttr("DEFER", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("SELECT"); elemDesc = (ElemDesc) m_elementFlags.get("select");
elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY); elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
elemDesc.setAttr("MULTIPLE", ElemDesc.ATTREMPTY); elemDesc.setAttr("MULTIPLE", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("TABLE"); elemDesc = (ElemDesc) m_elementFlags.get("table");
elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("TD"); elemDesc = (ElemDesc) m_elementFlags.get("td");
elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("TEXTAREA"); elemDesc = (ElemDesc) m_elementFlags.get("textarea");
elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY); elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY); elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("TH"); elemDesc = (ElemDesc) m_elementFlags.get("th");
elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
// The nowrap attribute of a tr element is both // The nowrap attribute of a tr element is both
// a Netscape and Internet-Explorer extension // a Netscape and Internet-Explorer extension
elemDesc = (ElemDesc) m_elementFlags.get("TR"); elemDesc = (ElemDesc) m_elementFlags.get("tr");
elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
// ---------------------------------------------- // ----------------------------------------------
elemDesc = (ElemDesc) m_elementFlags.get("UL"); elemDesc = (ElemDesc) m_elementFlags.get("ul");
elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY); elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
} }
@ -1762,7 +1764,7 @@ public final class ToHTMLStream extends ToStream
* lets determine if the current element is specified in the cdata- * lets determine if the current element is specified in the cdata-
* section-elements list. * section-elements list.
*/ */
if (m_cdataSectionElements != null) if (m_StringOfCDATASections != null)
m_elemContext.m_isCdataSection = isCdataSection(); m_elemContext.m_isCdataSection = isCdataSection();
if (m_doIndent) if (m_doIndent)
{ {
@ -1776,54 +1778,7 @@ public final class ToHTMLStream extends ToStream
throw new SAXException(e); throw new SAXException(e);
} }
} }
/**
* Initialize the serializer with the specified output stream and output
* format. Must be called before calling any of the serialize methods.
*
* @param output The output stream to use
* @param format The output format
* @throws UnsupportedEncodingException The encoding specified in the
* output format is not supported
*/
protected synchronized void init(OutputStream output, Properties format)
throws UnsupportedEncodingException
{
if (null == format)
{
format = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
}
super.init(output,format, false);
}
/**
* Specifies an output stream to which the document should be
* serialized. This method should not be called while the
* serializer is in the process of serializing a document.
* <p>
* The encoding specified in the output properties is used, or
* if no encoding was specified, the default for the selected
* output method.
*
* @param output The output stream
*/
public void setOutputStream(OutputStream output)
{
try
{
Properties format;
if (null == m_format)
format = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
else
format = m_format;
init(output, format, true);
}
catch (UnsupportedEncodingException uee)
{
// Should have been warned in init, I guess...
}
}
/** /**
* This method is used when a prefix/uri namespace mapping * This method is used when a prefix/uri namespace mapping
* is indicated after the element was started with a * is indicated after the element was started with a

View File

@ -22,7 +22,7 @@
*/ */
package com.sun.org.apache.xml.internal.serializer; package com.sun.org.apache.xml.internal.serializer;
import java.util.Vector; import java.util.ArrayList;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler; import org.xml.sax.ContentHandler;
@ -234,9 +234,9 @@ public abstract class ToSAXHandler extends SerializerBase
/** /**
* Does nothing. The setting of CDATA section elements has an impact on * Does nothing. The setting of CDATA section elements has an impact on
* stream serializers. * stream serializers.
* @see SerializationHandler#setCdataSectionElements(java.util.Vector) * @see SerializationHandler#setCdataSectionElements(java.util.ArrayList<String>)
*/ */
public void setCdataSectionElements(Vector URI_and_localNames) public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
{ {
// do nothing // do nothing
} }

View File

@ -3,9 +3,11 @@
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /*
* Copyright 2001-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
@ -25,11 +27,15 @@ package com.sun.org.apache.xml.internal.serializer;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport; import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.io.Writer; import java.io.Writer;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector; import java.util.ArrayList;
import javax.xml.transform.ErrorListener; import javax.xml.transform.ErrorListener;
import javax.xml.transform.OutputKeys; import javax.xml.transform.OutputKeys;
@ -186,9 +192,6 @@ abstract public class ToStream extends SerializerBase
*/ */
boolean m_isUTF8 = false; boolean m_isUTF8 = false;
/** The xsl:output properties. */
protected Properties m_format;
/** /**
* remembers if we are in between the startCDATA() and endCDATA() callbacks * remembers if we are in between the startCDATA() and endCDATA() callbacks
*/ */
@ -306,6 +309,7 @@ abstract public class ToStream extends SerializerBase
} }
} }
OutputStream m_outputStream;
/** /**
* Get the output stream where the events will be serialized to. * Get the output stream where the events will be serialized to.
* *
@ -314,13 +318,7 @@ abstract public class ToStream extends SerializerBase
*/ */
public OutputStream getOutputStream() public OutputStream getOutputStream()
{ {
return m_outputStream;
if (m_writer instanceof WriterToUTF8Buffered)
return ((WriterToUTF8Buffered) m_writer).getOutputStream();
if (m_writer instanceof WriterToASCI)
return ((WriterToASCI) m_writer).getOutputStream();
else
return null;
} }
// Implement DeclHandler // Implement DeclHandler
@ -419,10 +417,174 @@ abstract public class ToStream extends SerializerBase
*/ */
protected final void outputLineSep() throws IOException protected final void outputLineSep() throws IOException
{ {
m_writer.write(m_lineSep, 0, m_lineSepLen); m_writer.write(m_lineSep, 0, m_lineSepLen);
} }
void setProp(String name, String val, boolean defaultVal) {
if (val != null) {
char first = getFirstCharLocName(name);
switch (first) {
case 'c':
if (OutputKeys.CDATA_SECTION_ELEMENTS.equals(name)) {
addCdataSectionElements(val); // val is cdataSectionNames
}
break;
case 'd':
if (OutputKeys.DOCTYPE_SYSTEM.equals(name)) {
this.m_doctypeSystem = val;
} else if (OutputKeys.DOCTYPE_PUBLIC.equals(name)) {
this.m_doctypePublic = val;
if (val.startsWith("-//W3C//DTD XHTML"))
m_spaceBeforeClose = true;
}
break;
case 'e':
String newEncoding = val;
if (OutputKeys.ENCODING.equals(name)) {
String possible_encoding = Encodings.getMimeEncoding(val);
if (possible_encoding != null) {
// if the encoding is being set, try to get the
// preferred
// mime-name and set it too.
super.setProp("mime-name", possible_encoding,
defaultVal);
}
final String oldExplicitEncoding = getOutputPropertyNonDefault(OutputKeys.ENCODING);
final String oldDefaultEncoding = getOutputPropertyDefault(OutputKeys.ENCODING);
if ( (defaultVal && ( oldDefaultEncoding == null || !oldDefaultEncoding.equalsIgnoreCase(newEncoding)))
|| ( !defaultVal && (oldExplicitEncoding == null || !oldExplicitEncoding.equalsIgnoreCase(newEncoding) ))) {
// We are trying to change the default or the non-default setting of the encoding to a different value
// from what it was
EncodingInfo encodingInfo = Encodings.getEncodingInfo(newEncoding);
if (newEncoding != null && encodingInfo.name == null) {
// We tried to get an EncodingInfo for Object for the given
// encoding, but it came back with an internall null name
// so the encoding is not supported by the JDK, issue a message.
final String msg = Utils.messages.createMessage(
MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ newEncoding });
final String msg2 =
"Warning: encoding \"" + newEncoding + "\" not supported, using "
+ Encodings.DEFAULT_MIME_ENCODING;
try {
// Prepare to issue the warning message
final Transformer tran = super.getTransformer();
if (tran != null) {
final ErrorListener errHandler = tran
.getErrorListener();
// Issue the warning message
if (null != errHandler
&& m_sourceLocator != null) {
errHandler
.warning(new TransformerException(
msg, m_sourceLocator));
errHandler
.warning(new TransformerException(
msg2, m_sourceLocator));
} else {
System.out.println(msg);
System.out.println(msg2);
}
} else {
System.out.println(msg);
System.out.println(msg2);
}
} catch (Exception e) {
}
// We said we are using UTF-8, so use it
newEncoding = Encodings.DEFAULT_MIME_ENCODING;
val = Encodings.DEFAULT_MIME_ENCODING; // to store the modified value into the properties a little later
encodingInfo = Encodings.getEncodingInfo(newEncoding);
}
// The encoding was good, or was forced to UTF-8 above
// If there is already a non-default set encoding and we
// are trying to set the default encoding, skip the this block
// as the non-default value is already the one to use.
if (defaultVal == false || oldExplicitEncoding == null) {
m_encodingInfo = encodingInfo;
if (newEncoding != null)
m_isUTF8 = newEncoding.equals(Encodings.DEFAULT_MIME_ENCODING);
// if there was a previously set OutputStream
OutputStream os = getOutputStream();
if (os != null) {
Writer w = getWriter();
// If the writer was previously set, but
// set by the user, or if the new encoding is the same
// as the old encoding, skip this block
String oldEncoding = getOutputProperty(OutputKeys.ENCODING);
if ((w == null || !m_writer_set_by_user)
&& !newEncoding.equalsIgnoreCase(oldEncoding)) {
// Make the change of encoding in our internal
// table, then call setOutputStreamInternal
// which will stomp on the old Writer (if any)
// with a new Writer with the new encoding.
super.setProp(name, val, defaultVal);
setOutputStreamInternal(os,false);
}
}
}
}
}
break;
case 'i':
if (OutputPropertiesFactory.S_KEY_INDENT_AMOUNT.equals(name)) {
setIndentAmount(Integer.parseInt(val));
} else if (OutputKeys.INDENT.equals(name)) {
boolean b = "yes".equals(val) ? true : false;
m_doIndent = b;
}
break;
case 'l':
if (OutputPropertiesFactory.S_KEY_LINE_SEPARATOR.equals(name)) {
m_lineSep = val.toCharArray();
m_lineSepLen = m_lineSep.length;
}
break;
case 'm':
if (OutputKeys.MEDIA_TYPE.equals(name)) {
m_mediatype = val;
}
break;
case 'o':
if (OutputKeys.OMIT_XML_DECLARATION.equals(name)) {
boolean b = "yes".equals(val) ? true : false;
this.m_shouldNotWriteXMLHeader = b;
}
break;
case 's':
// if standalone was explicitly specified
if (OutputKeys.STANDALONE.equals(name)) {
if (defaultVal) {
setStandaloneInternal(val);
} else {
m_standaloneWasSpecified = true;
setStandaloneInternal(val);
}
}
break;
case 'v':
if (OutputKeys.VERSION.equals(name)) {
m_version = val;
}
break;
default:
break;
}
super.setProp(name, val, defaultVal);
}
}
/** /**
* Specifies an output format for this serializer. It the * Specifies an output format for this serializer. It the
* serializer has already been associated with an output format, * serializer has already been associated with an output format,
@ -434,115 +596,34 @@ abstract public class ToStream extends SerializerBase
*/ */
public void setOutputFormat(Properties format) public void setOutputFormat(Properties format)
{ {
boolean shouldFlush = m_shouldFlush; boolean shouldFlush = m_shouldFlush;
init(m_writer, format, false, false); if (format != null)
m_shouldFlush = shouldFlush;
}
/**
* Initialize the serializer with the specified writer and output format.
* Must be called before calling any of the serialize methods.
* This method can be called multiple times and the xsl:output properties
* passed in the 'format' parameter are accumulated across calls.
*
* @param writer The writer to use
* @param format The output format
* @param shouldFlush True if the writer should be flushed at EndDocument.
*/
private synchronized void init(
Writer writer,
Properties format,
boolean defaultProperties,
boolean shouldFlush)
{
m_shouldFlush = shouldFlush;
// if we are tracing events we need to trace what
// characters are written to the output writer.
if (m_tracer != null
&& !(writer instanceof SerializerTraceWriter) )
m_writer = new SerializerTraceWriter(writer, m_tracer);
else
m_writer = writer;
m_format = format;
// m_cdataSectionNames =
// OutputProperties.getQNameProperties(
// OutputKeys.CDATA_SECTION_ELEMENTS,
// format);
setCdataSectionElements(OutputKeys.CDATA_SECTION_ELEMENTS, format);
setIndentAmount(
OutputPropertyUtils.getIntProperty(
OutputPropertiesFactory.S_KEY_INDENT_AMOUNT,
format));
setIndent(
OutputPropertyUtils.getBooleanProperty(OutputKeys.INDENT, format));
{ {
String sep = // Set the default values first,
format.getProperty(OutputPropertiesFactory.S_KEY_LINE_SEPARATOR); // and the non-default values after that,
if (sep != null) { // just in case there is some unexpected
m_lineSep = sep.toCharArray(); // residual values left over from over-ridden default values
m_lineSepLen = sep.length(); Enumeration propNames;
propNames = format.propertyNames();
while (propNames.hasMoreElements())
{
String key = (String) propNames.nextElement();
// Get the value, possibly a default value
String value = format.getProperty(key);
// Get the non-default value (if any).
String explicitValue = (String) format.get(key);
if (explicitValue == null && value != null) {
// This is a default value
this.setOutputPropertyDefault(key,value);
}
if (explicitValue != null) {
// This is an explicit non-default value
this.setOutputProperty(key,explicitValue);
}
} }
} }
boolean shouldNotWriteXMLHeader =
OutputPropertyUtils.getBooleanProperty(
OutputKeys.OMIT_XML_DECLARATION,
format);
setOmitXMLDeclaration(shouldNotWriteXMLHeader);
setDoctypeSystem(format.getProperty(OutputKeys.DOCTYPE_SYSTEM));
String doctypePublic = format.getProperty(OutputKeys.DOCTYPE_PUBLIC);
setDoctypePublic(doctypePublic);
// if standalone was explicitly specified
if (format.get(OutputKeys.STANDALONE) != null)
{
String val = format.getProperty(OutputKeys.STANDALONE);
if (defaultProperties)
setStandaloneInternal(val);
else
setStandalone(val);
}
setMediaType(format.getProperty(OutputKeys.MEDIA_TYPE));
if (null != doctypePublic)
{
if (doctypePublic.startsWith("-//W3C//DTD XHTML"))
m_spaceBeforeClose = true;
}
/*
* This code is added for XML 1.1 Version output.
*/
String version = getVersion();
if (null == version)
{
version = format.getProperty(OutputKeys.VERSION);
setVersion(version);
}
// initCharsMap();
String encoding = getEncoding();
if (null == encoding)
{
encoding =
Encodings.getMimeEncoding(
format.getProperty(OutputKeys.ENCODING));
setEncoding(encoding);
}
m_isUTF8 = encoding.equals(Encodings.DEFAULT_MIME_ENCODING);
// Access this only from the Hashtable level... we don't want to // Access this only from the Hashtable level... we don't want to
// get default properties. // get default properties.
String entitiesFileName = String entitiesFileName =
@ -557,107 +638,10 @@ abstract public class ToStream extends SerializerBase
m_charInfo = CharInfo.getCharInfo(entitiesFileName, method); m_charInfo = CharInfo.getCharInfo(entitiesFileName, method);
} }
}
/**
* Initialize the serializer with the specified writer and output format.
* Must be called before calling any of the serialize methods.
*
* @param writer The writer to use
* @param format The output format
*/
private synchronized void init(Writer writer, Properties format)
{
init(writer, format, false, false);
}
/**
* Initialize the serializer with the specified output stream and output
* format. Must be called before calling any of the serialize methods.
*
* @param output The output stream to use
* @param format The output format
* @param defaultProperties true if the properties are the default
* properties
*
* @throws UnsupportedEncodingException The encoding specified in the
* output format is not supported
*/
protected synchronized void init(
OutputStream output,
Properties format,
boolean defaultProperties)
throws UnsupportedEncodingException
{
String encoding = getEncoding();
if (encoding == null)
{
// if not already set then get it from the properties
encoding =
Encodings.getMimeEncoding(
format.getProperty(OutputKeys.ENCODING));
setEncoding(encoding);
}
if (encoding.equalsIgnoreCase("UTF-8"))
{
m_isUTF8 = true;
// if (output instanceof java.io.BufferedOutputStream)
// {
// init(new WriterToUTF8(output), format, defaultProperties, true);
// }
// else if (output instanceof java.io.FileOutputStream)
// {
// init(new WriterToUTF8Buffered(output), format, defaultProperties, true);
// }
// else
// {
// // Not sure what to do in this case. I'm going to be conservative
// // and not buffer.
// init(new WriterToUTF8(output), format, defaultProperties, true);
// }
init(
new WriterToUTF8Buffered(output),
format,
defaultProperties,
true);
}
else if (
encoding.equals("WINDOWS-1250")
|| encoding.equals("US-ASCII")
|| encoding.equals("ASCII"))
{
init(new WriterToASCI(output), format, defaultProperties, true);
}
else
{
Writer osw;
try
{
osw = Encodings.getWriter(output, encoding);
}
catch (UnsupportedEncodingException uee)
{
System.out.println(
"Warning: encoding \""
+ encoding
+ "\" not supported"
+ ", using "
+ Encodings.DEFAULT_MIME_ENCODING);
encoding = Encodings.DEFAULT_MIME_ENCODING;
setEncoding(encoding);
osw = Encodings.getWriter(output, encoding);
}
init(osw, format, defaultProperties, true);
}
m_shouldFlush = shouldFlush;
} }
/** /**
@ -665,9 +649,26 @@ abstract public class ToStream extends SerializerBase
* *
* @return The output format in use * @return The output format in use
*/ */
public Properties getOutputFormat() public Properties getOutputFormat() {
{ Properties def = new Properties();
return m_format; {
Set<String> s = getOutputPropDefaultKeys();
for (String key : s) {
String val = getOutputPropertyDefault(key);
def.put(key, val);
}
}
Properties props = new Properties(def);
{
Set<String> s = getOutputPropKeys();
for (String key : s) {
String val = getOutputPropertyNonDefault(key);
if (val != null)
props.put(key, val);
}
}
return props;
} }
/** /**
@ -679,13 +680,28 @@ abstract public class ToStream extends SerializerBase
*/ */
public void setWriter(Writer writer) public void setWriter(Writer writer)
{ {
setWriterInternal(writer, true);
}
private boolean m_writer_set_by_user;
private void setWriterInternal(Writer writer, boolean setByUser) {
m_writer_set_by_user = setByUser;
m_writer = writer;
// if we are tracing events we need to trace what // if we are tracing events we need to trace what
// characters are written to the output writer. // characters are written to the output writer.
if (m_tracer != null if (m_tracer != null) {
&& !(writer instanceof SerializerTraceWriter) ) boolean noTracerYet = true;
m_writer = new SerializerTraceWriter(writer, m_tracer); Writer w2 = m_writer;
else while (w2 instanceof WriterChain) {
m_writer = writer; if (w2 instanceof SerializerTraceWriter) {
noTracerYet = false;
break;
}
w2 = ((WriterChain)w2).getWriter();
}
if (noTracerYet)
m_writer = new SerializerTraceWriter(m_writer, m_tracer);
}
} }
/** /**
@ -720,25 +736,68 @@ abstract public class ToStream extends SerializerBase
*/ */
public void setOutputStream(OutputStream output) public void setOutputStream(OutputStream output)
{ {
setOutputStreamInternal(output, true);
}
try private void setOutputStreamInternal(OutputStream output, boolean setByUser)
{
m_outputStream = output;
String encoding = getOutputProperty(OutputKeys.ENCODING);
if (Encodings.DEFAULT_MIME_ENCODING.equalsIgnoreCase(encoding))
{ {
Properties format; // We wrap the OutputStream with a writer, but
if (null == m_format) // not one set by the user
format = try {
OutputPropertiesFactory.getDefaultMethodProperties( setWriterInternal(new WriterToUTF8Buffered(output), false);
Method.XML); } catch (UnsupportedEncodingException e) {
else e.printStackTrace();
format = m_format; }
init(output, format, true); } else if (
"WINDOWS-1250".equals(encoding)
|| "US-ASCII".equals(encoding)
|| "ASCII".equals(encoding))
{
setWriterInternal(new WriterToASCI(output), false);
} else if (encoding != null) {
Writer osw = null;
try
{
osw = Encodings.getWriter(output, encoding);
}
catch (UnsupportedEncodingException uee)
{
osw = null;
}
if (osw == null) {
System.out.println(
"Warning: encoding \""
+ encoding
+ "\" not supported"
+ ", using "
+ Encodings.DEFAULT_MIME_ENCODING);
encoding = Encodings.DEFAULT_MIME_ENCODING;
setEncoding(encoding);
try {
osw = Encodings.getWriter(output, encoding);
} catch (UnsupportedEncodingException e) {
// We can't really get here, UTF-8 is always supported
// This try-catch exists to make the compiler happy
e.printStackTrace();
}
}
setWriterInternal(osw,false);
} }
catch (UnsupportedEncodingException uee) else {
{ // don't have any encoding, but we have an OutputStream
Writer osw = new OutputStreamWriter(output);
// Should have been warned in init, I guess... setWriterInternal(osw,false);
} }
} }
/** /**
* @see SerializationHandler#setEscaping(boolean) * @see SerializationHandler#setEscaping(boolean)
*/ */
@ -2455,7 +2514,7 @@ abstract public class ToStream extends SerializerBase
* lets determine if the current element is specified in the cdata- * lets determine if the current element is specified in the cdata-
* section-elements list. * section-elements list.
*/ */
if (m_cdataSectionElements != null) if (m_StringOfCDATASections != null)
m_elemContext.m_isCdataSection = isCdataSection(); m_elemContext.m_isCdataSection = isCdataSection();
if (m_doIndent) if (m_doIndent)
@ -2532,12 +2591,12 @@ abstract public class ToStream extends SerializerBase
* @param key the property key. * @param key the property key.
* @param props the list of properties to search in. * @param props the list of properties to search in.
* *
* Sets the vector of local-name/URI pairs of the cdata section elements * Sets the ArrayList of local-name/URI pairs of the cdata section elements
* specified in the cdata-section-elements property. * specified in the cdata-section-elements property.
* *
* This method is essentially a copy of getQNameProperties() from * This method is essentially a copy of getQNameProperties() from
* OutputProperties. Eventually this method should go away and a call * OutputProperties. Eventually this method should go away and a call
* to setCdataSectionElements(Vector v) should be made directly. * to setCdataSectionElements(ArrayList<String> v) should be made directly.
*/ */
private void setCdataSectionElements(String key, Properties props) private void setCdataSectionElements(String key, Properties props)
{ {
@ -2546,11 +2605,11 @@ abstract public class ToStream extends SerializerBase
if (null != s) if (null != s)
{ {
// Vector of URI/LocalName pairs // ArrayList<String> of URI/LocalName pairs
Vector v = new Vector(); ArrayList<String> v = new ArrayList<>();
int l = s.length(); int l = s.length();
boolean inCurly = false; boolean inCurly = false;
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
// parse through string, breaking on whitespaces. I do this instead // parse through string, breaking on whitespaces. I do this instead
// of a tokenizer so I can track whitespace inside of curly brackets, // of a tokenizer so I can track whitespace inside of curly brackets,
@ -2597,7 +2656,7 @@ abstract public class ToStream extends SerializerBase
* *
* @return a QName object * @return a QName object
*/ */
private void addCdataSectionElement(String URI_and_localName, Vector v) private void addCdataSectionElement(String URI_and_localName, ArrayList<String> v)
{ {
StringTokenizer tokenizer = StringTokenizer tokenizer =
@ -2608,14 +2667,14 @@ abstract public class ToStream extends SerializerBase
if (null == s2) if (null == s2)
{ {
// add null URI and the local name // add null URI and the local name
v.addElement(null); v.add(null);
v.addElement(s1); v.add(s1);
} }
else else
{ {
// add URI, then local name // add URI, then local name
v.addElement(s1); v.add(s1);
v.addElement(s2); v.add(s2);
} }
} }
@ -2624,11 +2683,38 @@ abstract public class ToStream extends SerializerBase
* The "official way to set URI and localName pairs. * The "official way to set URI and localName pairs.
* This method should be used by both Xalan and XSLTC. * This method should be used by both Xalan and XSLTC.
* *
* @param URI_and_localNames a vector of pairs of Strings (URI/local) * @param URI_and_localNames an ArrayList of pairs of Strings (URI/local)
*/ */
public void setCdataSectionElements(Vector URI_and_localNames) public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
{ {
m_cdataSectionElements = URI_and_localNames; // convert to the new way.
if (URI_and_localNames != null)
{
final int len = URI_and_localNames.size() - 1;
if (len > 0)
{
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < len; i += 2)
{
// whitspace separated "{uri1}local1 {uri2}local2 ..."
if (i != 0)
sb.append(' ');
final String uri = (String) URI_and_localNames.get(i);
final String localName =
(String) URI_and_localNames.get(i + 1);
if (uri != null)
{
// If there is no URI don't put this in, just the localName then.
sb.append('{');
sb.append(uri);
sb.append('}');
}
sb.append(localName);
}
m_StringOfCDATASections = sb.toString();
}
}
initCdataElems(m_StringOfCDATASections);
} }
/** /**
@ -3084,37 +3170,7 @@ abstract public class ToStream extends SerializerBase
*/ */
public void setEncoding(String encoding) public void setEncoding(String encoding)
{ {
String old = getEncoding(); setOutputProperty(OutputKeys.ENCODING,encoding);
super.setEncoding(encoding);
if (old == null || !old.equals(encoding)) {
// If we have changed the setting of the
m_encodingInfo = Encodings.getEncodingInfo(encoding);
if (encoding != null && m_encodingInfo.name == null) {
// We tried to get an EncodingInfo for Object for the given
// encoding, but it came back with an internall null name
// so the encoding is not supported by the JDK, issue a message.
String msg = Utils.messages.createMessage(
MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
try
{
// Prepare to issue the warning message
Transformer tran = super.getTransformer();
if (tran != null) {
ErrorListener errHandler = tran.getErrorListener();
// Issue the warning message
if (null != errHandler && m_sourceLocator != null)
errHandler.warning(new TransformerException(msg, m_sourceLocator));
else
System.out.println(msg);
}
else
System.out.println(msg);
}
catch (Exception e){}
}
}
return;
} }
/** /**
@ -3386,4 +3442,24 @@ abstract public class ToStream extends SerializerBase
public void setDTDEntityExpansion(boolean expand) { public void setDTDEntityExpansion(boolean expand) {
m_expandDTDEntities = expand; m_expandDTDEntities = expand;
} }
/**
* Remembers the cdata sections specified in the cdata-section-elements by appending the given
* cdata section elements to the list. This method can be called multiple times, but once an
* element is put in the list of cdata section elements it can not be removed.
* This method should be used by both Xalan and XSLTC.
*
* @param URI_and_localNames a whitespace separated list of element names, each element
* is a URI in curly braces (optional) and a local name. An example of such a parameter is:
* "{http://company.com}price {myURI2}book chapter"
*/
public void addCdataSectionElements(String URI_and_localNames)
{
if (URI_and_localNames != null)
initCdataElems(URI_and_localNames);
if (m_StringOfCDATASections == null)
m_StringOfCDATASections = URI_and_localNames;
else
m_StringOfCDATASections += (" " + URI_and_localNames);
}
} }

View File

@ -26,7 +26,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.Writer; import java.io.Writer;
import java.util.Properties; import java.util.Properties;
import java.util.Vector; import java.util.ArrayList;
import javax.xml.transform.SourceLocator; import javax.xml.transform.SourceLocator;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
@ -100,12 +100,12 @@ public final class ToUnknownStream extends SerializerBase
* A collection of namespace URI's (only for first element). * A collection of namespace URI's (only for first element).
* _namespacePrefix has the matching prefix for these URI's * _namespacePrefix has the matching prefix for these URI's
*/ */
private Vector m_namespaceURI = null; private ArrayList<String> m_namespaceURI = null;
/** /**
* A collection of namespace Prefix (only for first element) * A collection of namespace Prefix (only for first element)
* _namespaceURI has the matching URIs for these prefix' * _namespaceURI has the matching URIs for these prefix'
*/ */
private Vector m_namespacePrefix = null; private ArrayList<String> m_namespacePrefix = null;
/** /**
* true if startDocument() was called before the underlying handler * true if startDocument() was called before the underlying handler
@ -421,11 +421,11 @@ public final class ToUnknownStream extends SerializerBase
{ {
if (m_namespacePrefix == null) if (m_namespacePrefix == null)
{ {
m_namespacePrefix = new Vector(); m_namespacePrefix = new ArrayList<>();
m_namespaceURI = new Vector(); m_namespaceURI = new ArrayList<>();
} }
m_namespacePrefix.addElement(prefix); m_namespacePrefix.add(prefix);
m_namespaceURI.addElement(uri); m_namespaceURI.add(uri);
if (m_firstElementURI == null) if (m_firstElementURI == null)
{ {
@ -1092,8 +1092,8 @@ public final class ToUnknownStream extends SerializerBase
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {
final String prefix = final String prefix =
(String) m_namespacePrefix.elementAt(i); (String) m_namespacePrefix.get(i);
final String uri = (String) m_namespaceURI.elementAt(i); final String uri = (String) m_namespaceURI.get(i);
m_handler.startPrefixMapping(prefix, uri, false); m_handler.startPrefixMapping(prefix, uri, false);
} }
m_namespacePrefix = null; m_namespacePrefix = null;
@ -1165,8 +1165,8 @@ public final class ToUnknownStream extends SerializerBase
final int max = m_namespacePrefix.size(); final int max = m_namespacePrefix.size();
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
final String prefix = (String) m_namespacePrefix.elementAt(i); final String prefix = m_namespacePrefix.get(i);
final String uri = (String) m_namespaceURI.elementAt(i); final String uri = m_namespaceURI.get(i);
if (m_firstElementPrefix != null if (m_firstElementPrefix != null
&& m_firstElementPrefix.equals(prefix) && m_firstElementPrefix.equals(prefix)
@ -1194,7 +1194,7 @@ public final class ToUnknownStream extends SerializerBase
* specified in the cdata-section-elements attribute. * specified in the cdata-section-elements attribute.
* @see SerializationHandler#setCdataSectionElements(java.util.Vector) * @see SerializationHandler#setCdataSectionElements(java.util.Vector)
*/ */
public void setCdataSectionElements(Vector URI_and_localNames) public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
{ {
m_handler.setCdataSectionElements(URI_and_localNames); m_handler.setCdataSectionElements(URI_and_localNames);
} }

View File

@ -3,9 +3,11 @@
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /*
* Copyright 1999-2005 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *

View File

@ -3,9 +3,11 @@
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /*
* Copyright 2003-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
@ -22,7 +24,7 @@
*/ */
package com.sun.org.apache.xml.internal.serializer; package com.sun.org.apache.xml.internal.serializer;
import java.util.Vector; import java.util.ArrayList;
/** /**
* This interface has methods associated with the XSLT xsl:output attribues * This interface has methods associated with the XSLT xsl:output attribues
@ -105,11 +107,6 @@ interface XSLOutputAttributes
*/ */
public String getVersion(); public String getVersion();
/** /**
* Sets the value coming from the xsl:output cdata-section-elements * Sets the value coming from the xsl:output cdata-section-elements
* stylesheet property. * stylesheet property.
@ -124,7 +121,7 @@ interface XSLOutputAttributes
* relevant in specifying which elements have their text to be output as * relevant in specifying which elements have their text to be output as
* CDATA sections. * CDATA sections.
*/ */
public void setCdataSectionElements(Vector URI_and_localNames); public void setCdataSectionElements(ArrayList<String> URI_and_localNames);
/** Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties /** Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
* @param system the system identifier to be used in the DOCTYPE declaration * @param system the system identifier to be used in the DOCTYPE declaration
@ -181,4 +178,58 @@ interface XSLOutputAttributes
*/ */
public void setVersion(String version); public void setVersion(String version);
/**
* Get the value for a property that affects seraialization,
* if a property was set return that value, otherwise return
* the default value, otherwise return null.
* @param name The name of the property, which is just the local name
* if it is in no namespace, but is the URI in curly braces followed by
* the local name if it is in a namespace, for example:
* <ul>
* <li> "encoding"
* <li> "method"
* <li> "{http://xml.apache.org/xalan}indent-amount"
* <li> "{http://xml.apache.org/xalan}line-separator"
* </ul>
* @return The value of the parameter
*/
public String getOutputProperty(String name);
/**
* Get the default value for a property that affects seraialization,
* or null if there is none. It is possible that a non-default value
* was set for the property, however the value returned by this method
* is unaffected by any non-default settings.
* @param name The name of the property.
* @return The default value of the parameter, or null if there is no default value.
*/
public String getOutputPropertyDefault(String name);
/**
* Set the non-default value for a property that affects seraialization.
* @param name The name of the property, which is just the local name
* if it is in no namespace, but is the URI in curly braces followed by
* the local name if it is in a namespace, for example:
* <ul>
* <li> "encoding"
* <li> "method"
* <li> "{http://xml.apache.org/xalan}indent-amount"
* <li> "{http://xml.apache.org/xalan}line-separator"
* </ul>
* @val The non-default value of the parameter
*/
public void setOutputProperty(String name, String val);
/**
* Set the default value for a property that affects seraialization.
* @param name The name of the property, which is just the local name
* if it is in no namespace, but is the URI in curly braces followed by
* the local name if it is in a namespace, for example:
* <ul>
* <li> "encoding"
* <li> "method"
* <li> "{http://xml.apache.org/xalan}indent-amount"
* <li> "{http://xml.apache.org/xalan}line-separator"
* </ul>
* @val The default value of the parameter
*/
public void setOutputPropertyDefault(String name, String val);
} }

View File

@ -352,7 +352,7 @@ public abstract class Entity {
} }
/**each 'external' parsed entity may have xml/text declaration containing version information /**each 'external' parsed entity may have xml/text declaration containing version information
* @return String version of the enity, for an internal entity version would be null * @return String version of the entity, for an internal entity version would be null
*/ */
public String getEntityVersion(){ public String getEntityVersion(){
return version ; return version ;

View File

@ -34,7 +34,7 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
* @author Neeraj * @author Neeraj
* *
* This class wraps XMLInputSource and is also capable of telling wether application * This class wraps XMLInputSource and is also capable of telling wether application
* returned XMLStreamReader or not when XMLResolver.resolveEnity * returned XMLStreamReader or not when XMLResolver.resolveEntity
* was called. * was called.
*/ */
public class StaxXMLInputSource { public class StaxXMLInputSource {

View File

@ -36,7 +36,7 @@ public class DatatypeConfigurationException extends Exception {
/** /**
* <p>Create a new <code>DatatypeConfigurationException</code> with * <p>Create a new <code>DatatypeConfigurationException</code> with
* no specified detail mesage and cause.</p> * no specified detail message and cause.</p>
*/ */
public DatatypeConfigurationException() { public DatatypeConfigurationException() {

View File

@ -119,7 +119,7 @@ public abstract class DatatypeFactory {
Pattern.compile("[^YM]*[DT].*"); Pattern.compile("[^YM]*[DT].*");
/** /**
* <p>Protected constructor to prevent instaniation outside of package.</p> * <p>Protected constructor to prevent instantiation outside of package.</p>
* *
* <p>Use {@link #newInstance()} to create a <code>DatatypeFactory</code>.</p> * <p>Use {@link #newInstance()} to create a <code>DatatypeFactory</code>.</p>
*/ */

View File

@ -83,7 +83,7 @@ public class QName implements Serializable {
* *
* <p>To workaround this issue, serialVersionUID is set with either * <p>To workaround this issue, serialVersionUID is set with either
* a default value or a compatibility value. To use the * a default value or a compatibility value. To use the
* compatiblity value, set the system property:</p> * compatibility value, set the system property:</p>
* *
* <code>com.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0</code> * <code>com.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0</code>
* *

View File

@ -423,7 +423,7 @@ public abstract class DocumentBuilderFactory {
* <ul> * <ul>
* <li> * <li>
* <code>true</code>: the implementation will limit XML processing to conform to implementation limits. * <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
* Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources. * Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
* If XML processing is limited for security reasons, it will be reported via a call to the registered * If XML processing is limited for security reasons, it will be reported via a call to the registered
* {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}. * {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
* See {@link DocumentBuilder#setErrorHandler(org.xml.sax.ErrorHandler errorHandler)}. * See {@link DocumentBuilder#setErrorHandler(org.xml.sax.ErrorHandler errorHandler)}.
@ -517,7 +517,7 @@ public abstract class DocumentBuilderFactory {
* modified DOM trees. * modified DOM trees.
* *
* <p> * <p>
* Initialy, null is set as the {@link Schema}. * Initially, null is set as the {@link Schema}.
* *
* <p> * <p>
* This processing will take effect even if * This processing will take effect even if
@ -531,7 +531,7 @@ public abstract class DocumentBuilderFactory {
* exception when the {@link #newDocumentBuilder()} is invoked.</p> * exception when the {@link #newDocumentBuilder()} is invoked.</p>
* *
* *
* <h4>Note for implmentors</h4> * <h4>Note for implementors</h4>
* *
* <p> * <p>
* A parser must be able to work with any {@link Schema} * A parser must be able to work with any {@link Schema}

View File

@ -45,7 +45,7 @@ public class FactoryConfigurationError extends Error {
/** /**
* Create a new <code>FactoryConfigurationError</code> with no * Create a new <code>FactoryConfigurationError</code> with no
* detail mesage. * detail message.
*/ */
public FactoryConfigurationError() { public FactoryConfigurationError() {

View File

@ -35,7 +35,7 @@ public class ParserConfigurationException extends Exception {
/** /**
* Create a new <code>ParserConfigurationException</code> with no * Create a new <code>ParserConfigurationException</code> with no
* detail mesage. * detail message.
*/ */
public ParserConfigurationException() { public ParserConfigurationException() {

View File

@ -69,7 +69,7 @@ import org.xml.sax.helpers.DefaultHandler;
* given {@link org.xml.sax.HandlerBase} or the * given {@link org.xml.sax.HandlerBase} or the
* {@link org.xml.sax.helpers.DefaultHandler} are called.<p> * {@link org.xml.sax.helpers.DefaultHandler} are called.<p>
* *
* Implementors of this class which wrap an underlaying implementation * Implementors of this class which wrap an underlying implementation
* can consider using the {@link org.xml.sax.helpers.ParserAdapter} * can consider using the {@link org.xml.sax.helpers.ParserAdapter}
* class to initially adapt their SAX1 implementation to work under * class to initially adapt their SAX1 implementation to work under
* this revised class. * this revised class.
@ -79,7 +79,7 @@ import org.xml.sax.helpers.DefaultHandler;
public abstract class SAXParser { public abstract class SAXParser {
/** /**
* <p>Protected constructor to prevent instaniation. * <p>Protected constructor to prevent instantiation.
* Use {@link javax.xml.parsers.SAXParserFactory#newSAXParser()}.</p> * Use {@link javax.xml.parsers.SAXParserFactory#newSAXParser()}.</p>
*/ */
protected SAXParser () { protected SAXParser () {
@ -393,10 +393,10 @@ public abstract class SAXParser {
} }
/** /**
* Returns the SAX parser that is encapsultated by the * Returns the SAX parser that is encapsulated by the
* implementation of this class. * implementation of this class.
* *
* @return The SAX parser that is encapsultated by the * @return The SAX parser that is encapsulated by the
* implementation of this class. * implementation of this class.
* *
* @throws SAXException If any SAX errors occur during processing. * @throws SAXException If any SAX errors occur during processing.

View File

@ -359,7 +359,7 @@ public abstract class SAXParserFactory {
* is responsible to make sure that the application will receive * is responsible to make sure that the application will receive
* those modified event stream.</p> * those modified event stream.</p>
* *
* <p>Initialy, <code>null</code> is set as the {@link Schema}.</p> * <p>Initially, <code>null</code> is set as the {@link Schema}.</p>
* *
* <p>This processing will take effect even if * <p>This processing will take effect even if
* the {@link #isValidating()} method returns <code>false</code>. * the {@link #isValidating()} method returns <code>false</code>.

View File

@ -28,7 +28,7 @@ package javax.xml.transform;
/** /**
* <p>To provide customized error handling, implement this interface and * <p>To provide customized error handling, implement this interface and
* use the <code>setErrorListener</code> method to register an instance of the * use the <code>setErrorListener</code> method to register an instance of the
* implmentation with the {@link javax.xml.transform.Transformer}. The * implementation with the {@link javax.xml.transform.Transformer}. The
* <code>Transformer</code> then reports all errors and warnings through this * <code>Transformer</code> then reports all errors and warnings through this
* interface.</p> * interface.</p>
* *

View File

@ -32,7 +32,7 @@ public class TransformerConfigurationException extends TransformerException {
/** /**
* Create a new <code>TransformerConfigurationException</code> with no * Create a new <code>TransformerConfigurationException</code> with no
* detail mesage. * detail message.
*/ */
public TransformerConfigurationException() { public TransformerConfigurationException() {
super("Configuration Error"); super("Configuration Error");

View File

@ -42,7 +42,7 @@ public class TransformerFactoryConfigurationError extends Error {
/** /**
* Create a new <code>TransformerFactoryConfigurationError</code> with no * Create a new <code>TransformerFactoryConfigurationError</code> with no
* detail mesage. * detail message.
*/ */
public TransformerFactoryConfigurationError() { public TransformerFactoryConfigurationError() {

View File

@ -358,7 +358,7 @@ public abstract class SchemaFactory {
* <ul> * <ul>
* <li> * <li>
* <code>true</code>: the implementation will limit XML processing to conform to implementation limits. * <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
* Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources. * Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
* If XML processing is limited for security reasons, it will be reported via a call to the registered * If XML processing is limited for security reasons, it will be reported via a call to the registered
* {@link ErrorHandler#fatalError(SAXParseException exception)}. * {@link ErrorHandler#fatalError(SAXParseException exception)}.
* See {@link #setErrorHandler(ErrorHandler errorHandler)}. * See {@link #setErrorHandler(ErrorHandler errorHandler)}.

View File

@ -379,7 +379,7 @@ public abstract class ValidatorHandler implements ContentHandler {
* <ul> * <ul>
* <li> * <li>
* <code>true</code>: the implementation will limit XML processing to conform to implementation limits. * <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
* Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources. * Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
* If XML processing is limited for security reasons, it will be reported via a call to the registered * If XML processing is limited for security reasons, it will be reported via a call to the registered
* {@link ErrorHandler#fatalError(SAXParseException exception)}. * {@link ErrorHandler#fatalError(SAXParseException exception)}.
* See {@link #setErrorHandler(ErrorHandler errorHandler)}. * See {@link #setErrorHandler(ErrorHandler errorHandler)}.