Package org.dom4j.xpath

Examples of org.dom4j.xpath.DefaultXPath


   * @return a new <code>XPath</code> instance
   * @throws InvalidXPathException if the XPath expression is invalid
   */
  public XPath createXPath(String xpathExpression)
      throws InvalidXPathException {
    DefaultXPath xpath = new DefaultXPath(xpathExpression);

    if (xpathNamespaceURIs != null) {
      xpath.setNamespaceURIs(xpathNamespaceURIs);
    }

    return xpath;
  }
View Full Code Here


    private static void filterWebXml(WebArchive webArchive, File explodedWarFile) {
        try {
            SAXReader reader = new SAXReader();
            Document document = reader.read(new File(explodedWarFile.getPath() + "/WEB-INF/web.xml"));
            // Keep in sync with guvnor-distribution-wars/src/main/config-processor-filter/jboss-as-7_0/web_xml-filter.xml
            DefaultXPath xpath = new DefaultXPath("//j:context-param[j:param-name/text()=\"resteasy.injector.factory\"]");
            Map<String,String> namespaces = new TreeMap<String,String>();
            namespaces.put("j","http://java.sun.com/xml/ns/javaee");
            xpath.setNamespaceURIs(namespaces);

            Node node =  xpath.selectSingleNode(document);
            node.detach();
            File filteredWebXml = new File("target/test/filtered/jboss-as-7_0/WEB-INF/web.xml");
            filteredWebXml.getParentFile().mkdirs();
            FileWriter writer = null;
            try {
View Full Code Here

  }

  private int[] extractBoxConstraint(Element root) {
    int[] result = new int[4];
    String nodeName = currentToken.getNode().getName();
    XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']");
    Element node = (Element) xPath.selectSingleNode(root);
    result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue();
    result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue();
    result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue();
    result[3] = Integer.valueOf(node.attribute("height").getValue()).intValue();
    return result;
View Full Code Here

  }

  private int[] extractBoxConstraint(Element root, Token token) {
      int[] result = new int[4];
      String nodeName = token.getNode().getName();
      XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']");
      Element node = (Element) xPath.selectSingleNode(root);
      result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue();
      result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue();
      result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue();
      result[3] = Integer.valueOf(node.attribute("height").getValue()).intValue();
      return result;
View Full Code Here

  @SuppressWarnings("rawtypes")
  public List selectNodes(String xPathStmt)throws DocumentException, Exception {
    if (!loaded()){
      throw new Exception ("XML Document not loaded.");
    }
    DefaultXPath dxp = new DefaultXPath(xPathStmt);
    dxp.setNamespaceContext(namespaceContext);
    List nodes = dxp.selectNodes(m_oRootElement);
    return nodes;
  }
View Full Code Here

   */
  public Node selectSingleNode(String xPathStmt) throws DocumentException, Exception {
    if(!loaded()){
      throw new Exception("XML Document not loaded.");
    }
    DefaultXPath dxp = new DefaultXPath(xPathStmt);
    dxp.setNamespaceContext(namespaceContext);
    Node node = dxp.selectSingleNode(m_oRootElement);
    return node;
  }
View Full Code Here

    private static void filterWebXml(WebArchive webArchive, File explodedWarFile) {
        try {
            SAXReader reader = new SAXReader();
            Document document = reader.read(new File(explodedWarFile.getPath() + "/WEB-INF/web.xml"));
            // Keep in sync with guvnor-distribution-wars/src/main/config-processor-filter/jboss-as-7_0/web_xml-filter.xml
            DefaultXPath xpath = new DefaultXPath("//j:context-param[j:param-name/text()=\"resteasy.injector.factory\"]");
            Map<String,String> namespaces = new TreeMap<String,String>();
            namespaces.put("j","http://java.sun.com/xml/ns/javaee");
            xpath.setNamespaceURIs(namespaces);

            Node node =  xpath.selectSingleNode(document);
            node.detach();
            File filteredWebXml = new File("target/test/filtered/jboss-as-7_0/WEB-INF/web.xml");
            filteredWebXml.getParentFile().mkdirs();
            FileWriter writer = null;
            try {
View Full Code Here

    private static void filterWebXml(WebArchive webArchive, File explodedWarFile) {
        try {
            SAXReader reader = new SAXReader();
            Document document = reader.read(new File(explodedWarFile.getPath() + "/WEB-INF/web.xml"));
            // Keep in sync with guvnor-distribution-wars/src/main/config-processor-filter/jboss-as-7_0/web_xml-filter.xml
            DefaultXPath xpath = new DefaultXPath("//j:context-param[j:param-name/text()=\"resteasy.injector.factory\"]");
            Map<String,String> namespaces = new TreeMap<String,String>();
            namespaces.put("j","http://java.sun.com/xml/ns/javaee");
            xpath.setNamespaceURIs(namespaces);

            Node node =  xpath.selectSingleNode(document);
            node.detach();
            File filteredWebXml = new File("target/test/filtered/jboss-as-7_0/WEB-INF/web.xml");
            filteredWebXml.getParentFile().mkdirs();
            FileWriter writer = null;
            try {
View Full Code Here

     * @throws InvalidXPathException
     *             if the XPath expression is invalid
     */
    public XPath createXPath(String xpathExpression)
            throws InvalidXPathException {
        DefaultXPath xpath = new DefaultXPath(xpathExpression);

        if (xpathNamespaceURIs != null) {
            xpath.setNamespaceURIs(xpathNamespaceURIs);
        }

        return xpath;
    }
View Full Code Here

    private static void filterWebXml(WebArchive webArchive, File explodedWarFile) {
        try {
            SAXReader reader = new SAXReader();
            Document document = reader.read(new File(explodedWarFile.getPath() + "/WEB-INF/web.xml"));
            // Keep in sync with guvnor-distribution-wars/src/main/config-processor-filter/jboss-as-7_0/web_xml-filter.xml
            DefaultXPath xpath = new DefaultXPath("//j:context-param[j:param-name/text()=\"resteasy.injector.factory\"]");
            Map<String,String> namespaces = new TreeMap<String,String>();
            namespaces.put("j","http://java.sun.com/xml/ns/javaee");
            xpath.setNamespaceURIs(namespaces);

            Node node =  xpath.selectSingleNode(document);
            node.detach();
            File filteredWebXml = new File("target/test/filtered/jboss-as-7_0/WEB-INF/web.xml");
            filteredWebXml.getParentFile().mkdirs();
            FileWriter writer = null;
            try {
View Full Code Here

TOP

Related Classes of org.dom4j.xpath.DefaultXPath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.