public final class RepairingNsStreamWriter extends BaseNsStreamWriter
XMLStreamWriter, that does
namespace repairing, ie resolves possible conflicts between prefixes
(add new bindings as necessary), as well as automatically creates
namespace declarations as necessary.| Modifier and Type | Field and Description |
|---|---|
protected String |
mAutomaticNsPrefix |
protected int[] |
mAutoNsSeq
Sequence number used for generating dynamic namespace prefixes.
|
protected String |
mSuggestedDefNs |
protected HashMap<String,String> |
mSuggestedPrefixes
Map that contains URI-to-prefix entries that point out suggested
prefixes for URIs.
|
ERR_NSDECL_WRONG_STATE, mAutomaticNS, mCurrElem, mEmptyElementHandler, mOutputElemPool, mPoolSize, mRootNsContext, sPrefixXml, sPrefixXmlnsmValueEncoderFactoryATTR_MIN_ARRAYCOPY, CHAR_SPACE, DEFAULT_COPYBUFFER_LEN, mAnyOutput, mCfgAutomaticEmptyElems, mCfgCDataAsText, mCfgCopyDefaultAttrs, mCheckAttrs, mCheckStructure, mConfig, mCopyBuffer, mDtdRootElem, mEmptyElement, mEncoding, MIN_ARRAYCOPY, mReturnNullForDefaultNamespace, mStartElementOpen, mState, mValidator, mVldContent, mVldProbHandler, mWriter, mXml11, STATE_EPILOG, STATE_PROLOG, STATE_TREECFG_ADD_SPACE_AFTER_EMPTY_ELEM, CFG_AUTO_CLOSE_OUTPUT, CFG_AUTOMATIC_EMPTY_ELEMENTS, CFG_AUTOMATIC_END_ELEMENTS, CFG_AUTOMATIC_NS, CFG_COPY_DEFAULT_ATTRS, CFG_ENABLE_NS, CFG_ESCAPE_CR, CFG_FIX_CONTENT, CFG_OUTPUT_CDATA_AS_TEXT, CFG_USE_DOUBLE_QUOTES_IN_XML_DECL, CFG_VALIDATE_ATTR, CFG_VALIDATE_CONTENT, CFG_VALIDATE_NAMES, CFG_VALIDATE_STRUCTUREATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT| Constructor and Description |
|---|
RepairingNsStreamWriter(XmlWriter xw,
String enc,
WriterConfig cfg) |
| Modifier and Type | Method and Description |
|---|---|
void |
copyStartElement(InputElementStack elemStack,
AttributeCollector ac)
Element copier method implementation suitable for use with
namespace-aware writers in repairing mode.
|
void |
doSetPrefix(String prefix,
String uri) |
protected String |
findElemPrefix(String nsURI,
SimpleOutputElement elem)
Method called to find an existing prefix for the given namespace,
if any exists in the scope.
|
protected String |
findOrCreateAttrPrefix(String suggPrefix,
String nsURI,
SimpleOutputElement elem)
Method called to somehow find a prefix for given namespace, to be
used for a new start element; either use an existing one, or
generate a new one.
|
protected String |
generateElemPrefix(String suggPrefix,
String nsURI,
SimpleOutputElement elem)
Method called after
findElemPrefix(java.lang.String, com.ctc.wstx.sw.SimpleOutputElement) has returned null,
to create and bind a namespace mapping for specified namespace. |
void |
setDefaultNamespace(String uri)
With repairing writer, this is only taken as a suggestion as to how
the caller would prefer prefixes to be mapped.
|
String |
validateQNamePrefix(QName name)
Method called before writing a QName via Typed Access API.
|
void |
writeAttribute(String nsURI,
String localName,
String value) |
void |
writeAttribute(String prefix,
String nsURI,
String localName,
String value) |
void |
writeDefaultNamespace(String nsURI) |
void |
writeNamespace(String prefix,
String nsURI) |
void |
writeStartElement(StartElement elem)
Convenience method needed by
XMLEventWriter
implementation, to use when
writing a start element, and possibly its attributes and namespace
declarations. |
protected void |
writeStartOrEmpty(String localName,
String nsURI) |
protected void |
writeStartOrEmpty(String suggPrefix,
String localName,
String nsURI) |
protected void |
writeTypedAttribute(String prefix,
String nsURI,
String localName,
org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)
Method that will write attribute with value that is known not to
require additional escaping.
|
checkStartElement, closeStartElement, doWriteAttr, doWriteAttr, doWriteDefaultNs, doWriteEndTag, doWriteNamespace, doWriteStartTag, doWriteStartTag, getCurrentElementName, getNamespaceContext, getNamespaceURI, getPrefix, getTopElementDesc, setNamespaceContext, setPrefix, writeAttribute, writeEmptyElement, writeEmptyElement, writeEmptyElement, writeEndElement, writeEndElement, writeFullEndElement, writeStartElement, writeStartElement, writeStartElementvalueEncoderFactory, writeBinary, writeBinary, writeBinaryAttribute, writeBinaryAttribute, writeBoolean, writeBooleanAttribute, writeDecimal, writeDecimalAttribute, writeDouble, writeDoubleArray, writeDoubleArrayAttribute, writeDoubleAttribute, writeFloat, writeFloatArray, writeFloatArrayAttribute, writeFloatAttribute, writeInt, writeIntArray, writeIntArrayAttribute, writeIntAttribute, writeInteger, writeIntegerAttribute, writeLong, writeLongArray, writeLongArrayAttribute, writeLongAttribute, writeQName, writeQNameAttribute, writeTypedElementaddDefaultAttribute, close, closeCompletely, copyEventFromReader, doReportProblem, doReportProblem, doWriteStartDocument, findAttributeIndex, flush, getAttributeCount, getAttributeLocalName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getBaseUri, getCopyBuffer, getCopyBuffer, getEncoding, getLocation, getProperty, getValidationLocation, getXmlVersion, inPrologOrEpilog, isNotationDeclared, isPropertySupported, isUnparsedEntityDeclared, isValidating, reportIllegalArg, reportIllegalMethod, reportInvalidContent, reportNwfAttr, reportNwfAttr, reportNwfContent, reportNwfContent, reportNwfStructure, reportNwfStructure, reportProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, setProperty, setValidationProblemHandler, stopValidatingAgainst, stopValidatingAgainst, throwFromIOE, throwOutputError, throwOutputError, toString, validateAgainst, verifyRootElement, verifyWriteCData, verifyWriteDTD, wrapAsRawWriter, wrapAsTextWriter, writeCData, writeCData, writeCharacters, writeCharacters, writeCharacters, writeComment, writeDTD, writeDTD, writeDTD, writeEndDocument, writeEntityRef, writeProcessingInstruction, writeProcessingInstruction, writeRaw, writeRaw, writeRaw, writeSpace, writeSpace, writeStartDocument, writeStartDocument, writeStartDocument, writeStartDocumentprotected final String mAutomaticNsPrefix
protected int[] mAutoNsSeq
protected String mSuggestedDefNs
protected HashMap<String,String> mSuggestedPrefixes
BaseNsStreamWriter.setPrefix(java.lang.String, java.lang.String), and they are only used as hints for binding;
if there are conflicts, repairing writer can just use some other
prefix.public RepairingNsStreamWriter(XmlWriter xw, String enc, WriterConfig cfg)
public void writeAttribute(String nsURI, String localName, String value) throws XMLStreamException
writeAttribute in interface XMLStreamWriterwriteAttribute in class BaseNsStreamWriterXMLStreamExceptionpublic void writeAttribute(String prefix, String nsURI, String localName, String value) throws XMLStreamException
writeAttribute in interface XMLStreamWriterwriteAttribute in class BaseNsStreamWriterXMLStreamExceptionpublic void writeDefaultNamespace(String nsURI) throws XMLStreamException
writeDefaultNamespace in interface XMLStreamWriterwriteDefaultNamespace in class BaseNsStreamWriterXMLStreamExceptionpublic void writeNamespace(String prefix, String nsURI) throws XMLStreamException
writeNamespace in interface XMLStreamWriterwriteNamespace in class BaseNsStreamWriterXMLStreamExceptionpublic void setDefaultNamespace(String uri) throws XMLStreamException
setDefaultNamespace in interface XMLStreamWritersetDefaultNamespace in class BaseNsStreamWriterXMLStreamExceptionpublic void doSetPrefix(String prefix, String uri) throws XMLStreamException
doSetPrefix in class BaseNsStreamWriterXMLStreamExceptionpublic void writeStartElement(StartElement elem) throws XMLStreamException
BaseStreamWriterXMLEventWriter
implementation, to use when
writing a start element, and possibly its attributes and namespace
declarations.writeStartElement in class BaseNsStreamWriterXMLStreamExceptionprotected void writeTypedAttribute(String prefix, String nsURI, String localName, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws XMLStreamException
TypedStreamWriterwriteTypedAttribute in class BaseNsStreamWriterXMLStreamExceptionprotected void writeStartOrEmpty(String localName, String nsURI) throws XMLStreamException
writeStartOrEmpty in class BaseNsStreamWriterXMLStreamExceptionprotected void writeStartOrEmpty(String suggPrefix, String localName, String nsURI) throws XMLStreamException
writeStartOrEmpty in class BaseNsStreamWriterXMLStreamExceptionpublic final void copyStartElement(InputElementStack elemStack, AttributeCollector ac) throws IOException, XMLStreamException
setPrefix, writeNamespace
and writeStartElement; the order writers expect is
bit different from the order in which element information is
passed in.copyStartElement in class BaseStreamWriterIOExceptionXMLStreamExceptionpublic String validateQNamePrefix(QName name) throws XMLStreamException
BaseStreamWritervalidateQNamePrefix in class BaseStreamWriterXMLStreamExceptionprotected final String findElemPrefix(String nsURI, SimpleOutputElement elem) throws XMLStreamException
nsURI - URI of namespace for which we need a prefixXMLStreamExceptionprotected final String generateElemPrefix(String suggPrefix, String nsURI, SimpleOutputElement elem) throws XMLStreamException
findElemPrefix(java.lang.String, com.ctc.wstx.sw.SimpleOutputElement) has returned null,
to create and bind a namespace mapping for specified namespace.XMLStreamExceptionprotected final String findOrCreateAttrPrefix(String suggPrefix, String nsURI, SimpleOutputElement elem) throws XMLStreamException
suggPrefix - Suggested prefix to bind, if any; may be null
to indicate "no preference"nsURI - URI of namespace for which we need a prefixelem - Currently open start element, on which the attribute
will be added.XMLStreamExceptionCopyright © 2020 FasterXML. All rights reserved.