Package javax.xml.transform.dom

Examples of javax.xml.transform.dom.DOMResult


                return ((Document) node).getDocumentElement();
            }
        }
        // we have no other option than to transform
        Document requestDocument = documentBuilder.newDocument();
        DOMResult domResult = new DOMResult(requestDocument);
        transform(source, domResult);
        return requestDocument.getDocumentElement();
    }
View Full Code Here


         TransformerFactory transFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl",null);
         Transformer transformer = transFactory.newTransformer();

         for (Source s : standard) {
            DOMResult result = new DOMResult();
            transformer.transform (s, result);
            ret.add (new DOMSource (result.getNode()));
         }

         return ret;
      }catch (TransformerConfigurationException tce) {
         // TODO: Should we log the exception here?
View Full Code Here

        return new DOMSource(toDOMNodeFromStAX(source));
    }

    @Converter
    public Node toDOMNodeFromSAX(SAXSource source) throws ParserConfigurationException, IOException, SAXException, TransformerException {
        DOMResult result = new DOMResult();
        toResult(source, result);
        return result.getNode();
    }
View Full Code Here

        return result.getNode();
    }

    @Converter
    public Node toDOMNodeFromStAX(StAXSource source) throws ParserConfigurationException, IOException, SAXException, TransformerException {
        DOMResult result = new DOMResult();
        toResult(source, result);
        return result.getNode();
    }
View Full Code Here

  private String xpathPrefix = "/p:GetCityWeatherByZIPResponse/p:GetCityWeatherByZIPResult/";

  public Object unmarshal(Source source) throws IOException, XmlMappingException {

    //this.writeXml(((DOMSource)source).getNode().getOwnerDocument());
    DOMResult result = null;
    try {
      Transformer transformer = transformerFactory.newTransformer();
      result = new DOMResult();
      transformer.transform(source, result);
    } catch (Exception e) {
      throw new MarshallingFailureException("Failed to unmarshal SOAP Response", e);
    }
    Weather weather = new Weather();
    String expression = xpathPrefix + "p:City";
    String city = XPathExpressionFactory.createXPathExpression(expression, namespacePrefixes).evaluateAsString(result.getNode());
    weather.setCity(city);
    expression = xpathPrefix + "p:State";
    String state = XPathExpressionFactory.createXPathExpression(expression, namespacePrefixes).evaluateAsString(result.getNode());
    weather.setState(state);
    expression = xpathPrefix + "p:Temperature";
    String temperature = XPathExpressionFactory.createXPathExpression(expression, namespacePrefixes).evaluateAsString(result.getNode());
    weather.setTemperature(temperature);
    expression = xpathPrefix + "p:Description";
    String description = XPathExpressionFactory.createXPathExpression(expression, namespacePrefixes).evaluateAsString(result.getNode());
    weather.setDescription(description);
    return weather;
  }
View Full Code Here

        }
    }

    private void read(InputStream in) throws IOException {
        StreamSource source = new StreamSource(in);
        DOMResult result = new DOMResult(doc);
        Transformer xform = createTransformer();
        try {
            xform.transform(source, result);
        }
        catch (TransformerException e) {
View Full Code Here

   * @return the parsed Element
   */
  public static final Element fromString(final String element) {
    try {
      final Document doc = newDocument();
      transformer.transform(new StreamSource(new StringReader(element)), new DOMResult(doc));
      return doc.getDocumentElement();
    } catch (final TransformerException e) {
      throw new InternalError("Transformer error");
    }
  }
View Full Code Here

  }
 
  private void resetWriter() {
    try {
      document = XMLUtil.newDocument();
      result = new DOMResult(document);
      writer = xmlOutputFactory.createXMLEventWriter(result);
    } catch (XMLStreamException e) {
      throw new InternalError("Error creating writer");
    }
   
View Full Code Here

    this.xsltCacheLifetimeSeconds = xsltCacheLifetimeSeconds;
  }

  @Override
  public void load(SolrQueryRequest req, SolrQueryResponse rsp, ContentStream stream) throws Exception {
    final DOMResult result = new DOMResult();
    final Transformer t = getTransformer(req);
    InputStream is = null;
    XMLStreamReader parser = null;
    // first step: read XML and build DOM using Transformer (this is no overhead, as XSL always produces
    // an internal result DOM tree, we just access it directly as input for StAX):
    try {
      is = stream.getStream();
      final String charset = ContentStreamBase.getCharsetFromContentType(stream.getContentType());
      final InputSource isrc = new InputSource(is);
      isrc.setEncoding(charset);
      final SAXSource source = new SAXSource(isrc);
      t.transform(source, result);
    } catch(TransformerException te) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, te.getMessage(), te);
    } finally {
      IOUtils.closeQuietly(is);
    }
    // second step feed the intermediate DOM tree into StAX parser:
    try {
      parser = inputFactory.createXMLStreamReader(new DOMSource(result.getNode()));
      this.processUpdate(processor, parser);
    } catch (XMLStreamException e) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e.getMessage(), e);
    } finally {
      if (parser != null) parser.close();
View Full Code Here

      // we can write directly to the Result
      t.transform(source, result);
  else if (var != null) {
      // we need a Document
      Document d = db.newDocument();
      Result doc = new DOMResult(d);
      t.transform(source, doc);
      pageContext.setAttribute(var, d, scope);
  } else {
      Result page =
    new StreamResult(new SafeWriter(pageContext.getOut()));
View Full Code Here

TOP

Related Classes of javax.xml.transform.dom.DOMResult

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.