Examples of IXMLWriter


Examples of org.jibx.runtime.IXMLWriter

                    }
                }
            }
           
            // marshal with all namespace declarations, since external state unknown
            IXMLWriter writer = new StAXWriter(nss, xmlWriter);
            IMarshallingContext ctx = bindingFactory.createMarshallingContext();
            ctx.setXmlWriter(writer);
            marshal(full, ctx);
           
        } catch (JiBXException e) {
View Full Code Here

Examples of org.jibx.runtime.IXMLWriter

                } else {
                    throw new IllegalStateException("Object of class " + dataObject.getClass().getName() +
                        " needs a JiBX <mapping> to be marshalled");
                }
            } else {
                IXMLWriter wrtr = ctx.getXmlWriter();
                String name = elementName;
                int nsidx = 0;
                if (full) {
                   
                    // declare all namespaces on start tag
                    nsidx = elementNamespaceIndex;
                    wrtr.startTagNamespaces(nsidx, name, openNamespaceIndexes, openNamespacePrefixes);
                   
                } else {
       
                    // configure writer with namespace declared in enclosing scope
                    wrtr.openNamespaces(openNamespaceIndexes, openNamespacePrefixes);
                    if (!"".equals(elementNamespacePrefix)) {
                        name = elementNamespacePrefix + ':' + name;
                    }
                    wrtr.startTagOpen(0, name);
                }
               
                // marshal object representation (may include attributes) into element
                IMarshaller mrsh = ctx.getMarshaller(marshallerName);
                mrsh.marshal(dataObject, ctx);
                wrtr.endTag(nsidx, name);
            }
            ctx.getXmlWriter().flush();

        } catch (IOException e) {
            throw new JiBXException("Error marshalling XML representation: " + e.getMessage(), e);
View Full Code Here

Examples of org.jibx.runtime.IXMLWriter

                    }
                }
            }
           
            // marshal with all namespace declarations, since external state unknown
            IXMLWriter writer = new StAXWriter(nss, xmlWriter);
            IMarshallingContext ctx = bindingFactory.createMarshallingContext();
            ctx.setXmlWriter(writer);
            marshal(full, ctx);
           
        } catch (JiBXException e) {
View Full Code Here

Examples of org.jibx.runtime.IXMLWriter

     */
    private void marshal(IMarshallingContext ctx) throws JiBXException {
        if (marshallerIndex < 0) {
            ((IMarshallable)dataObject).marshal(ctx);
        } else {
            IXMLWriter wrtr = ctx.getXmlWriter();
            int nsidx = 0;
            boolean nsfound = true;
            if (!"".equals(elementNamespaceUri)) {
                nsfound = false;
                for (nsidx = wrtr.getNamespaceCount()-1; nsidx > 1; nsidx--) {
                    if (elementNamespaceUri.equals(wrtr.getNamespaceUri(nsidx))) {
                        nsfound = true;
                        break;
                    }
                }
            }
            try {
                if (nsfound) {
                    wrtr.startTagOpen(nsidx, elementName);
                } else {
                    nsidx = wrtr.getNamespaceCount();
                    String[] uris = new String[] { elementNamespaceUri };
                    int[] indexes = new int[] { nsidx };
                    String[] prefixes = new String[] { "" };
                    wrtr.pushExtensionNamespaces(uris);
                    wrtr.startTagNamespaces(nsidx, elementName, indexes, prefixes);
                }
                IMarshaller mrsh = ctx.getMarshaller(marshallerIndex,
                    bindingFactory.getMappedClasses()[marshallerIndex]);
                mrsh.marshal(dataObject, ctx);
                wrtr.endTag(nsidx, elementName);
                if (!nsfound) {
                    wrtr.popExtensionNamespaces();
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
View Full Code Here

Examples of org.jibx.runtime.IXMLWriter

    /* (non-Javadoc)
     * @see org.apache.axiom.om.OMDataSource#serialize(javax.xml.stream.XMLStreamWriter)
     */
    public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
        try {
            IXMLWriter writer = new StAXWriter(bindingFactory.getNamespaces(),
                xmlWriter);
            IMarshallingContext ctx = bindingFactory.createMarshallingContext();
            ctx.setXmlWriter(writer);
            marshal(ctx);
        } catch (JiBXException e) {
View Full Code Here

Examples of org.jibx.runtime.IXMLWriter

    }
  }

  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);
  }
View Full Code Here

Examples of org.jibx.runtime.IXMLWriter

  @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);
View Full Code Here

Examples of org.jibx.runtime.IXMLWriter

    /* (non-Javadoc)
     * @see org.apache.axiom.om.OMDataSource#serialize(javax.xml.stream.XMLStreamWriter)
     */
    public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
        try {
            IXMLWriter writer = new StAXWriter(bindingFactory.getNamespaces(),
                xmlWriter);
            IMarshallingContext ctx = bindingFactory.createMarshallingContext();
            ctx.setXmlWriter(writer);
            outObject.marshal(ctx);
        } catch (JiBXException e) {
View Full Code Here

Examples of org.jibx.runtime.IXMLWriter

                } else {
                    throw new IllegalStateException("Object of class " + dataObject.getClass().getName() +
                        " needs a JiBX <mapping> to be marshalled");
                }
            } else {
                IXMLWriter wrtr = ctx.getXmlWriter();
                String name = elementName;
                int nsidx = 0;
                if (full) {
                   
                    // declare all namespaces on start tag
                    nsidx = elementNamespaceIndex;
                    wrtr.startTagNamespaces(nsidx, name, openNamespaceIndexes, openNamespacePrefixes);
                   
                } else {
       
                    // configure writer with namespace declared in enclosing scope
                    wrtr.openNamespaces(openNamespaceIndexes, openNamespacePrefixes);
                    if (!"".equals(elementNamespacePrefix)) {
                        name = elementNamespacePrefix + ':' + name;
                    }
                    wrtr.startTagOpen(0, name);
                }
               
                // marshal object representation (may include attributes) into element
                IMarshaller mrsh = ctx.getMarshaller(marshallerName);
                mrsh.marshal(dataObject, ctx);
                wrtr.endTag(nsidx, name);
            }
            ctx.getXmlWriter().flush();

        } catch (IOException e) {
            throw new JiBXException("Error marshalling XML representation: " + e.getMessage(), e);
View Full Code Here

Examples of org.jibx.runtime.IXMLWriter

                    }
                }
            }
           
            // marshal with all namespace declarations, since external state unknown
            IXMLWriter writer = new StAXWriter(nss, xmlWriter);
            IMarshallingContext ctx = bindingFactory.createMarshallingContext();
            ctx.setXmlWriter(writer);
            marshal(full, ctx);
           
        } catch (JiBXException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.