Subject: [xsl] dictating node processing order From: Nathan Shaw <n8_shaw@xxxxxxxxx> Date: Tue, 29 Jul 2003 05:28:16 -0700 (PDT) |
I am trying to allow an end user of an application to have the ability to pass in which fields they would like to see and in which order, as well as, what the sort order should be, when they view the results page of a search run against an LDAP server. To accomplish this, I am shoving their desired fields (which are ordered in the order in which they should be displayed in the resulting XHTML document) and sort order into the XML document so that I can pick them out with my XSLT (this was chosen instead of passing params into the parser for portability's sake). <searchResults> <searchResult> <uniqueID>HQ007267</uniqueID> <firstName>Jonathan</firstName> <lastName>Smith</lastName> <fullName>Jonathan H Smith</fullName> <title>Senior Consultant</title> <organization>National Aeronautics and Space Administration</organization> <orgUnit>headquarters</orgUnit> <email>jsmith5@xxxxxxxxxxxxxxxx</email> <code>AO</code> <employer>Booz, Allen and Hamilton</employer> <phone>+1 202 358-1389</phone> <fax>+1 202 358-3063</fax> <building>HQ</building> <room>6075</room> </searchResult> <searchResult> <uniqueID>HQ005617</uniqueID> <firstName>Mark</firstName> <lastName>Smith</lastName> <fullName>Mark Allen Smith</fullName> <title>Criminal Investigator</title> <organization>National Aeronautics and Space Administration</organization> <orgUnit>headquarters</orgUnit> <email>mark.smith@xxxxxxxx</email> <code>W</code> <employer>NASA</employer> <phone>+1 818 354-9804</phone> <fax>+1 818 393-4271</fax> <building>JPL</building> <room></room> </searchResult> <supplementaryData> <sort> <sortField>employer</sortField> <sortField>lastName</sortField> <sortPage>search.cfm</sortPage> </sort> <display> <displayField>fullname</displayField> <displayField>code</displayField> <displayField>employer</displayField> <displayField>room</displayField> <displayField>phone</displayField> <displayField>email</displayField> </display> <ldapBaseUrl>ldap://ldap.hq.nasa.gov:389/ou=headquarters,o=National Aeronautics and Space Administration,c=us??sub?</ldapBaseUrl> </supplementaryData> </searchResults> However, when trying to output the desired fields in the proper order, I am running into design problems. This is what I am attempting now, but apparently xsl:apply-templates needs an actual node set, not a string representing a pointer to a node set. <xsl:template match="searchResult"> <tr> <xsl:for-each select="$displayFields/displayField"> <xsl:variable name="dField" select="concat('/searchResults/searchResult/',normalize-space(.))" /> <!--<xsl:value-of select="$dField" /><br />--> <td valign="top" align="left"> <xsl:choose> <xsl:when test="$dField='email'"> <a> <xsl:attribute name="href">mailto:<xsl:value-of select="normalize-space(.)" /></xsl:attribute> <xsl:apply-templates select="$dField" /> </a> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="$dField" /> </xsl:otherwise> </xsl:choose> </td> </xsl:for-each> </tr> </xsl:template> Is there a better way to accomplish what I am trying to do? I feel like I should be thinking differently, looking at the problem from another angle, but I have been unable to see one yet. a cc to me is appreciated, as I am a digester... thanks, --Nate __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Using a reference in a sort, Jesse M. Heines | Thread | RE: [xsl] dictating node processing, Américo Albuquerque |
[xsl] Using a reference in a sort, Jesse M. Heines | Date | RE: [xsl] dictating node processing, Andrew Welch |
Month |