Examples of DOMSerializer


Examples of org.exist.util.serializer.DOMSerializer

      Document doc = receiver.getDocument();
      Node node = doc.getFirstChild();
      assertNotNull(node);
 
      StringWriter writer = new StringWriter();
      DOMSerializer serializer = new DOMSerializer(writer, null);
      serializer.serialize(node);
      System.out.println(writer.toString());
      } catch (Exception e) {
        fail(e.getMessage());
      }     
  }
View Full Code Here

Examples of org.exist.util.serializer.DOMSerializer

        Node node = resource.getContentAsDOM();
        System.out.println("Attempting serialization using eXist's serializer");
        StringWriter writer = new StringWriter();
        Properties outputProperties = new Properties();
        outputProperties.setProperty("indent", "yes");
        DOMSerializer serializer = new DOMSerializer(writer, outputProperties);
        serializer.serialize(node);

        System.out.println("Using org.exist.util.serializer.DOMSerializer");
        System.out.println("---------------------");
        System.out.println(writer.toString());
        System.out.println("---------------------");
View Full Code Here

Examples of org.exist.util.serializer.DOMSerializer

            }
        }
        if (root == null)
            throw new EXistException("no content element found for " + config.getNodeName());
        StringWriter writer = new StringWriter();
        DOMSerializer serializer = new DOMSerializer(writer, new Properties());
        try {
            serializer.serialize(root);
        } catch (TransformerException e) {
            throw new EXistException("exception while serializing content: " + e.getMessage(), e);
        }
        return writer.toString();
    }
View Full Code Here

Examples of org.exist.util.serializer.DOMSerializer

            }
        }
        if (root == null)
            throw new EXistException("no content element found for generate");
        StringWriter writer = new StringWriter();
        DOMSerializer serializer = new DOMSerializer(writer, new Properties());
        try {
            serializer.serialize(root);
        } catch (TransformerException e) {
            throw new EXistException("exception while serializing generate content: " + e.getMessage(), e);
        }
        xqueryContent = writer.toString();
    }
View Full Code Here

Examples of org.exist.util.serializer.DOMSerializer

        throws XPathException {
    final NodeValue data = (NodeValue) args[1].itemAt(0);
    final StringWriter writer = new StringWriter();
    final Properties properties = new Properties();
    properties.setProperty(OutputKeys.INDENT, "yes");
        final DOMSerializer serializer = new ExtendedDOMSerializer(context.getBroker(), writer, properties);
    try {
      serializer.serialize(data.getNode());
    } catch(final TransformerException e) {
      logger.debug("Exception while serializing XUpdate document", e);
      throw new XPathException(this, "Exception while serializing XUpdate document: " + e.getMessage(), e);
    }
    final String xupdate = writer.toString();
View Full Code Here

Examples of org.exist.util.serializer.DOMSerializer

        if (useAttribute != null) {
            request.setAttribute(useAttribute.toString(), root);

        } else {
            final Writer writer = new OutputStreamWriter(response.getOutputStream(), "UTF-8");
            final DOMSerializer streamer = new DOMSerializer(writer, defaultProperties);
            try {
                streamer.serialize(root);
            } catch (final TransformerException e) {
                LOG.error(e.getMessageAndLocation());
                throw new ServletException("Error while serializing result: " + e.getMessage(), e);
            }
            writer.flush();
View Full Code Here

Examples of org.exist.util.serializer.DOMSerializer

     * "instances", "disk", "system", "caches", "locking", "processes", "sanity", "all".
     */
    public String generateReport(String categories[]) throws TransformerException {
        final Element root = generateXMLReport(null, categories);
        final StringWriter writer = new StringWriter();
        final DOMSerializer streamer = new DOMSerializer(writer, defaultProperties);
        streamer.serialize(root);
        return writer.toString();
    }
View Full Code Here

Examples of org.exist.util.serializer.DOMSerializer

        }

    // Case 1: content is an external DOM node
    else if (root != null && !(root instanceof NodeValue)) {
            final StringWriter writer = new StringWriter();
      final DOMSerializer serializer = new DOMSerializer(writer, getProperties());
      try {
        serializer.serialize(root);
        content = writer.toString();
      } catch (final TransformerException e) {
        throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, e
            .getMessage(), e);
      }
      return content;

      // Case 2: content is an atomic value
    } else if (value != null) {
      try {
                if (Type.subTypeOf(value.getType(),Type.STRING)) {
                    return ((StringValue)value).getStringValue(true);
                }
                else {
        return value.getStringValue();
                }



      } catch (final XPathException e) {
        throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, e
            .getMessage(), e);
      }

      // Case 3: content is a file
    } else if (file != null) {
      try {
        content = XMLUtil.readFile(file);
        return content;
      } catch (final IOException e) {
        throw new XMLDBException(ErrorCodes.VENDOR_ERROR,
            "error while reading resource contents", e);
      }

      // Case 4: content is an input source
    } else if (inputSource != null) {
      try {
        content = XMLUtil.readFile(inputSource);
        return content;
      } catch (final IOException e) {
        throw new XMLDBException(ErrorCodes.VENDOR_ERROR,
            "error while reading resource contents", e);
      }

      // Case 5: content is a document or internal node
    } else {
        DocumentImpl document = null;
      final Subject preserveSubject = pool.getSubject();
      DBBroker broker = null;
      try {
        broker = pool.get(user);
        final Serializer serializer = broker.getSerializer();
        serializer.setUser(user);
        serializer.setProperties(getProperties());
        if (root != null) {
          content = serializer.serialize((NodeValue) root);
                   
                } else if (proxy != null) {
                    content = serializer.serialize(proxy);
                   
                } else {
            document = openDocument(broker, Lock.READ_LOCK);
          if (!document.getPermissions().validate(user,
              Permission.READ))
            {throw new XMLDBException(ErrorCodes.PERMISSION_DENIED,
                "permission denied to read resource");}
          content = serializer.serialize(document);
                }
        return content;
      } catch (final SAXException saxe) {
        saxe.printStackTrace();
        throw new XMLDBException(ErrorCodes.VENDOR_ERROR, saxe
View Full Code Here

Examples of org.exist.util.serializer.DOMSerializer

    private static Logger LOG = Logger.getLogger(XMLUtil.class.getName());

    public final static String dump(DocumentFragment fragment) {
        final StringWriter writer = new StringWriter();
        final DOMSerializer serializer = new DOMSerializer();
        serializer.setWriter(writer);
        try {
            serializer.serialize(fragment);
        } catch (final TransformerException e) {
            //Nothing to do ?
        }
        return writer.toString();
    }
View Full Code Here

Examples of org.htmlcleaner.DomSerializer

    @Override
    public String select(String text) {
        try {
            HtmlCleaner htmlCleaner = new HtmlCleaner();
            TagNode tagNode = htmlCleaner.clean(text);
            Document document = new DomSerializer(new CleanerProperties()).createDOM(tagNode);
            Object result;
            try {
                result = xPathExpression.evaluate(document, XPathConstants.NODESET);
            } catch (XPathExpressionException e) {
                result = xPathExpression.evaluate(document, XPathConstants.STRING);
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.