Page 169 - The Ultimate Palm Robot
P. 169
Color profile: Generic CMYK printer profile
Composite Default screen
Bots / The Ultimate Palm Robot/ Mukhar & Johnson / 222880-6 / Chapter 6
152 The Ultimate Palm Robot
The template tells the translator to replace that tag with the text
aServo_Stop( followed by the value of the servoNumber attribute, and fol-
lowed by a closing );. So what is written to the source code file is this:
aServoStop(1);
The second template is similar to the first. It takes a <Sleep> tag and con-
verts it into a line of code that calls the aCore_Sleep( ) function, changing sec-
onds to ten-thousandths of a second at the same time. Thus, this tag
<Sleep sleepSeconds="2"/>
becomes this line of code:
aCore_Sleep(20000);
The XSLT style sheet you create for your new language will need to handle
all the program icons used by the PRP. In other words, every icon in the palette
will have a corresponding template in the XSLT style sheet. In addition, you
will need a template for the tags used for the Main and Subroutine blocks.
Finally, as you can see in the XML listing earlier in this section, the root ele-
ment of the XMLis <PalmRobotProgram>, so your style sheet will need a tem-
plate for that tag.
The Robot Geek Says
If you want to learn how to create and use XSLT style sheets,
numerous books are available for you. We recommend these:
✖ XSLT by Doug Tidwell, from O’Reilly & Associates
✖ XSLT Quickly by Ron DuCharme, from Manning Publications Company
Just a couple of final steps are needed to add the new language translator to
the Palm Robot Programmer. First you need to compile the Java file you cre-
ated. When the file is successfully compiled into a class file, copy the class file
to the \classes\com\prp\converter directory of the PRP installation. You’ll
know you have the correct directory when you see the existing translator
classes and XSLT style sheets in the directory. If you created a toolbar icon,
copy that file to the same location. Finally, copy the XSLT style sheet to the
same location. The next time you run the PRP, the program will find the new
translator class and add an entry to the menu for the new language.
P:\010Comp\Bots\880-6\ch06.vp
Monday, May 12, 2003 1:06:28 PM