Geert Josten wrote:
I replied to the list earlier that I have written a lightweight Transformer that does exactly what you want. But you make an even more lightweight one allowing only copying of files.Geert,
Extend the AbstractTransformer, add the following:
public void startElement(String namespaceURI, String localName, String qName, Attributes attributes) throws SAXException {
// If we encounter a file element in our namespace, invoke a copy
// on the src attribute
if (COPY_FILES_NS.equals(namespaceURI) && FILE_ELEMENT.equals(localName)) {
copy(attributes.getValue(SRC_ATTRIBUTE), attributes.getValue(TARGET_ATTRIBUTE));
}
else {
super.startElement(namespaceURI, localName, qName, attributes);
}
}
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException {
if (COPY_FILES_NS.equals(namespaceURI) && FILE_ELEMENT.equals(localName)) {
; // Do nothing here since we want to remove this element.
} else {
super.endElement(namespaceURI, localName, qName);
}
}
And add a copy function that does the actual copying, just using plain Java...
Cheers...
Thanks for your help.
I would like to take you up on your offer -- please send me the code for the "save" transformer. And I will probably need to ask detailed questions on where to put the code, etc.
I would also very much like to see your transformer contributed to the Cocoon distro; it seems like copying a file would be a pretty widely useful feature. (And I don't want to leave my successors here the hassle of trying to figure out compile their own transformers when they upgrade Cocoon!)
As a start, I think someone should at least write a wiki page specifying what your transformer does, so people can find it.
E.g. a page like http://cocoon.apache.org/2.1/userdocs/transformers/sourcewriting-transformer.html that describes the capabilities. (http://wiki.apache.org/cocoon/SavingFilesToFileSystem should have a link to such a page.)
On the other hand, maybe this would be better as an improvement to the source-writing transformer, since it does something very similar and could be handled with very little change to the API. Or do you think the source-writing transformer is "heavy" enough that a separate lightweight one is warranted?
Really, I would be happy to do the coding, but as I said before, I have never extended a transformer, and I'm not a very experienced Java programmer, so I don't have confidence that I'd do well even on a file copy function... especially in an environment like Cocoon where it's hard to know what a relative path should be relative to. But if somebody could coach me I'd be happy to do it.
Lars
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
