{
// 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");
// S ystem.setProperty("javax.xml.parsers.DocumentBuilderFactory",
// "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl") ;
// S ystem.out.println("==================> " +
// System.getProperty("javax.xml.parsers.DocumentBuilderFactory")) ;
// S ystem.out.println("==================>" +
// DocumentBuilderFactory.newInstance());
Iterator itr = System.getProperties().entrySet().iterator();
while (itr.hasNext())
{
Map.Entry entry = (Map.Entry)itr.next();
String key = (String)entry.getKey();
if (key.startsWith("javax"))
{
// System .out.println(key + " = " + entry.getValue());
}
}
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);
}