Finally got it working. Source is enclosed.

Deeply disapointed in xslt from what I've seen so far. This was much work for what it does.

On Sunday, February 3, 2002, at 03:29 PM, Frank E. Weiss wrote:

I'm afraid I didn't understand your recommendation. I've tried
changing the subroutine to accept several of the possible types
(Node, NodeIterator), etc, which worked in that the subroutine
was still being called. Gave up on that because I wasn't sure
where to go from there.

public Page getPage(IntegerField pageNumber) throws Fault
{
System.err.println("pages:"+pages);
System.err.println("lastModified"+
" xml:"+ (lastModified-xmlFile.lastModified())+
" xsl:"+ (lastModified-xslFile.lastModified())
);
if (pages == null ||
xmlFile.lastModified() > lastModified ||
xslFile.lastModified() > lastModified)
{
if (!xmlFile.exists()) throw new Fault(this + " can't find:"+xmlFile, null);
if (!xslFile.exists()) throw new Fault(this + " can't find:"+xslFile, null);
try
{
System.err.println("transforming:"+ xmlFile + " with " + xslFile);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(
new StreamSource(xslFile.toString())
);
transformer.setParameter("task", this);
StringWriter sw = new StringWriter();
transformer.transform(
new StreamSource(xmlFile.toString()),
new StreamResult(sw)
);
System.err.println("discarded text:"+sw);
this.lastModified = System.currentTimeMillis();
}
catch (Exception e)
{
throw new Fault("Exception transforming:"+xmlFile+ " with:"+xslFile, e);
}
}
else System.err.println("reusing cached page");
return (Page)pages.get(pageNumber.getInt());
}
public void addPage( String ident, org.w3c.dom.traversal.NodeIterator dom)
{
System.err.println("addPage:"+ident+"="+dom);
try
{
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer serializer = tfactory.newTransformer();
Properties oprops = new Properties();
oprops.put("method", "html");
oprops.put("indent-amount", "2");
serializer.setOutputProperties(oprops);


StringWriter sw = new StringWriter();
StreamResult sr = new StreamResult(sw);
for (Node node = dom.nextNode(); node != null; node=dom.nextNode())
{
DOMSource source = new DOMSource(node);
serializer.transform(source, sr);
}
String text =
"#parse(\"vel/macros.vel\")\n"+
"#taskOpening(\""+ident+"\")\n"+
sw+
"#taskClosing(\""+ident+"\")\n"+
"";
System.err.println("text:"+text);
pages.add(new Page(this, ident, text, new IntegerField(pages.size())));
}
catch (Exception e)
{
System.err.println("IOException:" + ident);
e.printStackTrace();
}
}
}




Reply via email to