* Marshal the content tree rooted at jaxbElement into a .
*/
public void marshal(Object jaxbElement, XMLStreamWriter writer)
throws JAXBException
{
ClassSkeleton skeleton = _context.findSkeletonForObject(jaxbElement);
if (skeleton == null)
throw new MarshalException(L.l("Unable to marshal {0}: its type unknown to this JAXBContext", jaxbElement));
Class c = skeleton.getType();
writer = StaxUtil.toRepairingXMLStreamWriter(writer);
// tck/JAXBMarshall
if (! _context.createJAXBIntrospector().isElement(jaxbElement) &&
! c.isAnnotationPresent(XmlRootElement.class))
throw new MarshalException("JAXBIntrospector.isElement()==false");
/*
String name = null;
String namespace = null;
/// XXX: put into skeleton?
XmlType xmlTypeAnnotation = (XmlType) c.getAnnotation(XmlType.class);
if (name == null) {
name =
(xmlTypeAnnotation == null ? c.getName() : xmlTypeAnnotation.name());
}
XmlRootElement xre = (XmlRootElement) c.getAnnotation(XmlRootElement.class);
if (xre != null)
name = xre.name();*/
String encoding = getEncoding();
if (encoding == null)
encoding = "utf-8";
try {
if (!isFragment())
writer.writeStartDocument(encoding, "1.0");
// XXX this needs to happen after the startElement is written
// jaxb/5003
/*
if (getNoNSSchemaLocation() != null)
writer.writeAttribute("xsi",
"http://www.w3.org/2001/XMLSchema-instance",
"noNamespaceSchemaLocation",
getNoNSSchemaLocation());
*/
skeleton.write(this, writer, jaxbElement, null, null);
writer.writeEndDocument();
}
catch (JAXBException e) {
throw e;