velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike J Boyersmith <>
Subject anakia question and possible problem
Date Mon, 17 Jan 2005 22:57:53 GMT
Having problems getting anakia to transform $root.getChild calls..

I have the following xml data file

<?xml version="1.0" encoding="UTF-8"?>
   <foo name="waka">

And the following vsl file (marked by !!! problem is here)

        <META content="text/html; charset=UTF-8" 
        <title> Main Title </title>
        <link href="mystyle.css" rel="stylesheet" type="text/css"/>
        <img src="overview_banner.jpg"/>
        <p class="LargeTitle"> 
         <!-- !!!!   PROBLEM IS HERE  !!!!!! -->

and finally the following java code

            SAXBuilder builder;
            Document root = null;
                builder = new 
SAXBuilder("org.apache.xerces.parsers.SAXParser" );
                root = XMLFile );
            //Stuff the Document (or root Element) into the context:
            VelocityContext context = new VelocityContext();
            context.put("root", root );

            Template template =  null;
            template = Velocity.getTemplate(templateFile);
            BufferedWriter writer = writer = new BufferedWriter(
                        new FileWriter("./output/thePage.html"));

            if ( template != null)
                template.merge(context, writer);


When I execute the code and debug, I see the files get loaded and the 
merge, flush and close work fine.
However, my output html still has the literal string 


embedded in it. when I check the log I see the following message

 "reference : template = StartPage.vsl [line 10,column 17] : 
 "$root.getChild("foo").getText() is not a valid reference.

I have tried every variation of xml and $root command I can think of 
and they all give me the same error. The only thing that doesn't produce 
error is if I just have $root.

any Idea why my getChild() call isn't working?

thanks for any help here...

Also, anyone have any other examples of using anakia, I can only find one 
that comes with the SDK...bah.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message