[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: How to achieve java format on generated code using

Subject: RE: How to achieve java format on generated code using xslt
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Thu, 25 Sep 2003 10:50:32 -0400
java format
[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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.