Subject: RE: [xsl] making html output for application pages From: "Hunsberger, Peter" <Peter.Hunsberger@xxxxxxxxxx> Date: Mon, 22 Apr 2002 09:02:51 -0500 |
> I'm currently in the process of converting some legacy .jsp files to output > xml which will then be processed by xslt to output the pages. <snip>...</snip> > When generating the pages, the xsl figures out the general layout of the > page and values of things like the page title, headers. This requires lots > of instances of: > <xsl:choose> <snip>...</snip> > This means that when someone is translating the "index" page, they need to > go through the entire document and find each of these choices and work on > the little bits of text inside. > > I had thought it might be easier if I had some kind way of declaring all the > bits of text as variables at the top of the page, but I ran into a variable > scoping problem. > > I may be thinking in the wrong paradigm, but I wanted some way to say > "setupIndex" where one chunk of code would set up a bunch of variables that > would all be used later on in the <top> template. Bernie, In addition to using modal templates you may want to look at using imported or included templates. Since you have control over both ends of the transform you should be able to specify different templates for every major style of page. These templates can then either import or include a common templates that contains all the common processing logic. You then use the pattern of: <head> <title><xsl:value-of .../> <!-- page specific stuff --> . . . <xsl:apply-templates match="head"/> <!-- general stuff --> <!-- more page specific stuff --> . . . </head> <body> <!-- page specific stuff --> . . . <xsl:apply-templates match="form"/> <!-- general stuff --> <!-- page specific stuff --> . . . </body> This allows the main template for each page to contain all the page specific logic. In the generic templates I usually have things like table builders or dialogue builders. All the page specific setup is completed by the time the generic templates are called. However, the page specific templates typically don't run more than about 80 lines of code at most, and they don't do all the specific formatting; they pass generally named variables that contain page specific information. As to choosing between import and include; import is generally more flexible and allows you the equivalent of multiple inheritance. However, there can apparently be some issues with passing global parameters around with imported templates. I've never run into them, but if you really need to pass a lot of variables around include might work better for you... I should also note, that I use modal templates in addition to the imported and included templates. In our case they distinguish between handling data from different sources that has similar structure, but different output requirements. However, once again the pattern is that of a global switch. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] making html output for ap, J.Pietschmann | Thread | Re: [xsl] making html output for ap, Bernie Bernstein |
[xsl] Re: last(): selecting the las, Dimitre Novatchev | Date | [xsl] leaving and thanks, Ralph Holz |
Month |