Search code examples
javaxmlxsltjdeveloper

generating html from xml+xslt from jdeveloper


When I am trying to generate HTML from XML+XSLT in jdeveloper 10g using a java class I am getting following error

XML-22108: (Error) Invalid Source - URL format is incorrect.

XML-22000: (Fatal Error) Error while parsing XSL file (no protocol: headerMenu.xsl)

But when I am compiling the file with another jdk from command line it is working fine.

Following is my code snippet

 TransformerFactory tFactory = TransformerFactory.newInstance();

        Transformer transformer = 
            tFactory.newTransformer(new javax.xml.transform.stream.StreamSource(xslHeaderMenu)); //takes the xsl

             System.out.println("...xsl for header navigation menu block included...");

        transformer.transform(new javax.xml.transform.stream.StreamSource(xmlDataFile), 
                              new javax.xml.transform.stream.StreamResult(new FileOutputStream(htmlHeaderMenu))); //takes the xml and generates html for header menu

Please advice how can I generate inside jdeveloper


Solution

  • In the javadoc for StreamSource, the string method says that it 'Must be a String that conforms to the URI syntax', which you 'headerMenu.xsl' isn't.

    I would try:

    tFactory.newTransformer(
      new javax.xml.transform.stream.StreamSource(
        new File(xslHeaderMenu))); //takes the xsl
    

    as File can take an abstract filename (also for the other streamsource)