[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: dictating node processing order
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
|
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
|