Subject: [xsl] for-each performance question From: Josh Proctor <daslight110@xxxxxxxxx> Date: Mon, 26 Jan 2009 13:37:29 -0500 |
I have a question concerning performance (or maybe best practice): I am using cocoon 2.10, Xalan 2.7.0, and XSLT 1. My xml looks like this: <?xml version="1.0" encoding="ISO-8859-1" ?> <School> <Student> <Profile> <LastName>Joe</LastName> <FirstName>Smith</FirstName> <Middle>L</Middle> </Profile> </Student> </School> There are about 20 elements under profile, and only 1 student under HighSchoolAdmin. I need to display all the profile information for the student. This should be very simple but I want to make sure it is as efficient as possible, as we could have a very large number of people hitting the system at once. The xml is not large but the number of users who will be looking at this within a small time frame is very large. What would be best (or is there a better way): Case 1: A for-each "loop" which drills down to the parent node of the xml I want to display. <xsl:template match="/"> <xsl:for-each select="School/Student/Profile"> <p>Last Name: <xsl:value-of select="LastName"/></p> <p>First Name: <xsl:value-of select="FirstName"/></p> <p>Middle Name: <xsl:value-of select="Middle"/></p> ... </xsl:for-each> </xsl:template> Case 2: Applying a template which drills down to the parent node of the xml I want to display. <xsl:template match="/"> <xsl:apply-templates select="School/Student/Profile"/> </xsl:template> <xsl:template match="Profile"> <p>Last Name: <xsl:value-of select="LastName"/></p> <p>First Name: <xsl:value-of select="FirstName"/></p> <p>Middle Name: <xsl:value-of select="Middle"/></p> ... </xsl:template> Case 3: A variable with a tree fragment of the xml I want to display. <xsl:template match="/"> <xsl:variable name="studentProfile" select="School/Student/Profile"/> <p>Last Name: <xsl:value-of select="$studentProfile/LastName"/></p> <p>First Name: <xsl:value-of select="$studentProfile/FirstName"/></p> <p>Middle Name: <xsl:value-of select="$studentProfile/Middle"/></p> ... </xsl:template> Case 4: Use the XPath for each element I want to display. <xsl:template match="/"> <p>Last Name: <xsl:value-of select="School/Student/Profile/LastName"/></p> <p>First Name: <xsl:value-of select="School/Student/Profile/FirstName"/></p> <p>Middle Name: <xsl:value-of select="School/Student/Profile/Middle"/></p> ... </xsl:template> Thank you in advance for any help you can give me.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] FO border-end-width condi, G. Ken Holman | Thread | RE: [xsl] for-each performance ques, Michael Kay |
Re: [xsl] How to achieve FO Table v, Karl Stubsjoen | Date | RE: [xsl] for-each performance ques, Michael Kay |
Month |