List of usage examples for javax.xml.xpath XPathConstants STRING
QName STRING
To view the source code for javax.xml.xpath XPathConstants STRING.
Click Source Link
The XPath 1.0 string data type.
Maps to Java String .
From source file:nz.govt.natlib.ndha.wctdpsdepositor.extractor.XPathWctMetsExtractor.java
private void populateCreationDate(Document doc, XPath xpath) throws XPathExpressionException { creationDate = (String) xpath.evaluate(creationDateQuery, doc, XPathConstants.STRING); }
From source file:nz.govt.natlib.ndha.wctdpsdepositor.extractor.XPathWctMetsExtractor.java
private void populateProvenanceNote(Document doc, XPath xpath) throws XPathExpressionException { provenanceNote = (String) xpath.evaluate(provenanceNoteQuery, doc, XPathConstants.STRING); }
From source file:nz.govt.natlib.ndha.wctdpsdepositor.extractor.XPathWctMetsExtractor.java
private void populateCopyrightStatement(Document doc, XPath xpath) throws XPathExpressionException { copyrightStatement = (String) xpath.evaluate(copyrightStatementQuery, doc, XPathConstants.STRING); }
From source file:nz.govt.natlib.ndha.wctdpsdepositor.extractor.XPathWctMetsExtractor.java
private void populateCopyrightURL(Document doc, XPath xpath) throws XPathExpressionException { copyrightURL = (String) xpath.evaluate(copyrightURLQuery, doc, XPathConstants.STRING); }
From source file:nz.govt.natlib.ndha.wctdpsdepositor.extractor.XPathWctMetsExtractor.java
private void populateAccessRestrictions(Document doc, XPath xpath) throws XPathExpressionException { accessRestriction = (String) xpath.evaluate(accessRestrictionQuery, doc, XPathConstants.STRING); }
From source file:nz.govt.natlib.ndha.wctdpsdepositor.extractor.XPathWctMetsExtractor.java
private ArchiveFile populateFileValueObjectFrom(XPath xpath, Node metsFileNode, FileArchiveBuilder fileBuilder) throws XPathExpressionException { String mimeType = (String) xpath.evaluate("@MIMETYPE", metsFileNode, XPathConstants.STRING); String checkSum = (String) xpath.evaluate("@CHECKSUM", metsFileNode, XPathConstants.STRING); String fileLocation = (String) xpath.evaluate("mets:FLocat/@xlink:href", metsFileNode, XPathConstants.STRING); String fileName = getFileName(fileLocation); return fileBuilder.createFileFrom(mimeType, checkSum, fileName); }
From source file:org.ala.documentmapper.XMLDocumentMapper.java
/** * Uses the supplied xpath to retrieve values * /* w w w . j ava 2s. c o m*/ * @param document * @param xpathAsString * @return * @throws Exception */ protected String getXPathSingleValue(Document document, String xpathAsString) throws Exception { XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); NodeList nodes = null; try { nodes = (NodeList) xpath.evaluate(xpathAsString, document, XPathConstants.NODESET); for (int i = 0; i < nodes.getLength(); i++) { String value = extractValue(nodes.item(i)); value = StringUtils.trimToNull(value); if (value != null) { return value; } } } catch (XPathException e) { String value = (String) xpath.evaluate(xpathAsString, document, XPathConstants.STRING); return value; } return null; }
From source file:org.alfresco.po.share.dashlet.AbstractDashlet.java
/** * Parses the xml string of the original-title attribute element to get tooltip * data for report dashlets/*w ww. j av a2s . co m*/ * * @param xml String * @param element String * @return String */ protected String getElement(String xml, String element) throws Exception { String tooltipElement = " "; xml = xml.replaceAll("alt=\"avatar\">", "alt=\"avatar\"/>"); xml = xml.replaceAll("<br>", ""); XPathFactory xpathFactory = XPathFactory.newInstance(); XPath xpath = xpathFactory.newXPath(); InputSource source = new InputSource(new StringReader(xml)); try { tooltipElement = (String) xpath.evaluate(element, source, XPathConstants.STRING); } catch (XPathExpressionException ee) { logger.error("Cannot parse xml string " + ee); } return tooltipElement; }
From source file:org.alfresco.repo.content.metadata.xml.XPathMetadataExtracter.java
private Serializable getStringValue(Document document, XPathExpression xpathExpression) throws XPathExpressionException { String value = (String) xpathExpression.evaluate(document, XPathConstants.STRING); // Done//w ww. j a v a2 s . co m return value; }
From source file:org.apache.camel.builder.xml.XPathBuilder.java
/** * Evaluates the given xpath using the provided body as a String return type. * * @param context the camel context//from w w w . j a v a 2 s . co m * @param body the body * @return result of the evaluation */ public String evaluate(CamelContext context, Object body) { ObjectHelper.notNull(context, "CamelContext"); // create a dummy Exchange to use during evaluation Exchange dummy = new DefaultExchange(context); dummy.getIn().setBody(body); setResultQName(XPathConstants.STRING); String answer = evaluate(dummy, String.class); // remove the dummy from the thread local after usage exchange.remove(); return answer; }