Java Code Examples for javax.xml.xpath.XPathExpressionException#printStackTrace()
The following examples show how to use
javax.xml.xpath.XPathExpressionException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestFinder.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static Set<String> getExcludeSet() throws XPathExpressionException { final String testExcludeList = System.getProperty(TEST_JS_EXCLUDE_LIST); String[] testExcludeArray = {}; if (testExcludeList != null) { testExcludeArray = testExcludeList.split(" "); } final Set<String> testExcludeSet = new HashSet<>(testExcludeArray.length); for (final String test : testExcludeArray) { testExcludeSet.add(test); } final String testExcludesFile = System.getProperty(TEST_JS_EXCLUDES_FILE); if (testExcludesFile != null && !testExcludesFile.isEmpty()) { try { loadExcludesFile(testExcludesFile, testExcludeSet); } catch (final XPathExpressionException e) { System.err.println("Error: unable to load test excludes from " + testExcludesFile); e.printStackTrace(); throw e; } } return testExcludeSet; }
Example 2
Source File: TestFinder.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static Set<String> getExcludeSet() throws XPathExpressionException { final String testExcludeList = System.getProperty(TEST_JS_EXCLUDE_LIST); String[] testExcludeArray = {}; if (testExcludeList != null) { testExcludeArray = testExcludeList.split(" "); } final Set<String> testExcludeSet = new HashSet<>(testExcludeArray.length); for (final String test : testExcludeArray) { testExcludeSet.add(test); } final String testExcludesFile = System.getProperty(TEST_JS_EXCLUDES_FILE); if (testExcludesFile != null && !testExcludesFile.isEmpty()) { try { loadExcludesFile(testExcludesFile, testExcludeSet); } catch (final XPathExpressionException e) { System.err.println("Error: unable to load test excludes from " + testExcludesFile); e.printStackTrace(); throw e; } } return testExcludeSet; }
Example 3
Source File: AndroidManifestPlainTextReader.java From android-classyshark with Apache License 2.0 | 6 votes |
public Map<String, String> getActionsWithReceivers() { Map<String, String> list = new TreeMap<>(); try { XPathFactory xpathFactory = XPathFactory.newInstance(); XPath xpath = xpathFactory.newXPath(); XPathExpression expr = xpath.compile("/manifest/application/receiver/intent-filter/action"); NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); for (int i = 0; i < nodes.getLength(); i++) { Node currentNode = nodes.item(i); Node actionNameAttribute = currentNode.getAttributes().getNamedItem("name"); String receiverName = currentNode.getParentNode().getParentNode().getAttributes().getNamedItem("name").getTextContent(); list.put(actionNameAttribute.getTextContent(), receiverName); } } catch (XPathExpressionException e) { e.printStackTrace(); } return list; }
Example 4
Source File: AndroidManifestPlainTextReader.java From android-classyshark with Apache License 2.0 | 6 votes |
public List<String> getServices() { List<String> list = new ArrayList<>(); try { XPathFactory xpathFactory = XPathFactory.newInstance(); XPath xpath = xpathFactory.newXPath(); XPathExpression expr = xpath.compile("/manifest/application/service"); NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); for (int i = 0; i < nodes.getLength(); i++) { Node serviceNode = nodes.item(i); Node actionName = serviceNode.getAttributes().getNamedItem("name"); list.add(actionName.getTextContent()); } } catch (XPathExpressionException e) { e.printStackTrace(); } return list; }
Example 5
Source File: TestFinder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private static Set<String> getExcludeSet() throws XPathExpressionException { final String testExcludeList = System.getProperty(TEST_JS_EXCLUDE_LIST); String[] testExcludeArray = {}; if (testExcludeList != null) { testExcludeArray = testExcludeList.split(" "); } final Set<String> testExcludeSet = new HashSet<>(testExcludeArray.length); for (final String test : testExcludeArray) { testExcludeSet.add(test); } final String testExcludesFile = System.getProperty(TEST_JS_EXCLUDES_FILE); if (testExcludesFile != null && !testExcludesFile.isEmpty()) { try { loadExcludesFile(testExcludesFile, testExcludeSet); } catch (final XPathExpressionException e) { System.err.println("Error: unable to load test excludes from " + testExcludesFile); e.printStackTrace(); throw e; } } return testExcludeSet; }
Example 6
Source File: TestFinder.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static Set<String> getExcludeSet() throws XPathExpressionException { final String testExcludeList = System.getProperty(TEST_JS_EXCLUDE_LIST); String[] testExcludeArray = {}; if (testExcludeList != null) { testExcludeArray = testExcludeList.split(" "); } final Set<String> testExcludeSet = new HashSet<>(testExcludeArray.length); for (final String test : testExcludeArray) { testExcludeSet.add(test); } final String testExcludesFile = System.getProperty(TEST_JS_EXCLUDES_FILE); if (testExcludesFile != null && !testExcludesFile.isEmpty()) { try { loadExcludesFile(testExcludesFile, testExcludeSet); } catch (final XPathExpressionException e) { System.err.println("Error: unable to load test excludes from " + testExcludesFile); e.printStackTrace(); throw e; } } return testExcludeSet; }
Example 7
Source File: TestFinder.java From hottub with GNU General Public License v2.0 | 6 votes |
private static Set<String> getExcludeSet() throws XPathExpressionException { final String testExcludeList = System.getProperty(TEST_JS_EXCLUDE_LIST); String[] testExcludeArray = {}; if (testExcludeList != null) { testExcludeArray = testExcludeList.split(" "); } final Set<String> testExcludeSet = new HashSet<>(testExcludeArray.length); for (final String test : testExcludeArray) { testExcludeSet.add(test); } final String testExcludesFile = System.getProperty(TEST_JS_EXCLUDES_FILE); if (testExcludesFile != null && !testExcludesFile.isEmpty()) { try { loadExcludesFile(testExcludesFile, testExcludeSet); } catch (final XPathExpressionException e) { System.err.println("Error: unable to load test excludes from " + testExcludesFile); e.printStackTrace(); throw e; } } return testExcludeSet; }
Example 8
Source File: TestFinder.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static Set<String> getExcludeSet() throws XPathExpressionException { final String testExcludeList = System.getProperty(TEST_JS_EXCLUDE_LIST); String[] testExcludeArray = {}; if (testExcludeList != null) { testExcludeArray = testExcludeList.split(" "); } final Set<String> testExcludeSet = new HashSet<>(testExcludeArray.length); for (final String test : testExcludeArray) { testExcludeSet.add(test); } final String testExcludesFile = System.getProperty(TEST_JS_EXCLUDES_FILE); if (testExcludesFile != null && !testExcludesFile.isEmpty()) { try { loadExcludesFile(testExcludesFile, testExcludeSet); } catch (final XPathExpressionException e) { System.err.println("Error: unable to load test excludes from " + testExcludesFile); e.printStackTrace(); throw e; } } return testExcludeSet; }
Example 9
Source File: TestFinder.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static Set<String> getExcludeSet() throws XPathExpressionException { final String testExcludeList = System.getProperty(TEST_JS_EXCLUDE_LIST); String[] testExcludeArray = {}; if (testExcludeList != null) { testExcludeArray = testExcludeList.split(" "); } final Set<String> testExcludeSet = new HashSet<>(testExcludeArray.length); for (final String test : testExcludeArray) { testExcludeSet.add(test); } final String testExcludesFile = System.getProperty(TEST_JS_EXCLUDES_FILE); if (testExcludesFile != null && !testExcludesFile.isEmpty()) { try { loadExcludesFile(testExcludesFile, testExcludeSet); } catch (final XPathExpressionException e) { System.err.println("Error: unable to load test excludes from " + testExcludesFile); e.printStackTrace(); throw e; } } return testExcludeSet; }
Example 10
Source File: XMLHelpers.java From SAMLRaider with MIT License | 6 votes |
/** * Set the ID Attribute in an XML Document so that java recognises the ID * Attribute as a real id * * @param document * Document to set the ids */ public void setIDAttribute(Document document) { try { if(Thread.currentThread().getContextClassLoader() == null){ Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); } XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expr = xpath.compile("//*[@ID]"); NodeList nodeList = (NodeList) expr.evaluate(document, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { Element elem = (Element) nodeList.item(i); Attr attr = (Attr) elem.getAttributes().getNamedItem("ID"); elem.setIdAttributeNode(attr, true); } } catch (XPathExpressionException e) { e.printStackTrace(); } }
Example 11
Source File: TestFinder.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
private static Set<String> getExcludeSet() throws XPathExpressionException { final String testExcludeList = System.getProperty(TEST_JS_EXCLUDE_LIST); String[] testExcludeArray = {}; if (testExcludeList != null) { testExcludeArray = testExcludeList.split(" "); } final Set<String> testExcludeSet = new HashSet<>(testExcludeArray.length); for (final String test : testExcludeArray) { testExcludeSet.add(test); } final String testExcludesFile = System.getProperty(TEST_JS_EXCLUDES_FILE); if (testExcludesFile != null && !testExcludesFile.isEmpty()) { try { loadExcludesFile(testExcludesFile, testExcludeSet); } catch (final XPathExpressionException e) { System.err.println("Error: unable to load test excludes from " + testExcludesFile); e.printStackTrace(); throw e; } } return testExcludeSet; }
Example 12
Source File: XMLHelpers.java From SAMLRaider with MIT License | 6 votes |
/** * Returns SOAP Body as an Element * * @param document * document with SOAP body * @return Element SOAP Body Element or null if no body found */ public Element getSOAPBody(Document document) { try { if(Thread.currentThread().getContextClassLoader() == null){ Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); } XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expr = xpath.compile("//*[local-name()='Envelope']/*[local-name()='Body']"); NodeList elements = (NodeList) expr.evaluate(document, XPathConstants.NODESET); if(elements.getLength()>0){ return (Element) elements.item(0); } } catch (XPathExpressionException e) { e.printStackTrace(); } return null; }
Example 13
Source File: XMLHelpers.java From SAMLRaider with MIT License | 6 votes |
/** * Removes empty tags, spaces between XML tags * * @param document * document in which the empty tags should be removed */ public void removeEmptyTags(Document document) { NodeList nl = null; try { if(Thread.currentThread().getContextClassLoader() == null){ Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); } XPath xPath = XPathFactory.newInstance().newXPath(); nl = (NodeList) xPath.evaluate("//text()[normalize-space(.)='']", document, XPathConstants.NODESET); for (int i = 0; i < nl.getLength(); ++i) { Node node = nl.item(i); node.getParentNode().removeChild(node); } } catch (XPathExpressionException e) { e.printStackTrace(); } }
Example 14
Source File: XMLHelpers.java From SAMLRaider with MIT License | 6 votes |
/** * Removes a signature in a given XML document * * @param document * document in which the signature should be removed * @return number of removed signatures */ public int removeOnlyMessageSignature(Document document) { try { if(Thread.currentThread().getContextClassLoader() == null){ Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); } setIDAttribute(document); XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expr = xpath.compile("//*[local-name()='Response']/*[local-name()='Signature']"); NodeList nl = (NodeList) expr.evaluate(document, XPathConstants.NODESET); int nrSig = nl.getLength(); for (int i = 0; i < nrSig; i++) { Node parent = nl.item(0).getParentNode(); parent.removeChild(nl.item(0)); } removeEmptyTags(document); document.normalize(); return nrSig; } catch (XPathExpressionException e) { e.printStackTrace(); } return 0; }
Example 15
Source File: XMLHelpers.java From SAMLRaider with MIT License | 5 votes |
/** * Sign whole SAML Message * * @param document * Document with the response to sign * @param signAlgorithm * Signature algorithm in uri form, default if an unknown * algorithm is provided: * http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 * @param digestAlgorithm * Digest algorithm in uri form, default if an unknown algorithm * is provided: http://www.w3.org/2001/04/xmlenc#sha256 */ public void signMessage(Document document, String signAlgorithm, String digestAlgorithm, X509Certificate cert, PrivateKey key) throws CertificateException, FileNotFoundException, NoSuchAlgorithmException, InvalidKeySpecException, MarshalException, XMLSignatureException, IOException { try { if(Thread.currentThread().getContextClassLoader() == null){ Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); } setIDAttribute(document); XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expr = xpath.compile("//*[local-name()='Response']/@ID"); NodeList nlURIs = (NodeList) expr.evaluate(document, XPathConstants.NODESET); String[] sigIDs = new String[nlURIs.getLength()]; for (int i = 0; i < nlURIs.getLength(); i++) { sigIDs[i] = nlURIs.item(i).getNodeValue(); } Init.init(); for (String id : sigIDs) { signElement(document, id, cert, key, signAlgorithm, digestAlgorithm); } } catch (XPathExpressionException e) { e.printStackTrace(); } }
Example 16
Source File: XMLHelpers.java From SAMLRaider with MIT License | 5 votes |
/** * Sign assertions in SAML message * * @param document * Document in assertions should be signed * @param signAlgorithm * Signature algorithm in uri form, default if an unknown * algorithm is provided: * http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 * @param digestAlgorithm * Digest algorithm in uri form, default if an unknown algorithm * is provided: http://www.w3.org/2001/04/xmlenc#sha256 */ public void signAssertion(Document document, String signAlgorithm, String digestAlgorithm, X509Certificate cert, PrivateKey key) throws CertificateException, FileNotFoundException, NoSuchAlgorithmException, InvalidKeySpecException, MarshalException, XMLSignatureException, IOException { try { if(Thread.currentThread().getContextClassLoader() == null){ Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); } setIDAttribute(document); XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expr = xpath.compile("//*[local-name()='Assertion']/@ID"); NodeList nlURIs = (NodeList) expr.evaluate(document, XPathConstants.NODESET); String[] sigIDs = new String[nlURIs.getLength()]; for (int i = 0; i < nlURIs.getLength(); i++) { sigIDs[i] = nlURIs.item(i).getNodeValue(); } Init.init(); for (String id : sigIDs) { signElement(document, id, cert, key, signAlgorithm, digestAlgorithm); } } catch (XPathExpressionException e) { e.printStackTrace(); } }
Example 17
Source File: XmlFileReader.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public FileReader replacePropertyValuesWith( String propertyName, String replacedValue ) { XPath xPath = XPathFactory.newInstance().newXPath(); try { NodeList nodes = (NodeList) xPath.evaluate( "//*[@" + propertyName + "]", document, XPathConstants.NODESET ); for ( int i = 0; i < nodes.getLength(); i++ ) { Node node = nodes.item( i ).getAttributes().getNamedItem( propertyName ); if ( replacedValue.equalsIgnoreCase( "uniqueid" ) ) { node.setNodeValue( new IdGenerator().generateUniqueId() ); continue; } node.setNodeValue( replacedValue ); } } catch ( XPathExpressionException e ) { e.printStackTrace(); } return this; }
Example 18
Source File: XMLReferencesManager.java From lemminx with Eclipse Public License 2.0 | 5 votes |
public void collect(DOMNode node, Consumer<DOMNode> collector) { DOMDocument document = node.getOwnerDocument(); for (XMLReferences references : referencesCache) { if (references.canApply(document)) { try { references.collectNodes(node, collector); } catch (XPathExpressionException e) { // TODO!!! e.printStackTrace(); } } } }
Example 19
Source File: Xml.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public static NodeList selectNodes(String express, Object source) {// 查找节点,返回符合条件的节点集。 NodeList result = null; XPathFactory xpathFactory = XPathFactory.newInstance(); XPath xpath = xpathFactory.newXPath(); try { result = (NodeList) xpath.evaluate(express, source, XPathConstants.NODESET); } catch (XPathExpressionException e) { e.printStackTrace(); } return result; }
Example 20
Source File: SLDOutput.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Gets the string. * * @param sldContentString the sld content string * @param selectionData the selection data * @param field the field * @param suffix the suffix * @return the string */ public String getString( String sldContentString, TreeSelectionData selectionData, FieldIdEnum field, String suffix) { Document doc = getXMLDocument(sldContentString); String extractedString = null; XPath xpath = xPathfactory.newXPath(); XPathExpression expr; try { String xPathString = null; SelectedTreeItemEnum selection = selectionData.getSelection(); String prefix = prefixMap.get(selection); Map<FieldIdEnum, String> fieldMap = xPathMap.get(selection); if (fieldMap == null) { System.err.println("Unknown selected tree item : " + selection); } else { String configXPathString = fieldMap.get(field); if (configXPathString == null) { System.err.println("Unknown XPath : " + field); } StringBuilder sb = new StringBuilder(); sb.append(prefix); sb.append("/"); sb.append(configXPathString); if (suffix != null) { sb.append(suffix); } String fieldString = sb.toString(); switch (selection) { case LAYER: xPathString = getLayerString(selectionData, fieldString); break; case STYLE: xPathString = getStyleString(selectionData, fieldString); break; case POINT_SYMBOLIZER: case LINE_SYMBOLIZER: case POLYGON_SYMBOLIZER: case TEXT_SYMBOLIZER: case RASTER_SYMBOLIZER: xPathString = getSymbolizerString(selectionData, fieldString); break; case RULE: xPathString = getRuleString(selectionData, fieldString); break; case POINT_FILL: case POLYGON_FILL: xPathString = getFillString(selectionData, fieldString); break; case STROKE: xPathString = getStrokeString(selectionData, fieldString); break; default: break; } if (xPathString != null) { expr = xpath.compile(xPathString); extractedString = expr.evaluate(doc); if ((extractedString == null) || extractedString.isEmpty()) { System.out.println("SLD : " + sldContentString); System.out.println("XPath : " + xPathString); } } else { System.out.println("No XPath string"); } } } catch (XPathExpressionException e) { e.printStackTrace(); } return extractedString; }