@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); } }
IXMLWriter xwrite = ctx.getXmlWriter(); int ixsi = xwrite.getNamespaces().length; String[][] extens = xwrite.getExtensionNamespaces(); ctx.startTagNamespaces(m_index, m_name, new int[] { ixsi, ixsi+1 }, SCHEMA_NAMESPACE_PREFIXES). attribute(m_index, SIZE_ATTRIBUTE_NAME, map.size()). closeStartContent(); ctx.startTagAttributes(m_index, ENTRY_ELEMENT_NAME); ctx.attribute(m_index, KEY_ATTRIBUTE_NAME, entry.getKey().toString()); ctx.attribute(ixsi, TYPE_ATTRIBUTE_NAME, XSD_PREFIX_LEAD + s_schemaTypesEnum.getName(type)); ctx.closeStartContent(); ctx.content(Utility.serializeBoolean (((Boolean)value).booleanValue())); break; ctx.content(Utility. serializeByte(((Byte)value).byteValue())); break; ctx.content(Utility. serializeDouble(((Double)value).doubleValue())); break;
int[] copy = new int[m_nsIndexes.length]; System.arraycopy(m_nsIndexes, 0, copy, 0, m_nsIndexes.length); m_context.startTagNamespaces(m_schemaIndex, node.name(), copy, m_nsPrefixes); } else { m_context.startTagAttributes(m_schemaIndex, node.name()); IMarshaller marshaller = m_context.getMarshaller(node.getClass().getName()); marshaller.marshal(node, m_context); m_context.closeStartContent(); IXMLWriter writer = m_context.getXmlWriter(); writer.indent(); writer.writeComment(text.toString());
m_marshalContext.setOutput(os, null); m_marshalContext.setIndent(2); m_marshalContext.setUserContext(def); IMarshaller mar = m_marshalContext.getMarshaller(Definitions.class.getName()); mar.marshal(def, m_marshalContext); m_marshalContext.endDocument();
ctx.startTagAttributes(m_index, m_name). attribute(m_index, getSizeAttributeName(), map.size()). closeStartContent(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry)iter.next(); ctx.startTagAttributes(m_index, getEntryElementName()); ctx.attribute(m_index, getKeyAttributeName(), entry.getKey().toString()); ctx.closeStartContent(); if (entry.getValue() instanceof IMarshallable) { ((IMarshallable)entry.getValue()).marshal(ctx); ctx.endTag(m_index, getEntryElementName()); } else { throw new JiBXException("Mapped value is not marshallable"); ctx.endTag(m_index, m_name);
context.setIndent(m_outputIndent); if (m_outputWriter == null) { if (m_outputStream == null) { throw new JiBXException("Output not configured"); } else { context.setOutput(m_outputStream, m_outputEncoding); context.setOutput(m_outputWriter); context.startDocument(m_outputEncoding, null); ((IMarshallable)obj).marshal(context); context.endDocument(); return;
@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); } }
HashMap map = ctx.getIdMap(); String id = getIdValue(obj); Object value = map.get(id); ctx.startTagAttributes(m_index, m_name); ctx.attribute(0, getAttributeName(), id); ctx.closeStartEmpty();
public void marshal(Object obj, IMarshallingContext ictx) throws JiBXException { // make sure the parameters are as expected if (obj == null) { return; } else if (!(ictx instanceof MarshallingContext)) { throw new JiBXException("Invalid context type for marshaller"); } else { // generate the element start tag MarshallingContext ctx = (MarshallingContext)ictx; ctx.startTagAttributes(m_index, m_name); // add attribute reference to object ID ctx.attribute(0, getAttributeName(), getIdValue(obj)); // close start tag for empty element ctx.closeStartEmpty(); } }
m_context.setOutput(strwriter); IXMLWriter xmlwriter = m_context.getXmlWriter(); int base = xmlwriter.getNamespaceCount(); xmlwriter.pushExtensionNamespaces(uris);
public void marshal(Object obj, IMarshallingContext ctx) throws JiBXException { try { m_schemaContext.setFromContext((MarshallingContext)ctx); ((IMarshallable)obj).marshal(m_schemaContext); m_schemaContext.getXmlWriter().flush(); } catch (IOException e) { throw new JiBXException("Error writing schema", e); } } }
/** * Exit a schema node. This just writes the end tag for the node. * * @param node */ public void exit(SchemaBase node) { try { m_context.endTag(m_schemaIndex, node.name()); } catch (JiBXException e) { s_logger.fatal("Binding failed", e); throw new IllegalStateException("Internal error - binding failed: " + e.getMessage()); } }
/** * Constructor. * * @throws JiBXException on error loading binding information */ public SchemaDocumentationGenerator() throws JiBXException { m_factory = BindingDirectory.getFactory("schema_extract_binding", "org.jibx.schema.codegen"); int index = 0; String[] uris = m_factory.getNamespaces(); m_namespaceSet = new HashSet(); for (int i = 1; i < uris.length; i++) { m_namespaceSet.add(uris[i]); if (SCHEMA_DEFINITIONS_NS.equals(uris[i])) { index = i; } } if (index < 0) { throw new JiBXException("Schema namespace definition not found"); } m_schemaIndex = index; m_schemaPrefix = m_factory.getPrefixes()[index]; m_context = (MarshallingContext)m_factory.createMarshallingContext(); m_context.setIndent(2, COMMENT_LEAD_TEXT, ' '); }
IXMLWriter ixw = ((MarshallingContext)ictx).getXmlWriter(); int index = -1; int tryidx = ixw.getPrefixIndex(qname.m_prefix);
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); } }