XSL import into XML file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

XSL import into XML file

Muaaz
Hi ,

This is general java (xmlparser) related question , my question is i have a XSLT file that transforms a separate XML file . after my test fnished following code is applying , but relevant XSLT file didnt import to relevant XML successfully , i appriciate if you can mention any similar code or suggetion , my code is ..

 public static void Xmlparser() throws TransformerException
          {
                        try{
              Source source = new StreamSource("myxml.xml");
                          Source xsl = new StreamSource("myxslt.xslt");
                          Result result = new StreamResult(System.out);
                         
                          TransformerFactory factory = TransformerFactory.newInstance();
                          Transformer transformer = factory.newTransformer(xsl);
                          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                          transformer.transform(xsl, result);
                        }catch(Throwable t)
                        {
                                System.out.println("cannot transform");
                                t.printStackTrace();
                        }


Relevant real error is ,


ERROR:  'D:\Aftersales_Automation\target\surefire-reports\cdcatalog.xsl (The system cannot find the file specified)'
FATAL ERROR:  'Could not compile stylesheet'
cannot transform
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:619)
        at com.ebuilder.core.Util.Xmlparser(Util.java:210)
        at com.ebuilder.core.Executor$1.oneTimeTearDown(Executor.java:91)
        at com.ebuilder.core.Executor$1.tearDown(Executor.java:95)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:24)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.extensions.TestSetup.run(TestSetup.java:27)
        at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
        at





ANY IDEA ?  whr did it went wrong ,


Reply | Threaded
Open this post in threaded view
|

Re: XSL import into XML file

softwaretestingforum
Administrator
I notice this error -

ERROR:  'D:\Aftersales_Automation\target\surefire-reports\cdcatalog.xsl (The system cannot find the file specified)' 

Could you check if xsl file is available in this location?
~ seleniumtests.com