java - XSL validation while transformation -
i'm using folowing piece of code xsl transformation :
source source = new streamsource(new stringreader(request.tostring())); source xsl = new streamsource(xslpath); stringwriter destination = new stringwriter(); result result = new streamresult(destination); transformerfactory transfactory = transformerfactory.newinstance(); transformer transformer; transformer = transfactory.newtransformer(xsl); transformer.setoutputproperty(outputkeys.indent, "yes"); transformer.transform(source, result); the xslpath variable passes file location .xsl file.
i need know whether transfactory.newtransformer(xsl) kind of internal validation first of xsl file itself. if not, there way can validation of xsl file, before performing transformation.
i have code validate xsd file, but, beileve same code wouldn't work xsl. still tried well, throw or other saxexception non-white spaces not being allowed on of lines.
please help.
yes, first thing xslt processor validate , compile stylesheet. (why did have ask? introduce error, , see happens!)
you might find useful set errorlistener make sure application can capture error messages.
if using same stylesheet repeatedly many transformations, more efficient use newtemplates() create templates object validation/compilation once. think of templates object compiled stylesheet.
Comments
Post a Comment