Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Method;

import javax.xml.transform.TransformerException;

import org.w3c.dom.Node;

import org.w3c.dom.traversal.NodeIterator;

public class Main {
    /** Holds the method for executing the selectNodeIterator method. */
    private static Method s_mSelectNodeIterator;

    /**
     * Use an XPath string to select a nodelist. XPath namespace prefixes are resolved from the contextNode.
     * 
     * @param nContextNode The node to start searching from.
     * @param sXPath A valid XPath string.
     * @return A NodeIterator, should never be null.
     * @throws TransformerException
     */
    public static NodeIterator selectNodeIterator(Node nContextNode, String sXPath) throws TransformerException {
        try {
            return (NodeIterator) s_mSelectNodeIterator.invoke(null, new Object[] { nContextNode, sXPath });
        } catch (Exception e) {
            throw new TransformerException(e);
        }
    }
}