You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2004/02/02 23:02:45 UTC
DO NOT REPLY [Bug 26618] New: -
Relative path and file name parameters on XSLTProcess
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26618>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26618
Relative path and file name parameters on XSLTProcess
Summary: Relative path and file name parameters on XSLTProcess
Product: Ant
Version: 1.7Alpha (nightly)
Platform: All
OS/Version: All
Status: NEW
Severity: Enhancement
Priority: Other
Component: Core tasks
AssignedTo: dev@ant.apache.org
ReportedBy: keeleyd@clear.net.nz
This allows the generated output file to have these in it.
We have a branch of XSLTProcess that does this and use it widely.
It is one change to two files, simple.
Discussed on email with Stephane Bailliez.
The enhancement means that when you generate a java file, you can generate it's
package to match the source it was generated from. Or when you generate a BPEL
process or WSDL definition, the generated target namespace can match the
artefact you genereated if from. Very common requirements.
Suggested implementation:
CHANGE 1: add the parameters to before transforming
around line 507 in XSLTProcess add this (the constants are suggested here):
// TODO setup parameters - Only block added by David Keeley
// Intention is to get this added to apache ANT source
String sourceFile = xmlFile;
String sourcePath = xmlFile.replace('\\', '/');
int pos = sourcePath.lastIndexOf('/');
if (pos != -1) {
sourceFile = xmlFile.substring(pos+1);
sourcePath = sourcePath.substring(0, pos);
}
else {
sourcePath = "";
}
liaison.addParam("source-xml-file", sourceFile);
liaison.addParam("source-xml-path", sourcePath);
log("SOURCE " + sourcePath + " " + sourceFile);
liaison.transform(inFile, outFile);
CHANGE 2: make sure they are not immutable in the transformer, so change from
file to file
in TraXLiaison, comment this out around line 164:
// if (transformer == null) {
createTransformer();
// }
and modify this method as shown :
private void createTransformer() throws Exception {
if (transformer == null) {
if (templates == null) {
readTemplates();
}
transformer = templates.newTransformer();
// configure the transformer...
transformer.setErrorListener(this);
if (uriResolver != null) {
transformer.setURIResolver(uriResolver);
}
for (int i = 0; i < outputProperties.size(); i++) {
final String[] pair = (String[]) outputProperties.elementAt(i);
transformer.setOutputProperty(pair[0], pair[1]);
}
}
for (int i = 0; i < params.size(); i++) {
final String[] pair = (String[]) params.elementAt(i);
transformer.setParameter(pair[0], pair[1]);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org