velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clifton C. Craig" <...@icsaward.com>
Subject Re: Learning Velocity/Anakia
Date Tue, 12 Oct 2004 13:20:04 GMT
Thank you Shinobu,

I initially considered using properties.xml but considered it overkill 
for what I was attempting. I thought that I could pass in properties 
through the velocity.properties file somehow. I now believe that 
properties.xml may be the better approach here. My velocity.properties 
is as follows (generated using echoproperties from my Ant build):

#Ant properties
#Tue Oct 12 08:19:14 EDT 2004
version=1.4
file.resource.loader.path=C\:\\Documents and Settings\\Clifton 
Craig\\IdeaProjects\\ice\\DataAccess\\tools\\anakia\\stylesheets
home=D\:\\software\\velocity-1.4

The version and home properties are superfluous. (I couldn't quickly 
find a clean way to filter them from my propertyset.) The important 
property, file.resource.loader.path is definitely set to the correct 
path as I use this same value in the Anakia task directly sans 
velocity.properties and the templates are easily found. Also if I 
convert the value to a DOS 8.3 path as below it works.
#Ant properties
#Tue Oct 12 08:19:14 EDT 2004
version=1.4
file.resource.loader.path=C\:\\DOCUME~1\\CLIFTO~1\\IDEAPR~1\\ice\\DATAAC~1\\tools\\anakia\\STYLES~1
home=D\:\\software\\velocity-1.4

I am convinced that it is a result of the commons ExtendedProperties 
class that causes this. I don't believe that this class tokenized the 
CSV list correctly. I believe it tokenized on white-space as well as 
commas causing certain directory names to be broken into separate paths.

CANCEL WHAT I JUST WROTE ABOVE!! I just tried it and it doesn't work 
either way. The real problem is related to ExtendedProperties but not as 
I thought it would be. ExtendedProperties cannot evaluate a real Java 
properties file. It tries to offer convenience by not forcing you to 
escape backslashes. So my prior examples were being interpreted as is 
with double backslashes and all. I initially found success by 
accidentally coding the DOS 8.3 format without escaping the backslashes. 
(Idea local VCS revealed this to me.) That's why I thought the class 
wasn't tokenizing correctly. I just tried the following path and it worked.
file.resource.loader.path=C:\Documents and Settings\Clifton 
Craig\IdeaProjects\ice\DataAccess\tools\anakia\stylesheets

The funny thing is I've been struggling with escaped backslashed in 
properties files all year and I just figured out that the echoproperties 
task handles this transparently with this project. (I used to copy an 
existing properties file with ant properties which were expanded in 
place.) Now my first use of echoproperties is with a task that expects 
the paths in the properties file to be unescaped. Damned convenience 
coding is making things inconvenient. I understand what you're saying 
about the generated SQL and I'm going forward trying not to care. I was 
just wondering (hoping) that I could have my cake and eat it too because 
when I go back to debug problems it helps to have formatted output that 
I can use to trace problems. Besides, it just doesn't feel quite right 
doing it this way. I thank you for all of your suggestions.

Best Regards,

Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
2101 Embassy Drive
Lancaster, PA  17603

Phone:  717-295-7977 ext. 621
Fax:  717-295-7683
ccc@icsaward.com
ccraig@gbg.com



Shinobu Kawai wrote:

>Hi Craig,
>
>My first time with anakia, but let's see what I can figure out.
>
>  
>
>>Basically I'm struggling with white-space and formatting issues as well
>>as a way to externalize details of my XML schema. What I'm doing
>>currently is hard-coding the element and attribute names from my XML
>>document in my .vsl. I want to pass them in as properties or references
>>somehow. 
>>    
>>
>Hmm, if I understand anakia correctly, it looks like the only way you
>can do that is via $project (project.xml).
>
>  
>
>> I tried setting up a velocity.properties file but once I did
>>that Velocity was no longer able to find my .vsl template. I tried
>>setting the path property in the velocity.properties file and that
>>became an issue because the templates are stored in a Windows directory
>>with spaces in the names. (eg. "Documents And Settings") I tried several
>>renditions of this but what it boiled down to was I had to use the
>>primitive DOS 8.3 naming convention in my path or velocity would lose
>>it. I believe this is due to the Commons collections external properties
>>stuff but I haven't tested it to confirm my suspicions. Anyhow, that's
>>my 1st major concern.
>>    
>>
>That's strange, the only special characters are commas.  I put the vsl
>file in such a directory, but it worked.  What does your properties
>file look like?
>
>  
>
>> My 2nd problem is formatting of my Velocity code
>>and/or it's output. I can get away with both being a little sloppy
>>because it's just me using it now and the SQL syntax is very generous
>>with whitespace. However both need serious improvement. It seems that
>>anything I do to help readability suffers in sloppy output and anything
>>I do to format the output suffers in readability. I am brand new to this
>>project so I know the following example will look silly to many but
>>understand that I am learning.
>>    
>>
>If I were you, I wouldn't care about how sloppy the SQL output is, as
>long as the DBMS can understand it.  When you write java code, you
>don't write it so the class file is neat, do you?  Make the vsl as
>readable as possible.
>
>Best regards,
>-- Shinobu Kawai
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message