public interface XMLEventWriter extends XMLEventConsumer
XMLEventReader
,
XMLEvent
,
Characters
,
ProcessingInstruction
,
StartElement
,
EndElement
Modifier and Type | Method and Description |
---|---|
void |
add(XMLEvent event)
事件添加到输出流中加入start_element将打开一个新的命名空间范围将被关闭时,相应的end_element写。
|
void |
add(XMLEventReader reader)
增加了一个整流输出流,呼吁InputStream的说法next()直到hasnext()返回false,这应该被视为一个方便的方法,将执行以下在一个事件的读者和调用所有的事件循环加上每个事件。
|
void |
close()
释放与此流关联的任何资源
|
void |
flush()
将任何缓存事件写入到底层输出机制
|
NamespaceContext |
getNamespaceContext()
返回当前命名空间上下文。
|
String |
getPrefix(String uri)
获取前缀的URI是必然的
|
void |
setDefaultNamespace(String uri)
绑定一个默认的命名空间URI的URI,这必将在当前start_element / end_element对范围。
|
void |
setNamespaceContext(NamespaceContext context)
设置当前的命名空间的前缀和URI绑定上下文。
|
void |
setPrefix(String prefix, String uri)
设置前缀的URI是必然的。
|
void flush() throws XMLStreamException
void close() throws XMLStreamException
void add(XMLEvent event) throws XMLStreamException
Required and optional fields for events added to the writer | |||
---|---|---|---|
Event Type | Required Fields | Optional Fields | Required Behavior |
START_ELEMENT | QName name | namespaces , attributes | A START_ELEMENT will be written by writing the name, namespaces, and attributes of the event in XML 1.0 valid syntax for START_ELEMENTs. The name is written by looking up the prefix for the namespace uri. The writer can be configured to respect prefixes of QNames. If the writer is respecting prefixes it must use the prefix set on the QName. The default behavior is to lookup the value for the prefix on the EventWriter's internal namespace context. Each attribute (if any) is written using the behavior specified in the attribute section of this table. Each namespace (if any) is written using the behavior specified in the namespace section of this table. |
END_ELEMENT | Qname name | None | A well formed END_ELEMENT tag is written. The name is written by looking up the prefix for the namespace uri. The writer can be configured to respect prefixes of QNames. If the writer is respecting prefixes it must use the prefix set on the QName. The default behavior is to lookup the value for the prefix on the EventWriter's internal namespace context. If the END_ELEMENT name does not match the START_ELEMENT name an XMLStreamException is thrown. |
ATTRIBUTE | QName name , String value | QName type | An attribute is written using the same algorithm to find the lexical form as used in START_ELEMENT. The default is to use double quotes to wrap attribute values and to escape any double quotes found in the value. The type value is ignored. |
NAMESPACE | String prefix, String namespaceURI, boolean isDefaultNamespaceDeclaration | None | A namespace declaration is written. If the namespace is a default namespace declaration (isDefault is true) then xmlns="$namespaceURI" is written and the prefix is optional. If isDefault is false, the prefix must be declared and the writer must prepend xmlns to the prefix and write out a standard prefix declaration. |
PROCESSING_INSTRUCTION | None | String target, String data | The data does not need to be present and may be null. Target is required and many not be null. The writer will write data section directly after the target, enclosed in appropriate XML 1.0 syntax |
COMMENT | None | String comment | If the comment is present (not null) it is written, otherwise an an empty comment is written |
START_DOCUMENT | None | String encoding , boolean standalone, String version | A START_DOCUMENT event is not required to be written to the stream. If present the attributes are written inside the appropriate XML declaration syntax |
END_DOCUMENT | None | None | Nothing is written to the output |
DTD | String DocumentTypeDefinition | None | The DocumentTypeDefinition is written to the output |
add
接口
XMLEventConsumer
event
-事件被添加
XMLStreamException
void add(XMLEventReader reader) throws XMLStreamException
reader
的事件流添加到输出
XMLStreamException
String getPrefix(String uri) throws XMLStreamException
uri
- URI查找
XMLStreamException
void setPrefix(String prefix, String uri) throws XMLStreamException
prefix
-前缀绑定到URI
uri
- URI绑定前缀
XMLStreamException
void setDefaultNamespace(String uri) throws XMLStreamException
uri
- URI绑定默认命名空间
XMLStreamException
void setNamespaceContext(NamespaceContext context) throws XMLStreamException
context
-命名空间上下文使用这个作家
XMLStreamException
NamespaceContext getNamespaceContext()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.