-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from vmi/update_deps_20230319
Catch up Selenium 4.8.1 and update dependency versions.
- Loading branch information
Showing
13 changed files
with
100 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/jp/vmi/selenium/selenese/parser/XPathAPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package jp.vmi.selenium.selenese.parser; | ||
|
||
import javax.xml.transform.TransformerException; | ||
import javax.xml.xpath.XPath; | ||
import javax.xml.xpath.XPathConstants; | ||
import javax.xml.xpath.XPathExpression; | ||
import javax.xml.xpath.XPathExpressionException; | ||
import javax.xml.xpath.XPathFactory; | ||
|
||
import org.w3c.dom.Document; | ||
import org.w3c.dom.Node; | ||
import org.w3c.dom.NodeList; | ||
|
||
/** | ||
* org.apache.xpath.XPathAPI alternative. | ||
*/ | ||
public class XPathAPI { | ||
|
||
/** | ||
* Select single node. | ||
* | ||
* @param document XML document. | ||
* @param query query | ||
* @return node | ||
* @throws TransformerException exception. | ||
*/ | ||
public static Node selectSingleNode(Document document, String query) throws TransformerException { | ||
XPathFactory f = XPathFactory.newInstance(); | ||
XPath xPath = f.newXPath(); | ||
try { | ||
XPathExpression expr = xPath.compile(query); | ||
return (Node) expr.evaluate(document, XPathConstants.NODE); | ||
} catch (XPathExpressionException e) { | ||
throw new TransformerException(e); | ||
} | ||
} | ||
|
||
/** | ||
* Select node list. | ||
* | ||
* @param document XML document. | ||
* @param query query | ||
* @return list of node | ||
* @throws TransformerException exception. | ||
*/ | ||
public static NodeList selectNodeList(Document document, String query) throws TransformerException { | ||
XPathFactory f = XPathFactory.newInstance(); | ||
XPath xPath = f.newXPath(); | ||
try { | ||
XPathExpression expr = xPath.compile(query); | ||
return (NodeList) expr.evaluate(document, XPathConstants.NODESET); | ||
} catch (XPathExpressionException e) { | ||
throw new TransformerException(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters