Package com.caucho.xml

Examples of com.caucho.xml.XmlPrinter


    Properties output = _stylesheet.getOutputProperties();

    com.caucho.vfs.StringWriter sw = new com.caucho.vfs.StringWriter();
    WriteStream ws = sw.openWrite();
   
    XmlPrinter out = new XmlPrinter(ws);

    out.setMethod((String) output.get(OutputKeys.METHOD));
    out.setEncoding("UTF-8");
    out.setMimeType((String) output.get(OutputKeys.MEDIA_TYPE));
    String omit = (String) output.get(OutputKeys.OMIT_XML_DECLARATION);

    if (omit == null || omit.equals("false") || omit.equals("no"))
      out.setPrintDeclaration(true);
    out.setStandalone((String) output.get(OutputKeys.STANDALONE));
    out.setSystemId((String) output.get(OutputKeys.DOCTYPE_SYSTEM));
    out.setPublicId((String) output.get(OutputKeys.DOCTYPE_PUBLIC));
   
    String indent = (String) output.get(OutputKeys.INDENT);
    if (indent != null)
      out.setPretty(indent.equals("true"));
    out.setVersion((String) output.get(OutputKeys.VERSION));
    if (node instanceof CauchoNode) {
      String filename = ((CauchoNode) node).getFilename();
      out.setLineMap(filename != null ? filename : "anonymous.xsl");
    }
    else
      out.setLineMap("anonymous.xsl");
   
      String includeContentType = (String) output.get("include-content-type");
      if (includeContentType != null)
        out.setIncludeContentType(includeContentType.equals("true") ||
                                  includeContentType.equals("yes"));

    try {
      out.startDocument();
      _stylesheet.transform(node, out, this);
      out.endDocument();
      _lineMap = out.getLineMap();
      ws.close();

      return sw.getString();
    } catch (Exception e) {
      throw new IOExceptionWrapper(e);
View Full Code Here


        if (data != null) {
          data = data.getFirstChild();

          TempOutputStream os = new TempOutputStream();

          XmlPrinter printer = new XmlPrinter(os);

          printer.printXml(data);

          os.close();

          long length = os.getLength();
View Full Code Here

    }

    public void writeToStream(OutputStream os)
      throws IOException
    {
      XmlPrinter xmlPrinter = new XmlPrinter(os);
      xmlPrinter.setPretty(true);
      xmlPrinter.printXml(_data);
    }
View Full Code Here

  }

  private void saveToStream(DOMNode delegate, WriteStream os, boolean isHTML)
    throws IOException
  {
    XmlPrinter printer = new XmlPrinter(os);

    printer.setMethod(isHTML ? "html" : "xml");

    printer.setEncoding(_encoding);
    if(delegate._delegate instanceof Document)
    {
        /*
        Print the XML Declaration ( the <?xml thing ) only for Documents,
        as they don't make sense when just printing nodes.
         */
        printer.setPrintDeclaration(true);

        Document document = (Document) delegate._delegate;
        printer.setVersion(document.getXmlVersion());
        if (document.getXmlStandalone()){
            printer.setStandalone("yes");
        }
        printer.printXml(document);
    }
      else
    {
        printer.printXml((org.w3c.dom.Node) delegate._delegate);
    }

    if (hasChildNodes())
      os.println();
  }
View Full Code Here

    out.writeEndElement(); // definitions

    _wsdlBuffer = new CharArrayWriter();

    XmlPrinter printer = new XmlPrinter(_wsdlBuffer);
    printer.setPrintDeclaration(true);
    printer.setStandalone("true");
    printer.printPrettyXml(result.getNode());
   
    _wsdlGenerated = true;
  }
View Full Code Here

    writeSchema(out);

    _schemaBuffer = new CharArrayWriter();

    XmlPrinter printer = new XmlPrinter(_schemaBuffer);
    printer.setPrintDeclaration(true);
    printer.setStandalone("true");
    printer.printPrettyXml(result.getNode());
   
    _schemaGenerated = true;
  }
View Full Code Here

public class XmlPrinterEcmaWrap {
  public static XmlPrinter create(WriteStream os)
    throws IOException, SAXException
  {
    return new XmlPrinter(os);
  }
View Full Code Here

  }
 
  public static XmlPrinter create(OutputStream os)
    throws IOException, SAXException
  {
    return new XmlPrinter(os);
  }
View Full Code Here

    org.w3c.dom.Element xtpDocument = looseToStrictHtml(path);
   
    OutputStream fileOut = path.openWrite();

    XmlPrinter printer = new XmlPrinter(fileOut);

    printer.printXml(xtpDocument);

    fileOut.close();
  }
View Full Code Here

  }

  private void saveToStream(WriteStream os, boolean isHTML)
    throws IOException
  {
    XmlPrinter printer = new XmlPrinter(os);

    printer.setMethod(isHTML ? "html" : "xml");

    printer.setPrintDeclaration(true);

    printer.setVersion(_delegate.getXmlVersion());
    printer.setEncoding(_encoding);

    if (_delegate.getXmlStandalone())
      printer.setStandalone("yes");

    printer.printXml(_delegate);

    if (hasChildNodes())
      os.println();
  }
View Full Code Here

TOP

Related Classes of com.caucho.xml.XmlPrinter

Copyright © 2018 www.massapicom. 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.