Hi List
Apologies for a newbie question:
I have an XSLT that runs perfectly well through XSLTProc and Xalan
(through the Oxygen editor) so it would seem that my XSLT works.
However, when I run the XSLT on the same input XML file through Java
calling Xalan, I get multiple elements each having a namespace of the
format:
<ElementName xmlns:nsX=http://www.logica.com/project> where X increments
from 0 to 4295 in my particular case!
The Java I am using is the standard one which I cribbed from the Net:
import java.io.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
public class BasicXsl {
// This method applies the xslFilename to inFilename and writes
// the output to outFilename.
public static void main() {
String inFileName = "filename";
String outFileName = "filename";
String xslFileName = "filename";
try {
TransformerFactory factory =
TransformerFactory.newInstance();
Templates template = factory.newTemplates(new
StreamSource(new FileInputStream(xslFilename)));
Transformer xformer = template.newTransformer();
Source source = new StreamSource(new
FileInputStream(inFilename));
Result result = new StreamResult(new
FileOutputStream(outFilename));
xformer.transform(source, result);
} catch (FileNotFoundException e) {
} catch (TransformerConfigurationException e) {
// An error occurred in the XSL file
} catch (TransformerException e) {
// An error occurred while applying the XSL file
// Get location of error in input file
SourceLocator locator = e.getLocator();
int col = locator.getColumnNumber();
int line = locator.getLineNumber();
String publicId = locator.getPublicId();
String systemId = locator.getSystemId();
}
}
}
Does anyone have any idea why I am getting the extraneous namespaces on
the transformed elements (it is not all elements but the children of
/Root/Child/ - i.e. those lower in the tree), or how to get rid of them?
Thanks in advance
Stephen Etheridge
Please help Logica to respect the environment by not printing this email /
Pour contribuer comme Logica au respect de l'environnement, merci de ne pas
imprimer ce mail / Bitte drucken Sie diese Nachricht nicht aus und helfen Sie
so Logica dabei, die Umwelt zu schützen. / Por favor ajude a Logica a
respeitar o ambiente nao imprimindo este correio electronico.
This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an intended
recipient then please promptly delete this e-mail and any attachment and all
copies and inform the sender. Thank you.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--