Subject: RE: [xsl] How to achieve java format on generated code using xslt From: "Passin, Tom" <tpassin@xxxxxxxxxxxx> Date: Thu, 25 Sep 2003 10:50:32 -0400 |
[Mikael Petterson] > I am using xsl/xslt to generate java code. The problem I have > is to make the output more readable. Visual formatting of text output can be hard, all right, depending on what you want to do. > Here is part of the code that I generate: > > public void actionTcp (Coordinator c) throws Exception, > HwException, > SwException, > FailoverException; > > I would rather see something like: > > public void actionStartTpcInsertion(Coordinator c) throws Exception, > > HwException, > > SwException, > > FailoverException; > > ( If it does not show up in the mail, I mean all Execptions > below each other in a straight line.) > > How can I make sure that they begin under Exception and in a > straight line? > First you have to figure out just what you want to do in terms of characters in the output, because xslt does not know about anything more advanced about output characteristics. There are many ways - mostly awkward, like recursive templates - to create stringlets for formatting, but in this particular example, I think it could be done more easily. You want to insert a string composed of blanks in front of each text fragment. You can get one this way (this may get a bit distorted by wordwrapping in your email reader)- <xsl:variable name='padding' select='translate(" public void actionTcp (Coordinator c) throws", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", " "'/> Make sure that there is one space in the replacement string for each character in the alphabet string (you could add numbers and other characters if you need them). Then you just concatenate $padding and the string fragment you need to pad. You can make the padding string by calling a template, passing the string to used as a parameter. That way, you would not have to keep coding the padding strings by hand. > Does anyone of you ( somewhere out there......) have any experience with code generation? I have generated python, SQL table definitions, and lots of javascript. Cheers, Tom P XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to achieve java forma, Mikael Petterson (KI | Thread | Re: [xsl] How to achieve java forma, Robert Ogden |
[xsl] Multiple input files, Ricardo Saraiva | Date | RE: [xsl] How to achieve java forma, Passin, Tom |
Month |