|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface XMLSerializer
Receives XML serialization event
This object coordinates the overall marshalling efforts across different content-tree objects and different target formats.
The following CFG gives the proper sequence of method invocation.
MARSHALLING := ELEMENT ELEMENT := "startElement" NSDECL* "endNamespaceDecls" ATTRIBUTE* "endAttributes" BODY "endElement" NSDECL := "declareNamespace" ATTRIBUTE := "startAttribute" ATTVALUES "endAttribute" ATTVALUES := "text"* BODY := ( "text" | ELEMENT )*
A marshalling of one element consists of two stages. The first stage is for marshalling attributes and collecting namespace declarations. The second stage is for marshalling characters/child elements of that element.
Observe that multiple invocation of "text" is allowed.
Also observe that the namespace declarations are allowed only between "startElement" and "endAttributes".
Method Summary | |
---|---|
void |
childAsAttributes(com.sun.xml.bind.JAXBObject o,
java.lang.String fieldName)
This method is called when an JAXBObject object is found while the marshaller is in the "attribute" mode (i.e. marshalling attributes of an element) |
void |
childAsBody(com.sun.xml.bind.JAXBObject o,
java.lang.String fieldName)
This method is called when an JAXBObject object is found while the marshaller is in the "element" mode (i.e. marshalling a content model of an element) |
void |
childAsURIs(com.sun.xml.bind.JAXBObject o,
java.lang.String fieldName)
This method is called when an JAXBObject object is found while the marshaller is in the "URI" mode. |
void |
endAttribute()
|
void |
endAttributes()
Switches to the mode to marshal child texts/elements. |
void |
endElement()
Ends marshalling of an element. |
void |
endNamespaceDecls()
Switches to the mode to marshal attribute values. |
NamespaceContext2 |
getNamespaceContext()
Obtains a namespace context object, which is used to declare/obtain namespace bindings. |
java.lang.String |
onID(com.sun.xml.bind.marshaller.IdentifiableObject owner,
java.lang.String value)
Notifies the serializer that an ID value has just marshalled. |
java.lang.String |
onIDREF(com.sun.xml.bind.marshaller.IdentifiableObject obj)
Notifies the serializer that an IDREF value has just marshalled. |
void |
reportError(javax.xml.bind.ValidationEvent e)
Errors detected by the XMLSerializable should be either thrown as SAXException or reported through this method. |
void |
startAttribute(java.lang.String uri,
java.lang.String local)
Starts marshalling of an attribute. |
void |
startElement(java.lang.String uri,
java.lang.String local)
Starts marshalling of an element. |
void |
text(java.lang.String text,
java.lang.String fieldName)
Marshalls text. |
Method Detail |
---|
void reportError(javax.xml.bind.ValidationEvent e) throws com.sun.xml.bind.serializer.AbortSerializationException
SAXException
or reported through this method.
The callee should report an error to the client application and
com.sun.xml.bind.serializer.AbortSerializationException
void startElement(java.lang.String uri, java.lang.String local) throws org.xml.sax.SAXException
org.xml.sax.SAXException
void endNamespaceDecls() throws org.xml.sax.SAXException
org.xml.sax.SAXException
void endAttributes() throws org.xml.sax.SAXException
org.xml.sax.SAXException
void endElement() throws org.xml.sax.SAXException
org.xml.sax.SAXException
void text(java.lang.String text, java.lang.String fieldName) throws org.xml.sax.SAXException
This method can be called (i) after the startAttribute method and (ii) before the endAttribute method, to marshal attribute values. If the method is called more than once, those texts are considered as separated by whitespaces. For example,
c.startAttribute(); c.text("abc"); c.text("def"); c.endAttribute("", "foo");will generate foo="abc def".
Similarly, this method can be called after the endAttributes method to marshal texts inside elements. The same rule about multiple invokations apply to this case, too. For example,
c.startElement("", "foo"); c.endNamespaceDecls(); c.endAttributes(); c.text("abc"); c.text("def"); c.startElement("", "bar"); c.endAttributes(); c.endElement(); c.text("ghi"); c.endElement();will generate
<foo>abc def<bar/>ghi</foo>
.
org.xml.sax.SAXException
void startAttribute(java.lang.String uri, java.lang.String local) throws org.xml.sax.SAXException
org.xml.sax.SAXException
void endAttribute() throws org.xml.sax.SAXException
org.xml.sax.SAXException
NamespaceContext2 getNamespaceContext()
java.lang.String onID(com.sun.xml.bind.marshaller.IdentifiableObject owner, java.lang.String value) throws org.xml.sax.SAXException
owner
- JAXB content object that posesses the ID.value
- The value of the ID.
org.xml.sax.SAXException
java.lang.String onIDREF(com.sun.xml.bind.marshaller.IdentifiableObject obj) throws org.xml.sax.SAXException
org.xml.sax.SAXException
void childAsBody(com.sun.xml.bind.JAXBObject o, java.lang.String fieldName) throws org.xml.sax.SAXException
fieldName
- property name of the parent objeect from which 'o' comes. Used
as a part of the error message in case anything goes wrong
with 'o'.
org.xml.sax.SAXException
void childAsAttributes(com.sun.xml.bind.JAXBObject o, java.lang.String fieldName) throws org.xml.sax.SAXException
fieldName
- property name of the parent objeect from which 'o' comes. Used
as a part of the error message in case anything goes wrong
with 'o'.
org.xml.sax.SAXException
void childAsURIs(com.sun.xml.bind.JAXBObject o, java.lang.String fieldName) throws org.xml.sax.SAXException
fieldName
- property name of the parent objeect from which 'o' comes. Used
as a part of the error message in case anything goes wrong
with 'o'.
org.xml.sax.SAXException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |