|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Still Alive?
I'm not sure if this mailing list is still active. I am truly hoping that it is. I am having some trouble using XSLT in my web application. More specifically I'm having trouble using Java during the translation process. I have worked with XSL quite a bit for this project and I've had to use little static Java helpers to perform really complex calculations and conditionals. However, a situation has come up where life would be a lot easier if I could have a persistent Java Object during Translation. The situation. I have an XML document with 3 large nodes under the root. <es-feed> <events /> <performers /> <venues /> </es-feed> My Application is only concerned with the events node, however the events need specific information provided within the performers and venues nodes. My XSLT file looks like: <xsl:template match="/"> <general-feed> <xsl:apply-templates select="performers" /> <xsl:apply-templates select="venues" /> <xsl:apply-templates select="events" /> </general-feed> </xsl:template> What I want to do is create a global variable that is a Java Object, and then I want to use this Java object to store the required information about performers and venues so that I can access it very quickly when translating the events node. A cut down version of the entire XSL file would look something like this: <xsl:template match="/"> <xsl:variable name="eventHolder" select="java:EventHolder.new()"/> <general-feed> <xsl:apply-templates select="performers" /> <xsl:apply-templates select="venues" /> <xsl:apply-templates select="events" /> </general-feed> </xsl:template> <xsl:template match="performers"> <xsl:for-each select="performer"> <xsl:variable name="id" select="@id" /> <xsl:variable name="name" select="name" /> <xsl:value-of select="eventHolder.holdPerformerName($id, $name)" /> </xsl:for-each> </xsl:template> <xsl:template match="venues"> <xsl:for-each select="venue"> <xsl:variable name="id" select="@id" /> <xsl:variable name="name" select="name" /> <xsl:value-of select="eventHolder.holdVenueName($id, $name)" /> </xsl:for-each> </xsl:template> <xsl:template match="events"> <events> <xsl:for-each select="event"> <xsl:variable name="performerID" select="performer-id" /> <xsl:variable name="venueID" select="venue-id" /> <event> <name><xsl:value-of select="name"/></name> <performer-name><xsl:value-of select="eventHolder.getPerformerName($performerID)" /></performer-name> <venue-name><xsl:value-of select="eventHolder.getVenueName($venueID)" /></venue-name> <event> </xsl:for-each> </events> </xsl:template> I can create the variable easily and it works. However I get errors whenever I try to access one of the methods. Perhaps there is a better way to do this, and I'd appreciate any help anyone can give me. Thanks, Eric
|
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
|






