|
You don't import
'javax.xml.transform.Transformer', try
adding <%@
page import="javax.xml.transform.*" %>.
Von: Pasche [mailto:[EMAIL PROTECTED] Gesendet: Montag, 25. Juli 2005 23:41 An: [email protected] Betreff: XSLT transformation with a xindice result I try to transform a XML
document I get from the xindice database. First of all, I transform the
result of the xpath query into a DOMSource. Then I try to transform this
DOMSource with the help of a xslt stylesheet. But I can´t even compile it (see
errors below). I have no idea why I get the “cant resolve symbol” error. I think
I included all classes. <%@ page
import="org.xmldb.api.base.*" %> <%@ page
import="org.xmldb.api.modules.*" %> <%@ page import="org.xmldb.api.*"
%> <%@ page import="org.w3c.dom.*"
%> <%@ page
import="javax.xml.transform.dom.*" %> <%@ page
import="javax.xml.transform.stream.*" %> String suche =
request.getParameter("suchbegriff"); Collection col =
null; try
{
String driver =
"org.apache.xindice.client.xmldb.DatabaseImpl";
Class c = Class.forName(driver);
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col =
DatabaseManager.getCollection("xmldb:xindice://83.137.103.78:8080/db/wikipedia");
String xpath = "/output/ART/A0[SSTW='" + suche +
"']"; DOMSource src = "">
XPathQueryService service =
(XPathQueryService) col.getService("XPathQueryService",
"1.0");
ResourceSet resultSet = service.query(xpath);
ResourceIterator results = resultSet.getIterator();
while (results.hasMoreResources()) {
XMLResource res = (XMLResource)
results.nextResource();
Node node = res.getContentAsDOM();
src = "" DOMSource(node);
}
// Generate a Transformer.
javax.xml.transform.Transformer transformer =
Factory.newTransformer
(new
javax.xml.transform.stream.StreamSource("pml.xsl"));
// Create an empy DOMResult object for the
output.
javax.xml.transform.dom.DOMResult domResult = new
javax.xml.transform.dom.DOMResult();
// Perform the transformation.
transformer.transform(new
javax.xml.transform.dom.DOMSource(src));
// Now you can get the output Node from the
DOMResult.
org.w3c.dom.Node output =
domResult.getNode();
Result res = new StreamResult(output);
out.println(res.getOutputStream());
} catch
(XMLDBException e) {
System.err.println("XML:DB Exception occurred " +
e.errorCode);
}
finally {
if (col != null) {
col.close();
}
} Generated servlet error: ____________ Virus checked by G DATA AntiVirusKit Version: AVK 15.0.6237 from 25.07.2005 |
- AW: XSLT transformation with a xindice result Eickvonder Bjoern
