Re: Transforming data through Xalan
Hi, Without seeing your source xml I can't say for sure... but it looks as though your <xsl:for-each> can't find 'issues/issue' as a child of the root. You could use <xsl:for-each select="//issues/issue"> which will find all 'issue' elements with parent 'issues' throughout the whole xml doc, or you could make the path more specific (you will need to post some of your xml for help with that one) cheers andrew > > Hi All, > > Thank you for providing a forum like this for newbies like me. > > My problem is that: > > I have a JSP page which displays the various columns and look and feel based > on the selections made by user during account setup. This "metadata" is > stored in an XML file. > > While displaying the page I want to read the metadata, read a Java > collection (Vector) holding the records and convert it into SAX events on > the fly and apply one standard XSL to it. SAX events are generated for only > those data columns whose equivalent metadata have text value "Y". All this > transformation needs to be done at server-side only. > > The solution that I have been working with is > > 1- take input from user in a JSP page process the request and write the XML > file. > > 2- To generate the output XML, I parse this xml file into a dom tree and get > the Java Bean holding the Vector of Java objects to been displayed. I > generate the elements through my own parser extending XMLReader interface > (only those elements that need to be shown) > > 3- the XML generated by the TransformerHandlerIdentity contenthandler is > correct but when I plug the stylesheet into TransformerHandler the XSL > transformation do not get applied. > > I have traced the transformation through the xalan debugging classes and the > output says > > "file:///c:/ims/xsl/scheme.xsl Line #5, Column #25: template match='/' > STARTDOCUMENT > file:///c:/ims/xsl/scheme.xsl Line #6, Column #21: table > file:///c:/ims/xsl/scheme.xsl Line #7, Column #40: for-each > file:///c:/ims/xsl/scheme.xsl Line #7, Column #40: for-each, select='null': > [empty node list] > STARTELEMENT: table > ENDELEMENT: table > ENDDOCUMENT > > > for the xsl file which reads like > > <?xml version="1.0"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > <xsl:output method="html"/> > > <xsl:template match="/"> > <table border="1"> > <xsl:for-each select="issues/issue"> > <tr> > <xsl:apply-templates/> > </tr> > </xsl:for-each> > </table> > </xsl:template> > <xsl:template match="column"> > <td> > <xsl:value-of select="@name"/> > </td> > </xsl:template> > </xsl:stylesheet> > > I would be glad to provide any information needed. > > TIA, > Regards, > Pavitra Jain > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format