{
// System.setProperty("javax.xml.xpath.XPathFactory",
// "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl") ;
// XPathFactory xpfactory = XPathFactory.newInstance() ;
XPath xpath = XPathFactory.newInstance().newXPath();
XPathExpression clientTypeExp = xpath.compile("/clients-type/client-type");
XPathExpression nameExp = xpath.compile("name/text()");
XPathExpression userAgentPatternExp = xpath.compile("userAgentPattern/text()");
XPathExpression preferredMimeTypeExp = xpath.compile("preferredMimeType/text()");
XPathExpression rendererExp = xpath.compile("renderer/text()");
ClassLoader cl = Thread.currentThread().getContextClassLoader();
java.net.URL url = cl.getResource("conf/portal/clients-type.xml");
DocumentBuilderFactory finstance = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = finstance.newDocumentBuilder();
Document document = builder.parse(url.openStream());
NodeList nodes = (NodeList)clientTypeExp.evaluate(document, XPathConstants.NODESET);
for (int i = 0; i < nodes.getLength(); i++)
{
Node node = nodes.item(i);
String name = (String)nameExp.evaluate(node, XPathConstants.STRING);
String userAgentPattern = (String)userAgentPatternExp.evaluate(node, XPathConstants.STRING);
String preferredMimeType = (String)preferredMimeTypeExp.evaluate(node, XPathConstants.STRING);
String renderer = (String)rendererExp.evaluate(node, XPathConstants.STRING);
HttpClientType clientInfo;
if (renderer != null && renderer.length() > 0)
{
clientInfo = new HttpClientType(name, userAgentPattern, preferredMimeType, renderer);
}