com.sun.xml.bind.serializer
Interface XMLSerializer

All Known Implementing Classes:
MSVValidator, SAXMarshaller

Deprecated. in JAXB1.0.1

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" ATTRIBUTES "endAttributes" BODY "endElement"
 
 ATTRIBUTES   :=  ( ATTRIBUTE | NSDECL )*
 ATTRIBUTE    :=  "startAttribute" ATTVALUES "endAttribute"
 ATTVALUES    :=  ( "text" | NSDECL )*
 
 NSDECL       :=  "declareNamespace"
 
 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".

Since:
JAXB1.0

Method Summary
 void childAsAttributeBodies(XMLSerializable o)
          Deprecated. This method is called when an XMLSerializable object is found while the marshaller is in the "attribute body" mode (i.e.
 void childAsAttributes(XMLSerializable o)
          Deprecated. This method is called when an XMLSerializable object is found while the marshaller is in the "attribute" mode (i.e.
 void childAsElements(XMLSerializable o)
          Deprecated. This method is called when an XMLSerializable object is found while the marshaller is in the "element" mode (i.e.
 void endAttribute()
          Deprecated.  
 void endAttributes()
          Deprecated. Switches to the mode to marshal child texts/elements.
 void endElement()
          Deprecated. Ends marshalling of an element.
 NamespaceContext2 getNamespaceContext()
          Deprecated. Obtains a namespace context object, which is used to declare/obtain namespace bindings.
 java.lang.String onID(java.lang.String value)
          Deprecated. Notifies the serializer that an ID value has just marshalled.
 java.lang.String onIDREF(java.lang.String value)
          Deprecated. Notifies the serializer that an IDREF value has just marshalled.
 void reportError(javax.xml.bind.ValidationEvent e)
          Deprecated. 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)
          Deprecated. Starts marshalling of an attribute.
 void startElement(java.lang.String uri, java.lang.String local)
          Deprecated. Starts marshalling of an element.
 void text(java.lang.String text)
          Deprecated. Marshalls text.
 

Method Detail

reportError

void reportError(javax.xml.bind.ValidationEvent e)
                 throws AbortSerializationException
Deprecated. 
Errors detected by the XMLSerializable should be either thrown as SAXException or reported through this method. The callee should report an error to the client application and

Throws:
AbortSerializationException

startElement

void startElement(java.lang.String uri,
                  java.lang.String local)
                  throws org.xml.sax.SAXException
Deprecated. 
Starts marshalling of an element. Calling this method will push the internal state into the internal stack.

Throws:
org.xml.sax.SAXException

endAttributes

void endAttributes()
                   throws org.xml.sax.SAXException
Deprecated. 
Switches to the mode to marshal child texts/elements. This method has to be called after the 1st pass is completed.

Throws:
org.xml.sax.SAXException

endElement

void endElement()
                throws org.xml.sax.SAXException
Deprecated. 
Ends marshalling of an element. Pops the internal stack.

Throws:
org.xml.sax.SAXException

text

void text(java.lang.String text)
          throws org.xml.sax.SAXException
Deprecated. 
Marshalls text.

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.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>.

Throws:
org.xml.sax.SAXException

startAttribute

void startAttribute(java.lang.String uri,
                    java.lang.String local)
                    throws org.xml.sax.SAXException
Deprecated. 
Starts marshalling of an attribute. The marshalling of an attribute will be done by
  1. call the startAttribute method
  2. call the text method (several times if necessary)
  3. call the endAttribute method
No two attributes can be marshalled at the same time. Note that the whole attribute marshalling must be happened after the startElement method and before the endAttributes method.

Throws:
org.xml.sax.SAXException

endAttribute

void endAttribute()
                  throws org.xml.sax.SAXException
Deprecated. 
Throws:
org.xml.sax.SAXException

getNamespaceContext

NamespaceContext2 getNamespaceContext()
Deprecated. 
Obtains a namespace context object, which is used to declare/obtain namespace bindings.


onID

java.lang.String onID(java.lang.String value)
                      throws org.xml.sax.SAXException
Deprecated. 
Notifies the serializer that an ID value has just marshalled. The serializer may or may not check the consistency of ID/IDREFs and may throw a SAXException.

Returns:
Return the value parameter without any modification, so that the invocation of this method can be done transparently by a transducer.
Throws:
org.xml.sax.SAXException

onIDREF

java.lang.String onIDREF(java.lang.String value)
                         throws org.xml.sax.SAXException
Deprecated. 
Notifies the serializer that an IDREF value has just marshalled. The serializer may or may not check the consistency of ID/IDREFs and may throw a SAXException.

Returns:
Return the value parameter without any modification. so that the invocation of this method can be done transparently by a transducer.
Throws:
org.xml.sax.SAXException

childAsElements

void childAsElements(XMLSerializable o)
                     throws org.xml.sax.SAXException
Deprecated. 
This method is called when an XMLSerializable object is found while the marshaller is in the "element" mode (i.e. marshalling a content model of an element)

Throws:
org.xml.sax.SAXException

childAsAttributes

void childAsAttributes(XMLSerializable o)
                       throws org.xml.sax.SAXException
Deprecated. 
This method is called when an XMLSerializable object is found while the marshaller is in the "attribute" mode (i.e. marshalling attributes of an element)

Throws:
org.xml.sax.SAXException

childAsAttributeBodies

void childAsAttributeBodies(XMLSerializable o)
                            throws org.xml.sax.SAXException
Deprecated. 
This method is called when an XMLSerializable object is found while the marshaller is in the "attribute body" mode (i.e. marshalling a body of an attribute.)

Throws:
org.xml.sax.SAXException