Methods Summary |
---|
public void | addDefaultQueryTemplate(java.io.InputStream xslIs)
defaultCompiledTemplates=getTemplates(xslIs);
|
public void | addQueryTemplate(java.lang.String name, java.io.InputStream xslIs)
compiledTemplatesCache.put(name,getTemplates(xslIs));
|
public static org.w3c.dom.Document | getQueryAsDOM(java.util.Properties formProperties, javax.xml.transform.Templates template)Fast means of constructing query using a cached,precompiled stylesheet
DOMResult result=new DOMResult();
transformCriteria(formProperties,template,result);
return (Document)result.getNode();
|
public static org.w3c.dom.Document | getQueryAsDOM(java.util.Properties formProperties, java.io.InputStream xslIs)Slow means of constructing query - parses stylesheet from input stream
DOMResult result=new DOMResult();
transformCriteria(formProperties,xslIs,result);
return (Document)result.getNode();
|
public org.w3c.dom.Document | getQueryAsDOM(java.util.Properties formProperties, java.lang.String queryTemplateName)
Templates ts=(Templates) compiledTemplatesCache.get(queryTemplateName);
return getQueryAsDOM(formProperties, ts);
|
public org.w3c.dom.Document | getQueryAsDOM(java.util.Properties formProperties)
return getQueryAsDOM(formProperties, defaultCompiledTemplates);
|
public static java.lang.String | getQueryAsXmlString(java.util.Properties formProperties, java.io.InputStream xslIs)Slow means of constructing query parsing a stylesheet from an input stream
ByteArrayOutputStream baos=new ByteArrayOutputStream();
StreamResult result=new StreamResult(baos);
transformCriteria(formProperties,xslIs,result);
return baos.toString();
|
public java.lang.String | getQueryAsXmlString(java.util.Properties formProperties, java.lang.String queryTemplateName)
Templates ts=(Templates) compiledTemplatesCache.get(queryTemplateName);
return getQueryAsXmlString(formProperties, ts);
|
public java.lang.String | getQueryAsXmlString(java.util.Properties formProperties)
return getQueryAsXmlString(formProperties, defaultCompiledTemplates);
|
public static java.lang.String | getQueryAsXmlString(java.util.Properties formProperties, javax.xml.transform.Templates template)Fast means of constructing query using a precompiled stylesheet
ByteArrayOutputStream baos=new ByteArrayOutputStream();
StreamResult result=new StreamResult(baos);
transformCriteria(formProperties,template,result);
return baos.toString();
|
public static javax.xml.transform.Templates | getTemplates(java.io.InputStream xslIs)Parses a query stylesheet for repeated use
dbf.setNamespaceAware(true);
DocumentBuilder builder = dbf.newDocumentBuilder();
org.w3c.dom.Document xslDoc = builder.parse(xslIs);
DOMSource ds = new DOMSource(xslDoc);
return tFactory.newTemplates(ds);
|
public static void | transformCriteria(java.util.Properties formProperties, java.io.InputStream xslIs, javax.xml.transform.Result result)Slower transformation using an uncompiled stylesheet (suitable for development environment)
dbf.setNamespaceAware(true);
DocumentBuilder builder = dbf.newDocumentBuilder();
org.w3c.dom.Document xslDoc = builder.parse(xslIs);
DOMSource ds = new DOMSource(xslDoc);
Transformer transformer =null;
synchronized (tFactory)
{
transformer = tFactory.newTransformer(ds);
}
transformCriteria(formProperties,transformer,result);
|
public static void | transformCriteria(java.util.Properties formProperties, javax.xml.transform.Templates template, javax.xml.transform.Result result)Fast transformation using a pre-compiled stylesheet (suitable for production environments)
transformCriteria(formProperties,template.newTransformer(),result);
|
public static void | transformCriteria(java.util.Properties formProperties, javax.xml.transform.Transformer transformer, javax.xml.transform.Result result)
dbf.setNamespaceAware(true);
//Create an XML document representing the search index document.
DocumentBuilder db = dbf.newDocumentBuilder ();
org.w3c.dom.Document doc = db.newDocument ();
Element root = doc.createElement ("Document");
doc.appendChild (root);
Enumeration keysEnum = formProperties.keys();
while(keysEnum.hasMoreElements())
{
String propName=(String) keysEnum.nextElement();
String value=formProperties.getProperty(propName);
if((value!=null)&&(value.length()>0))
{
DOMUtils.insertChild(root,propName,value);
}
}
//Use XSLT to to transform into an XML query string using the queryTemplate
DOMSource xml=new DOMSource(doc);
transformer.transform(xml,result);
|