Subject: RE: [xsl] dictating node processing order From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx> Date: Tue, 29 Jul 2003 14:28:05 +0100 |
It might be a bit much here, but this is an ideal case for generating a stylesheet to handle the sort order and the display order. It's not that easy to start off with, but is really powerful. If your sort order and display fields are stored as java objects, you can generate sax events directly from those objects (rather than write them out as xml then process that). Write a stylesheet that processes that xml to generate the final stylesheet that you need. So for example, if your display fields were ordered like this: <display> <displayField>fullname</displayField> <displayField>code</displayField> <displayField>employer</displayField> <displayField>room</displayField> <displayField>phone</displayField> <displayField>email</displayField> </display> A good way to process fields in this order would be to have a named template something like: <xsl:template name="displayFields"> <xsl:apply-templates select="fullName"/> <xsl:apply-templates select="code"/> <xsl:apply-templates select="employer"/> .... </xsl:template> And then call that template when you want to process each <searchResult>. To generate this template from your displayField xml you would need a couple templates something like: <xsl:template match="display"> <xslt:template name="displayFields"> <xsl:apply-templates/> </xslt:template> </xsl:template> <xsl:template match="displayField"> <xslt:apply-templates select="{.}"/> <xsl:templates> (note the namespace prefixes) This requires you know how to generate a stylesheet from a stylesheet, which I'm sure is in Dave P's faq. Your generated stylesheet just needs to import your existing stylesheet (with all of the formatting templates) which can be hard coded or passed in as a parameter. There's a processing overhead to this, but if you generate the SAX events straight from java it can be reduced to the point on one extra fast transform per normal transform. Your stylesheets will also be much simpler, scalable etc so it's the usual tradeoff. cheers andrew XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] dictating node processing, Américo Albuquerque | Thread | [xsl] testing which files have same, James Cummings |
[xsl] dictating node processing ord, Nathan Shaw | Date | Re: [xsl] xslt-processor in perl?, Thomas F. O'Connell |
Month |