Example usage for javax.xml.xpath XPathExpressionException printStackTrace

List of usage examples for javax.xml.xpath XPathExpressionException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.xpath XPathExpressionException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Print stack trace to System.err .

Usage

From source file:org.rippleosi.patient.contacts.search.SCCISContactSummaryTransformer.java

@Override
public List<ContactSummary> transform(Node xml) {

    XPathFactory xpf = XPathFactory.newInstance();
    XPath xpath = xpf.newXPath();

    List<ContactSummary> contactList = new ArrayList<ContactSummary>();

    try {/*  ww  w.j  a  v a 2  s . c om*/
        xml.normalize();
        // Retrieve contacts from Carers section of XML
        NodeList nodeSet = (NodeList) xpath.evaluate("/LCR/Carers/List/RelatedPerson", xml,
                XPathConstants.NODESET);

        for (int i = 0; i < nodeSet.getLength(); i++) {
            ContactSummary contact = new ContactSummary();
            contact.setSource("SC-CIS");

            Node node = nodeSet.item(i);
            String sourceId = (String) xpath.evaluate("identifier/value/@value", node, XPathConstants.STRING);
            String name = (String) xpath.evaluate("name/text/@value", node, XPathConstants.STRING);
            String relationshipTeam = (String) xpath.evaluate("relationship/coding/display/@value", node,
                    XPathConstants.STRING);

            contact.setSourceId(sourceId);
            contact.setName(name);
            contact.setRelationship(relationshipTeam);
            contactList.add(contact);
        }

        // Retrieve contacts from Allocations section of the XML
        nodeSet = (NodeList) xpath.evaluate("/LCR/Allocations/List/Practitioner", xml, XPathConstants.NODESET);

        for (int i = 0; i < nodeSet.getLength(); i++) {
            ContactSummary contact = new ContactSummary();
            contact.setSource("SC-CIS");

            Node node = nodeSet.item(i);
            String sourceId = (String) xpath.evaluate("identifier/value/@value", node, XPathConstants.STRING);
            String name = (String) xpath.evaluate("name/text/@value", node, XPathConstants.STRING);
            String relationshipTeam = (String) xpath.evaluate("practitionerRole/role/coding/display/@value",
                    node, XPathConstants.STRING);

            contact.setSourceId(sourceId);
            contact.setName(name);
            contact.setRelationship(relationshipTeam);

            contactList.add(contact);
        }

    } catch (XPathExpressionException e) {
        e.printStackTrace();
    }

    return contactList;
}

From source file:org.sakaiproject.mediasite.tool.MediasiteLTI.java

public static String getConfigValue(Document doc, XPath xpath, String id, String name) {
    String value = null;//from   w w  w .ja v a 2  s .  c  o m
    try {
        XPathExpression expr = xpath
                .compile("/registration/tool[@id='" + id + "']/configuration[@name='" + name + "']/@value");
        value = (String) expr.evaluate(doc, XPathConstants.STRING);
    } catch (XPathExpressionException e) {
        e.printStackTrace();
    }

    return value;
}

From source file:org.xwiki.validator.framework.AbstractDOMValidator.java

/**
 * Evaluate a XPATH string against a node.
 * /* www.j  a v  a2 s  .  com*/
 * @param node node to evaluate
 * @param exprString evaluation expression
 * @param returnType type of the results to return
 * @return the result of the xpath evaluation
 */
public Object evaluate(Node node, String exprString, QName returnType) {
    try {
        XPathExpression expr = xpath.compile(exprString);
        return expr.evaluate(this.document, returnType);
    } catch (XPathExpressionException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:tufts.vue.ds.XMLIngest.java

static void XPathExtract(XmlSchema schema, Document document) {

    try {// ww  w  . j  a v a 2 s. c o m

        XPath xpath = XPathFactory.newInstance().newXPath();

        String expression = "/rss/channel/item";
        //String expression = "rss/channel/item/title";

        errout("Extracting " + expression);

        // First, obtain the element as a node.

        //tufts.DocDump.dump(document);

        Node nodeValue = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
        errout("   Node: " + nodeValue);

        // Next, obtain the element as a String.

        String stringValue = (String) xpath.evaluate(expression, document, XPathConstants.STRING);
        System.out.println(" String: " + stringValue);

        NodeList nodeSet = (NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
        errout("NodeSet: " + Util.tag(nodeSet) + "; size=" + nodeSet.getLength());

        for (int i = 0; i < nodeSet.getLength(); i++) {
            scanNode(schema, nodeSet.item(i), null, null);
        }

        //             // Finally, obtain the element as a Number (Double).

        //             Double birthdateDouble = (Double) xpath.evaluate(expression, document, XPathConstants.NUMBER);

        //             System.out.println("Double is: " + birthdateDouble);

    } catch (XPathExpressionException e) {
        System.err.println("XPathExpressionException caught...");
        e.printStackTrace();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}