xsl-list
[Top] [All Lists]

xml-source from COM to Xalan XLST-Transformation

2002-12-20 05:12:39
Hello,

please excuse my limit question to xlst. I hope the answer to following 
question can help also other people who get start with xalan passing dynamic 
xml-strings.

I am newbie at server side transformation, java and since several days i try to 
get run it.

Until now we use Tomcat and java-servlets transporting a COM-string in 
XML-Format by a java-com bridge to the browser IE6.

I try now with Xalan to do the stylesheet processing and serving html to the 
browser.

I get it run with static xml and xsl files, but not with the dynamic COM-String.

Any help and a tip where to look at resources and tutorials would be great.

My approach in the servlet:

// p_sXML is coming from JAVA-COM Bridge
// if i copy and save the p_sXML in a file xalan do the transformation
// if i try directly i get following error: java.net.MalformedURLException: no 
protocol: <?xml version="1.0" encoding="ISO-8 859-1"?>

public String  transform(String p_sXML)
{
    try
    {   

      TransformerFactory tFactory = TransformerFactory.newInstance();
        //ERROR:        
      //StreamSource xmlSource = new StreamSource(p_sXML);
        //THE SAME AS FILE: OK
      StreamSource xmlSource = new StreamSource(new 
URL("file:D:/Tomcat_4.1/webapps/ho/disposition.xml").openStream());
      //StreamSource xslSource = new StreamSource(sXSLFile);
      StreamSource xslSource = new StreamSource(new 
URL("file:D:/Tomcat_4.1/webapps/ho/xsl/disposition.xsl").openStream());
      // Generate the transformer.
      Transformer transformer = tFactory.newTransformer(xslSource);
      // Perform the transformation, sending the output to the response.
      transformer.transform(xmlSource, new StreamResult(out));
    }
    catch (Exception e)
    {
     System.out.println("transform(): Exception"); 
     e.printStackTrace();
    }
}       


Greetings from Hamburg, Germany


Hans Braumüller 
Systementwickler Web-Design 
Hanse Orga AG
Sportallee 41 
D-22335 Hamburg 
Telefon: (+49) 040 51 48 08-62 
Telefax: (+49) 040 51 48 08-88 
E-Mail: h(_dot_)braumueller(_at_)hanseorga(_dot_)de 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>