Package org.biojava.utils.xml
Interface XMLWriter
-
- All Known Implementing Classes:
PrettyXMLWriter
public interface XMLWriter
Simple interface for building XML documents.- Since:
- 1.3
- Author:
- Thomas Down
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidattribute(String qName, String value)Add an un-qualified attribute to an element.voidattribute(String nsURI, String localName, String value)Add an attribute to an element.voidclose()Close this XMLWriter, and it's underlying stream.voidcloseTag(String name)Closes an un-qualified element.voidcloseTag(String nsURI, String qName)Closes an elementvoiddeclareNamespace(String nsURI, String prefixHint)Hints that a namespace is going to be used in a sub-tree.voidopenTag(String name)Open a new unqualified XML tag.voidopenTag(String nsURI, String localName)Open a new namespace-qualified XML tag.voidprint(String data)Prints some textual content in an element.voidprintln(String data)Prints some textual content, terminated with a newline character.voidprintRaw(String s)Send raw data to the stream.
-
-
-
Method Detail
-
printRaw
void printRaw(String s) throws IOException
Send raw data to the stream. Mainly useful for things like DOCTYPE declarations. Use with care!- Parameters:
s- a string of data to include verbatim in the XML stream- Throws:
IOException
-
openTag
void openTag(String nsURI, String localName) throws IOException
Open a new namespace-qualified XML tag.- Parameters:
nsURI- A URI for the namespace to uselocalName- The name of the tag- Throws:
IOException
-
openTag
void openTag(String name) throws IOException
Open a new unqualified XML tag. This may also be used if you want to do namespace management yourself, independantly of the XMLWriter- Parameters:
name- The name of the tag.- Throws:
IOException
-
attribute
void attribute(String nsURI, String localName, String value) throws IOException
Add an attribute to an element. This will throw an exception if it's not called immediately after anopenTagcommand.- Parameters:
nsURI- A URI for the namespace to uselocalName- The name of the attributevalue- The textual value of the attribute- Throws:
IOException
-
attribute
void attribute(String qName, String value) throws IOException
Add an un-qualified attribute to an element. This will throw an exception if it's not called immediately after anopenTagcommand.- Parameters:
qName- The name of the attribute to setvalue- The textual value of the attribute- Throws:
IOException
-
print
void print(String data) throws IOException
Prints some textual content in an element.- Throws:
IOException
-
println
void println(String data) throws IOException
Prints some textual content, terminated with a newline character.- Throws:
IOException
-
closeTag
void closeTag(String nsURI, String qName) throws IOException
Closes an element- Parameters:
nsURI- A URI for the namespace to useqName- The name of the tag- Throws:
IOException
-
closeTag
void closeTag(String name) throws IOException
Closes an un-qualified element.- Parameters:
name- The tag name- Throws:
IOException
-
declareNamespace
void declareNamespace(String nsURI, String prefixHint) throws IOException
Hints that a namespace is going to be used in a sub-tree. Use this method to avoid namespaces that are used only in leaf-nodes of a tree being re-defined every time they are used. The XMLWriter will generally try to use the suggested prefix for this namespace, but there is no guarentee of this. In particular, if the namespace is already in use, the current prefix will still be used. Similarly if the suggested prefix has already been used for another namespace, a new one will be auto-generated.- Parameters:
nsURI- The namespace to declareprefixHint- A suggested prefix-string for this namespace.- Throws:
IOException
-
close
void close() throws IOException
Close this XMLWriter, and it's underlying stream.- Throws:
IOException- Since:
- 1.4
-
-