org.jibx.runtime.IXMLWriter Java Examples

The following examples show how to use org.jibx.runtime.IXMLWriter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JibxMarshaller.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void marshalDocument(IMarshallingContext marshallingContext, Object graph) throws IOException, JiBXException {
	if (StringUtils.hasLength(this.docTypeRootElementName)) {
		IXMLWriter xmlWriter = marshallingContext.getXmlWriter();
		xmlWriter.writeDocType(this.docTypeRootElementName, this.docTypeSystemId,
				this.docTypePublicId, this.docTypeInternalSubset);
	}
	marshallingContext.marshalDocument(graph);
}
 
Example #2
Source File: JibxMarshaller.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
	try {
		MarshallingContext marshallingContext = (MarshallingContext) createMarshallingContext();
		IXMLWriter xmlWriter = new StAXWriter(marshallingContext.getNamespaces(), streamWriter);
		marshallingContext.setXmlWriter(xmlWriter);
		marshallingContext.marshalDocument(graph);
	}
	catch (JiBXException ex) {
		throw convertJibxException(ex, false);
	}
}
 
Example #3
Source File: JibxMarshaller.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void marshalDocument(IMarshallingContext marshallingContext, Object graph) throws IOException, JiBXException {
	if (StringUtils.hasLength(this.docTypeRootElementName)) {
		IXMLWriter xmlWriter = marshallingContext.getXmlWriter();
		xmlWriter.writeDocType(this.docTypeRootElementName, this.docTypeSystemId,
				this.docTypePublicId, this.docTypeInternalSubset);
	}
	marshallingContext.marshalDocument(graph);
}
 
Example #4
Source File: JibxMarshaller.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
	try {
		MarshallingContext marshallingContext = (MarshallingContext) createMarshallingContext();
		IXMLWriter xmlWriter = new StAXWriter(marshallingContext.getNamespaces(), streamWriter);
		marshallingContext.setXmlWriter(xmlWriter);
		marshallingContext.marshalDocument(graph);
	}
	catch (JiBXException ex) {
		throw convertJibxException(ex, false);
	}
}
 
Example #5
Source File: JibxMarshaller.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void marshalDocument(IMarshallingContext marshallingContext, Object graph) throws IOException, JiBXException {
	if (StringUtils.hasLength(docTypeRootElementName)) {
		IXMLWriter xmlWriter = marshallingContext.getXmlWriter();
		xmlWriter.writeDocType(docTypeRootElementName, docTypeSystemId, docTypePublicId, docTypeInternalSubset);
	}
	marshallingContext.marshalDocument(graph);
}
 
Example #6
Source File: JibxMarshaller.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
	try {
		MarshallingContext marshallingContext = (MarshallingContext) createMarshallingContext();
		IXMLWriter xmlWriter = new StAXWriter(marshallingContext.getNamespaces(), streamWriter);
		marshallingContext.setXmlWriter(xmlWriter);
		marshallingContext.marshalDocument(graph);
	}
	catch (JiBXException ex) {
		throw convertJibxException(ex, false);
	}
}
 
Example #7
Source File: MLPResponse.java    From gmlc with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Create the svc_result XML result for any type of result (error or success)
 *
 * @param mlpSvcResult  Fully filled in SvcResult object to marshal (convert to XML)
 * @return              String of XML result to send to client
 * @throws org.jibx.runtime.JiBXException JiBX had an internal failure of some kind while marshalling the XML
 * @throws IOException  IO error occurred while generating the XML result
 */
private String marshalMlpResult(org.oma.protocols.mlp.svc_result.SvcResult mlpSvcResult)
    throws org.jibx.runtime.JiBXException, IOException {
  String lXml = null;

  IBindingFactory jc = BindingDirectory.getFactory(org.oma.protocols.mlp.svc_result.SvcResult.class);
  IMarshallingContext marshaller = jc.createMarshallingContext();
  ByteArrayOutputStream lOutputStream = new ByteArrayOutputStream();
  marshaller.setOutput(lOutputStream, "UTF-8");
  IXMLWriter ix = marshaller.getXmlWriter();

  // Add XML and DOCTYPE headers
  ix.writeXMLDecl("1.0", "UTF-8", null);
  ix.writeDocType("svc_result", "MLP_SVC_RESULT_310.DTD", null, null);

  // Set 4 spaces as the default indenting
  marshaller.setIndent(4);

  // Generate the XML
  marshaller.marshalDocument(mlpSvcResult);

  // Convert the stream to a string
  lXml = new String(lOutputStream.toByteArray(), "UTF-8");

  // Return our XML string result
  return lXml;
}
 
Example #8
Source File: MLPResponse.java    From gmlc with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Internal XML generation support function for above getSystemErrorResponseXML()
 *
 * @param mlpClientErrorType                Error type to return to client
 * @param mlpClientErrorMessage             Error message to send to client
 * @return                                  String XML result to return to client
 * @throws org.jibx.runtime.JiBXException   JiBX had an internal failure of some kind while marshalling the XML
 * @throws IOException                      IO error occurred while generating the XML result
 */
private String generateSystemErrorXML(MLPResultType mlpClientErrorType, String mlpClientErrorMessage)
    throws org.jibx.runtime.JiBXException, IOException {
  String lXml = null;
  String ver = "3.1.0";

  // Create all the objects we'll use to generate our svc_result XML
  org.oma.protocols.mlp.svc_result.SvcResult mlpSvcResult = new org.oma.protocols.mlp.svc_result.SvcResult();
  org.oma.protocols.mlp.svc_result.Slia mlpSlia = new org.oma.protocols.mlp.svc_result.Slia();
  org.oma.protocols.mlp.svc_result.Result mlpResult = new org.oma.protocols.mlp.svc_result.Result();
  org.oma.protocols.mlp.svc_result.AddInfo mlpAddInfo = new org.oma.protocols.mlp.svc_result.AddInfo();

  // Set the additional data error message if one is available
  if (mlpClientErrorMessage != null) {
    mlpAddInfo.setAddInfo(mlpClientErrorMessage);
    mlpSlia.setAddInfo(mlpAddInfo);
  }

  mlpResult.setString(MLPResponse.getResultStringForType(mlpClientErrorType));
  mlpResult.setResid(MLPResponse.getResultCodeForType(mlpClientErrorType));
  mlpSlia.setResult(mlpResult);
  mlpSlia.setVer(ver);
  mlpSvcResult.setSlia(mlpSlia);
  mlpSvcResult.setVer(ver);

  IBindingFactory jc = BindingDirectory.getFactory(org.oma.protocols.mlp.svc_result.SvcResult.class);
  IMarshallingContext marshaller = jc.createMarshallingContext();
  ByteArrayOutputStream lOutputStream = new ByteArrayOutputStream();
  marshaller.setOutput(lOutputStream, "UTF-8");
  IXMLWriter ix = marshaller.getXmlWriter();

  // Add XML and DOCTYPE headers
  ix.writeXMLDecl("1.0", "UTF-8", null);
  ix.writeDocType("svc_result", "MLP_SVC_RESULT_310.DTD", null, null);

  // Set 4 spaces as the default indenting
  marshaller.setIndent(4);

  // Generate the XML
  marshaller.marshalDocument(mlpSvcResult);

  // Convert the stream to a string
  lXml = new String(lOutputStream.toByteArray(), "UTF-8");

  // Return our XML string result
  return lXml;
}