public class Writer extends DefaultFilter
Since an HTML document may have specified its encoding using the <META> tag and http-equiv/content attributes, the writer will automatically change any character set specified in this tag to match the encoding of the output stream. Therefore, the character encoding name used to construct the writer should be an official IANA encoding name and not a Java encoding name.
Note: The modified character set in the <META> tag is not propagated to the next stage in the pipeline. The changed value is only output to the stream; the original value is sent to the next stage in the pipeline.
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
AUGMENTATIONS
Augmentations feature identifier.
|
protected int |
fElementDepth
Element depth.
|
protected java.lang.String |
fEncoding
The encoding.
|
protected static java.lang.String |
FILTERS
Filters property identifier.
|
protected boolean |
fNormalize
Normalize character content.
|
protected boolean |
fPrintChars
Print characters.
|
protected java.io.PrintWriter |
fPrinter
The print writer used for serializing the document with the
appropriate character encoding.
|
protected boolean |
fSeenHttpEquiv
Seen http-equiv directive.
|
protected boolean |
fSeenRootElement
Seen root element.
|
static java.lang.String |
NOTIFY_CHAR_REFS
Notify character entity references.
|
static java.lang.String |
NOTIFY_HTML_BUILTIN_REFS
Notify built-in entity references.
|
fDocumentHandler, fDocumentSource
Constructor and Description |
---|
Writer()
Constructs a writer filter that prints to standard out.
|
Writer(java.io.OutputStream outputStream,
java.lang.String encoding)
Constructs a writer filter using the specified output stream and
encoding.
|
Writer(java.io.Writer writer,
java.lang.String encoding)
Constructs a writer filter using the specified Java writer and
encoding.
|
Modifier and Type | Method and Description |
---|---|
void |
characters(XMLString text,
Augmentations augs)
Characters.
|
void |
comment(XMLString text,
Augmentations augs)
Comment.
|
void |
emptyElement(QName element,
XMLAttributes attributes,
Augmentations augs)
Empty element.
|
void |
endElement(QName element,
Augmentations augs)
End element.
|
void |
endGeneralEntity(java.lang.String name,
Augmentations augs)
End general entity.
|
static void |
main(java.lang.String[] argv)
Main.
|
protected void |
printAttributeValue(java.lang.String text)
Print attribute value.
|
protected void |
printCharacters(XMLString text,
boolean normalize)
Print characters.
|
protected void |
printEndElement(QName element)
Print end element.
|
protected void |
printEntity(java.lang.String name)
Print entity.
|
protected void |
printStartElement(QName element,
XMLAttributes attributes)
Print start element.
|
void |
startDocument(XMLLocator locator,
java.lang.String encoding,
Augmentations augs)
Start document.
|
void |
startDocument(XMLLocator locator,
java.lang.String encoding,
NamespaceContext nscontext,
Augmentations augs)
Start document.
|
void |
startElement(QName element,
XMLAttributes attributes,
Augmentations augs)
Start element.
|
void |
startGeneralEntity(java.lang.String name,
XMLResourceIdentifier id,
java.lang.String encoding,
Augmentations augs)
Start general entity.
|
doctypeDecl, endCDATA, endDocument, endPrefixMapping, getDocumentHandler, getDocumentSource, getFeatureDefault, getPropertyDefault, getRecognizedFeatures, getRecognizedProperties, ignorableWhitespace, merge, processingInstruction, reset, setDocumentHandler, setDocumentSource, setFeature, setProperty, startCDATA, startPrefixMapping, textDecl, xmlDecl
public static final java.lang.String NOTIFY_CHAR_REFS
public static final java.lang.String NOTIFY_HTML_BUILTIN_REFS
protected static final java.lang.String AUGMENTATIONS
protected static final java.lang.String FILTERS
protected java.lang.String fEncoding
protected java.io.PrintWriter fPrinter
protected boolean fSeenRootElement
protected boolean fSeenHttpEquiv
protected int fElementDepth
protected boolean fNormalize
protected boolean fPrintChars
public Writer()
public Writer(java.io.OutputStream outputStream, java.lang.String encoding) throws java.io.UnsupportedEncodingException
outputStream
- The output stream to write to.encoding
- The encoding to be used for the output. The encoding name
should be an official IANA encoding name.java.io.UnsupportedEncodingException
public Writer(java.io.Writer writer, java.lang.String encoding)
writer
- The Java writer to write to.encoding
- The encoding to be used for the output. The encoding name
should be an official IANA encoding name.public void startDocument(XMLLocator locator, java.lang.String encoding, NamespaceContext nscontext, Augmentations augs) throws XNIException
startDocument
in class DefaultFilter
XNIException
public void startDocument(XMLLocator locator, java.lang.String encoding, Augmentations augs) throws XNIException
startDocument
in class DefaultFilter
XNIException
public void comment(XMLString text, Augmentations augs) throws XNIException
comment
in class DefaultFilter
XNIException
public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException
startElement
in class DefaultFilter
XNIException
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException
emptyElement
in class DefaultFilter
XNIException
public void characters(XMLString text, Augmentations augs) throws XNIException
characters
in class DefaultFilter
XNIException
public void endElement(QName element, Augmentations augs) throws XNIException
endElement
in class DefaultFilter
XNIException
public void startGeneralEntity(java.lang.String name, XMLResourceIdentifier id, java.lang.String encoding, Augmentations augs) throws XNIException
startGeneralEntity
in class DefaultFilter
XNIException
public void endGeneralEntity(java.lang.String name, Augmentations augs) throws XNIException
endGeneralEntity
in class DefaultFilter
XNIException
protected void printAttributeValue(java.lang.String text)
protected void printCharacters(XMLString text, boolean normalize)
protected void printStartElement(QName element, XMLAttributes attributes)
protected void printEndElement(QName element)
protected void printEntity(java.lang.String name)
public static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception
(C) Copyright 2002-2014, Andy Clark, Marc Guillemot. All rights reserved.