public interface XMLStreamWriter
XML Namespaces, javax.xml.stream.isRepairingNamespaces and write method behaviour |
||||
---|---|---|---|---|
方法 | isRepairingNamespaces == true |
isRepairingNamespaces == false |
||
namespaceURI bound | namespaceURI unbound | namespaceURI bound | namespaceURI unbound | |
writeAttribute(namespaceURI, localName, value) |
prefix:localName="value" [1] | xmlns:{generated}="namespaceURI" {generated}:localName="value" | prefix:localName="value" [1] |
XMLStreamException |
writeAttribute(prefix, namespaceURI, localName, value) |
bound to same prefix: prefix:localName="value" [1] bound to different prefix: xmlns:{generated}="namespaceURI" {generated}:localName="value" |
xmlns:prefix="namespaceURI" prefix:localName="value" [3] |
bound to same prefix: prefix:localName="value" [1][2] bound to different prefix: XMLStreamException [2] |
xmlns:prefix="namespaceURI" prefix:localName="value" [2][5] |
writeStartElement(namespaceURI, localName) writeEmptyElement(namespaceURI, localName) |
<prefix:localName> [1] | <{generated}:localName xmlns:{generated}="namespaceURI"> | <prefix:localName> [1] |
XMLStreamException |
writeStartElement(prefix, localName, namespaceURI) writeEmptyElement(prefix, localName, namespaceURI) |
bound to same prefix: <prefix:localName> [1] bound to different prefix: <{generated}:localName xmlns:{generated}="namespaceURI"> |
<prefix:localName xmlns:prefix="namespaceURI"> [4] |
bound to same prefix: <prefix:localName> [1] bound to different prefix: XMLStreamException |
<prefix:localName> |
Notes:
|
XMLOutputFactory
,
XMLStreamReader
Modifier and Type | Method and Description |
---|---|
void |
close()
关闭这个作家,并释放与作者相关的任何资源。
|
void |
flush()
将任何缓存数据写入到底层输出机制。
|
NamespaceContext |
getNamespaceContext()
返回当前命名空间上下文。
|
String |
getPrefix(String uri)
获取前缀的URI是必然的
|
Object |
getProperty(String name)
从底层实现获取一个功能/属性的值
|
void |
setDefaultNamespace(String uri)
绑定一个默认的命名空间URI的URI,这必将在当前start_element / end_element对范围。
|
void |
setNamespaceContext(NamespaceContext context)
设置当前的命名空间的前缀和URI绑定上下文。
|
void |
setPrefix(String prefix, String uri)
设置前缀的URI是必然的。
|
void |
writeAttribute(String localName, String value)
在没有前缀的情况下将一个属性写入到输出流中。
|
void |
writeAttribute(String namespaceURI, String localName, String value)
将属性写入输出流
|
void |
writeAttribute(String prefix, String namespaceURI, String localName, String value)
将属性写入输出流
|
void |
writeCData(String data)
写一个CDATA部分
|
void |
writeCharacters(char[] text, int start, int len)
写入输出的文本
|
void |
writeCharacters(String text)
写入输出的文本
|
void |
writeComment(String data)
用封闭的数据写入XML注释
|
void |
writeDefaultNamespace(String namespaceURI)
将默认命名空间写入流
|
void |
writeDTD(String dtd)
写一个DTD部分。
|
void |
writeEmptyElement(String localName)
将一个空元素标记写入输出
|
void |
writeEmptyElement(String namespaceURI, String localName)
将一个空元素标记写入输出
|
void |
writeEmptyElement(String prefix, String localName, String namespaceURI)
将一个空元素标记写入输出
|
void |
writeEndDocument()
关闭任何开始标记并写入相应的结束标记。
|
void |
writeEndElement()
将结束标记写入依赖于写作者的内部状态,以确定事件的前缀和本地名称。
|
void |
writeEntityRef(String name)
写入实体引用
|
void |
writeNamespace(String prefix, String namespaceURI)
写一个命名空间输出流如果前缀论证方法是空字符串,“xmlns”,或空的方法将委托writedefaultnamespace
|
void |
writeProcessingInstruction(String target)
写一个处理指令
|
void |
writeProcessingInstruction(String target, String data)
写一个处理指令
|
void |
writeStartDocument()
写XML声明。
|
void |
writeStartDocument(String version)
写XML声明。
|
void |
writeStartDocument(String encoding, String version)
写XML声明。
|
void |
writeStartElement(String localName)
将开始标记写入输出。
|
void |
writeStartElement(String namespaceURI, String localName)
将开始标记写入输出
|
void |
writeStartElement(String prefix, String localName, String namespaceURI)
将开始标记写入输出
|
void writeStartElement(String localName) throws XMLStreamException
localName
-标签的本地名称,不得空
XMLStreamException
void writeStartElement(String namespaceURI, String localName) throws XMLStreamException
namespaceURI
-前缀使用namespaceuri,不得空
localName
-标签的本地名称,不得空
XMLStreamException
如果命名空间URI没有绑定到一个前缀和javax.xml.stream.isrepairingnamespaces尚未设置为true
void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException
localName
-标签的本地名称,不得空
prefix
-标签的前缀,不得空
namespaceURI
- URI绑定前缀,不得空
XMLStreamException
void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException
namespaceURI
- URI绑定标签,不得空
localName
-标签的本地名称,不得空
XMLStreamException
如果命名空间URI没有绑定到一个前缀和javax.xml.stream.isrepairingnamespaces尚未设置为true
void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException
prefix
-标签的前缀,不得空
localName
-标签的本地名称,不得空
namespaceURI
- URI绑定标签,不得空
XMLStreamException
void writeEmptyElement(String localName) throws XMLStreamException
localName
-标签的本地名称,不得空
XMLStreamException
void writeEndElement() throws XMLStreamException
void writeEndDocument() throws XMLStreamException
void close() throws XMLStreamException
void flush() throws XMLStreamException
void writeAttribute(String localName, String value) throws XMLStreamException
localName
-属性的本地名称
value
-该属性的值
IllegalStateException
-如果当前状态不允许属性的写作
XMLStreamException
void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException
prefix
-这个属性的前缀
namespaceURI
-此属性的前缀的URI
localName
-属性的本地名称
value
-该属性的值
IllegalStateException
-如果当前状态不允许属性的写作
XMLStreamException
如果命名空间URI没有绑定到一个前缀和javax.xml.stream.isrepairingnamespaces尚未设置为true
void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException
namespaceURI
-此属性的前缀的URI
localName
-属性的本地名称
value
-该属性的值
IllegalStateException
-如果当前状态不允许属性的写作
XMLStreamException
如果命名空间URI没有绑定到一个前缀和javax.xml.stream.isrepairingnamespaces尚未设置为true
void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException
prefix
-绑定命名空间前缀
namespaceURI
- URI绑定前缀
IllegalStateException
-如果当前状态不允许命名空间写作
XMLStreamException
void writeDefaultNamespace(String namespaceURI) throws XMLStreamException
namespaceURI
- URI绑定默认命名空间
IllegalStateException
-如果当前状态不允许命名空间写作
XMLStreamException
void writeComment(String data) throws XMLStreamException
data
的数据,可能是空的
XMLStreamException
void writeProcessingInstruction(String target) throws XMLStreamException
target
-处理指令的目标,不可能是空的
XMLStreamException
void writeProcessingInstruction(String target, String data) throws XMLStreamException
target
-处理指令的目标,不可能是空的
data
-数据,不得空
XMLStreamException
void writeCData(String data) throws XMLStreamException
data
-数据,不得空
XMLStreamException
void writeDTD(String dtd) throws XMLStreamException
dtd
的DTD来写的
XMLStreamException
void writeEntityRef(String name) throws XMLStreamException
name
-单位名称
XMLStreamException
void writeStartDocument() throws XMLStreamException
void writeStartDocument(String version) throws XMLStreamException
version
对XML文档的版本
XMLStreamException
void writeStartDocument(String encoding, String version) throws XMLStreamException
encoding
- XML声明的编码
version
对XML文档的版本
XMLStreamException
-如果编码不匹配的基本流编码
void writeCharacters(String text) throws XMLStreamException
text
价值-写
XMLStreamException
void writeCharacters(char[] text, int start, int len) throws XMLStreamException
text
价值-写
start
-数组中的起始位置
len
-数目字写
XMLStreamException
String getPrefix(String uri) throws XMLStreamException
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()
Object getProperty(String name) throws IllegalArgumentException
name
-属性的名称,不得空
IllegalArgumentException
如果物业不支持
NullPointerException
-如果名称是空的
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.