[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

for-each performance question

Subject: for-each performance question
From: Josh Proctor <daslight110@xxxxxxxxx>
Date: Mon, 26 Jan 2009 13:37:29 -0500
 for-each performance question
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.