[xsl] My first try at XSL..can someone give me a few pointers?

Subject: [xsl] My first try at XSL..can someone give me a few pointers?
From: "Kevin Duffey" <kevin.duffey@xxxxxxxx>
Date: Sun, 7 Jan 2001 15:17:55 -0800
Hi there,

Just joined this list in hopes to figure out a few things. First..what is a
recommended XSL book? I see a few that are coming out soon, but is there a
good one right now that explains the full syntax of XSL and XPATH? Also,
being that I am using Xalan (the latest build as of three days ago), it
supports something called TrAX, which I am trying to use to convert..it is a
Java API or something and right now I seem to be using only 4 lines of code.
I pass in two StreamSources, one of which is XML, and the other of which is
XSL. I don't know if how I am doing this is correct or not, but here is a
very basic XML file I have, and the XSL I am using to convert it to HTML. If
someone could just let me know if this should work or not that would be
great. I keep getting an error saying the XML file needs to have a root
element, and I am not sure what it is saying.


<?xml version="1.0" encoding="ISO-8859-1"?>


<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
<xsl:output method="html"/>

  <xsl:template match="OrderBuilder">

  <xsl:template match="Name">


Lastly, what I am trying to do is something like the cocoon project, but
much smaller in size. I have a working, very simple mvc framework using a
singel controller servlet and a few other helper classes. It is similar to
Struts, but much smaller in size and a little bit different. I added an
xslControllerServlet, which instead of forwarding to a JSP page, it grabs
the output of the JSP page (which results in XML well-formed..I think), and
applies an XSL to it, to transform it. Here is the last bit of code, but I
can supply the whole thing if necessary. I don't want anyone to do the whole
thing for me..I just want to know if what I read from the XSL stuff online
if what I am doing should work, or am I way off the mark here. From what I
gathered, the TrAX api is supposed to make the process very simple..simply
supply the xml stream and xsl stream, and the result is put in the output
stream you supply. Here is the code snippet.

      String urlPrefix = "http://localhost/";;
      URL url = new URL(urlPrefix + "xsl/demo.jsp");
      HttpURLConnection urlConnection = (HttpURLConnection)
      InputStream is = urlConnection.getInputStream();
      xmlStream = new StreamSource(is);
      TransformerFactory tFactory = TransformerFactory.newInstance();
      Transformer transformer = tFactory.newTransformer(xslStream);
      transformer.transform(xmlStream, new

That above is the portion that grabs the JSP page output (as if a web
browser accessed it so that I can dynamically create the XML output it
returns), and then calls the TrAX api transform() method with the xmlStream
and uses the HttpServletResponse outputstream for the output.

I set the response.setContentType() to the xsl output (which in my case
right now..is always HTML). I should ask..do I need to do a response.flush()
call or anything..or should the above work and send the transformed output
to the browser that requested the initial page?

Thanks for any help. While not a big deal..if anyone would like my simple
mvc framework with source, I am happy to give it out. A few things it
does..much like Struts, is supports auto-bean population, a single xml
config file mapping for all actions (and multiple forwards per action, each
forward having the ability to specify an XSL page to use to transform it;
the auto-population actually works on nested objects, so that if you have a
JavaBean with an object in it as a field, you can auto-populate that object
(and nested objects, etc), which allows you to use "pass-through" abilities
(ask for more details if you would like). It also uses reflection to make it
very easy to know what action method is being called on any page (or any
button that submits a form or any href link).

Anyways..thanks for any help.

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

Current Thread