void receiveElement(Element ruleElement) { Element nameElement = getChildByName(ruleElement, RequestConstants.RESTAPI_NS, "name"); this.setName(nameElement.getTextContent()); Element descElement = getChildByName(ruleElement, RequestConstants.RESTAPI_NS, "description"); this.setDescription(descElement.getTextContent()); Element searchElement = getChildByName(ruleElement, RequestConstants.SEARCH_NS, "search"); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); TransformerFactory transfac = TransformerFactory.newInstance(); Transformer trans = transfac.newTransformer(); trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); trans.setOutputProperty(OutputKeys.VERSION, "1.0"); trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); trans.setOutputProperty(OutputKeys.INDENT, "no"); trans.transform(new DOMSource(searchElement), new StreamResult(baos)); importQueryDefinition(new BytesHandle(baos.toByteArray()) .withFormat(Format.XML)); } catch (TransformerConfigurationException e) { throw new MarkLogicIOException( "Could not get query from rule payload"); } catch (TransformerException e) { throw new MarkLogicIOException( "Could not get query from rule payload"); } receiveRuleMetadataImpl(ruleElement); }
void receiveElement(Element ruleElement) { Element nameElement = getChildByName(ruleElement, RequestConstants.RESTAPI_NS, "name"); this.setName(nameElement.getTextContent()); Element descElement = getChildByName(ruleElement, RequestConstants.RESTAPI_NS, "description"); this.setDescription(descElement.getTextContent()); Element searchElement = getChildByName(ruleElement, RequestConstants.SEARCH_NS, "search"); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); TransformerFactory transfac = TransformerFactory.newInstance(); Transformer trans = transfac.newTransformer(); trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); trans.setOutputProperty(OutputKeys.VERSION, "1.0"); trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); trans.setOutputProperty(OutputKeys.INDENT, "no"); trans.transform(new DOMSource(searchElement), new StreamResult(baos)); importQueryDefinition(new BytesHandle(baos.toByteArray()) .withFormat(Format.XML)); } catch (TransformerConfigurationException e) { throw new MarkLogicIOException( "Could not get query from rule payload"); } catch (TransformerException e) { throw new MarkLogicIOException( "Could not get query from rule payload"); } receiveRuleMetadataImpl(ruleElement); }