/** {@inheritDoc} */ @Override public void render(DriverRequest httpRequest, String src, Writer out) throws IOException { try { HtmlDocumentBuilder htmlDocumentBuilder = new HtmlDocumentBuilder(); htmlDocumentBuilder.setDoctypeExpectation(DoctypeExpectation.NO_DOCTYPE_ERRORS); Document document = htmlDocumentBuilder.parse(new InputSource(new StringReader(src))); Source source = new DOMSource(document); DOMResult result = new DOMResult(); transformer.transform(source, result); XhtmlSerializer serializer = new XhtmlSerializer(out); Dom2Sax dom2Sax = new Dom2Sax(serializer, serializer); dom2Sax.parse(result.getNode()); } catch (TransformerException e) { throw new ProcessingFailedException("Failed to transform source", e); } catch (SAXException e) { throw new ProcessingFailedException("Failed serialize transformation result", e); } } }
emptyIfNull(current.getNamespaceURI()), localName == null ? current.getNodeName() : localName, null, attributes); emptyIfNull(current.getNamespaceURI()), localName == null ? current.getNodeName() : localName, null);
emptyIfNull(current.getNamespaceURI()), localName == null ? current.getNodeName() : localName, null, attributes); emptyIfNull(current.getNamespaceURI()), localName == null ? current.getNodeName() : localName, null);
emptyIfNull(current.getNamespaceURI()), localName == null ? current.getNodeName() : localName, null, attributes); emptyIfNull(current.getNamespaceURI()), localName == null ? current.getNodeName() : localName, null);
/** {@inheritDoc} */ @Override public void render(DriverRequest httpRequest, String src, Writer out) throws IOException { try { HtmlDocumentBuilder htmlDocumentBuilder = new HtmlDocumentBuilder(); htmlDocumentBuilder.setDoctypeExpectation(DoctypeExpectation.NO_DOCTYPE_ERRORS); Document document = htmlDocumentBuilder.parse(new InputSource(new StringReader(src))); NodeList matchingNodes = (NodeList) expr.evaluate(document, XPathConstants.NODESET); XhtmlSerializer serializer = new XhtmlSerializer(out); Dom2Sax dom2Sax = new Dom2Sax(serializer, serializer); for (int i = 0; i < matchingNodes.getLength(); i++) { dom2Sax.parse(matchingNodes.item(i)); } } catch (XPathExpressionException e) { throw new ProcessingFailedException("Failed to evaluate XPath expression", e); } catch (SAXException e) { throw new ProcessingFailedException("Unable to parse source", e); } } }