velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clifton C. Craig" <...@icsaward.com>
Subject Giving up on Velocity
Date Mon, 08 Nov 2004 19:20:09 GMT
I've had it. I'm trying my best but I can't get Velocity/Anakia to 
properly convert my XML to SQL. The code is starting to smell and it 
just doesn't feel quite right. I'm ready to hang up my efforts and call 
it quits. I can't see why something as simple as expanding a constraint 
list like this:
                <constraint name="simple_constraint">
                    <values select="exclude">
                        <val>hum</val>
                        <val>de</val>
                        <val>dum</val>
                    </values>
                </constraint>

would take code that looks like this:
#macro( expandIfNodeExists $node $templateStr)
    #if( $node )
        $!templateStr
    #end
#end

#macro( defineConstraints $col )
    #set ($colName = $col.getAttributeValue("name"))
    #set ( $constraint = $col.selectNodes("constraint") )
    #set ($constraintName = $constraint.selectNodes("@name").get(0))
    #if( $constraint.selectNodes("values") && 
$constraint.selectNodes("values").selectNodes("val") )
        #expandIfNodeExists($constraintName "constraint 
$constraintName.getValue()")
        #set ($list='')
        #foreach ($validVal in 
$constraint.selectNodes("values").selectNodes("val"))
            #set($qte = '"')
            #if($list=='')
                #set($list = "$qte$validVal.getText()$qte")
            #else
                #set($list = "$!list,$qte$validVal.getText()$qte")
            #end
        #end
        check $!colName
        #set ( $sltAtr = $constraint.selectNodes("values/@select") )
        #set ( $tmpltStr = "#if($sltAtr.get(0).getValue()=='exclude') 
not #else #end" )
        #expandIfNodeExists($sltAtr $tmpltStr)
        in ( $!list )
    #end
#end

And even that doesn't work. I know it probably not the technology at 
fault and it's just me. However, I feel like I've been slowed to a stop 
(if not a backward sprint) using Anakia. I thought it was the perfect 
fit at first but now I can't get past the clumsiness of doing anything 
sophisticated with it. If anyone can see where I'm coming from, please 
chime in and lend a hand. Otherwise, I'm stumped and I give up.

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



Clifton C. Craig wrote:

> An un-related question...
> How do you escape double quotes? I'm trying to use #set 
> ($var="\"MyValue\"") but $var ends up with \"MyValue\" instead of 
> "MyValue". When I try it without the backslashes I get parse errors.
>
> 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
>
>
>
> Clifton C. Craig wrote:
>
>> Hello all. I'm still green with Velocity. I'm wondering what's the 
>> easiest way to test a string for a numeric. For example, I have a 
>> string $myVal that can contain "foo", or "23.2", or "15". I want to 
>> 1st check if it is a numeric and then wrap it with quotes if it is not.
>>
>> 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
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>

---------------------------------------------------------------------
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