# Best practice advice

**URL:** <https://www.ruby-forum.com/t/best-practice-advice/49984>\
**Category:** Rails\
**Created:** [December 11, 2005, 5:15pm UTC](https://www.ruby-forum.com/t/best-practice-advice/49984 "2005-12-11T17:15:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [December 11, 2005, 5:15pm UTC](https://www.ruby-forum.com/t/best-practice-advice/49984/1 "2005-12-11T17:15:16Z")

</div>

All,

I am currently investigating the rewrite of a PHP app in Rails.

One of the few reasonably well designed bits of the PHP app in question  
is its rendering layer, which transforms XML generated by the app into  
XHTML via XSLT.

I am aware that few existing Rails apps make use of XSLT, but in the  
interests of not biting off more than I can chew I’d quite like to  
replace the PHP generating the XML while keeping the XSLT in place.

I am confident that I know how to create a Rails app which generates XML  
instead of HTML. I’m not confident that I know how to best convert that  
XML into XSLT. I would very much appreciate guidance on how to approach  
this.

I am aware of the RAA ruby-xslt project, but am not sure if this is the  
best place for me to start. Unfortunately the homepage  
[http://www.rubyfr.net/](http://www.rubyfr.net/) is currently down, which doesn’t help, and I  
notice that others have experienced problems getting it to work:

[http://www.ruby-forum.com/topic/34085](http://www.ruby-forum.com/topic/34085)

Are there any other avenues that I should be exploring? Does anyone have  
an example of a Rails app which utilises XSLT that I could see?

Thanks in advance for your help!

paul.butcher-\>msgCount++

Snetterton, Castle Combe, Cadwell Park…  
Who says I have a one track mind?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [December 11, 2005, 5:28pm UTC](https://www.ruby-forum.com/t/best-practice-advice/49984/2 "2005-12-11T17:28:30Z")

</div>

It will be much easier to convert the whole application. Generating the  
XML with rails will be harder than generating HTML directly. I would use  
ERB templates instead of XSLT.

ps.

This is wrong:  
paul.butcher-\>msgCount++

It should be:

paul.butcher.msg\_count += 1  
or  
paul.butcher.msg\_count.next!

😉

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [December 11, 2005, 11:56pm UTC](https://www.ruby-forum.com/t/best-practice-advice/49984/3 "2005-12-11T23:56:30Z")

</div>

Jules J. wrote:

> It will be much easier to convert the whole application. Generating the  
> XML with rails will be harder than generating HTML directly. I would use  
> ERB templates instead of XSLT.

I very much hope that this isn’t the only option - because if it is,  
we’ll be sticking with PHP ☹

At present, the XML that we generate is very simple and straightforward.  
I know that I can put together something in Ruby which will generate it  
very easily. On the other hand, the XSLT which then turns it into XHTML  
is not straightforward. It will take a long time for me to pick it apart  
to the point where I understand it well enough to be able to replicate  
its functionality (whether in ERB or anything else).

I would certainly like to do this. But if I _have_ to do it in order to  
move to Ruby then we won’t move to Ruby ☹ I need to find a way to move  
piecemeal if its going to happen.

> This is wrong:  
> paul.butcher-\>msgCount++
> 
> It should be:
> 
> paul.butcher.msg\_count += 1  
> or  
> paul.butcher.msg\_count.next!
> 
> 😉

🙂

That signature has served me very well for very many years, during which  
time I’ve programmed in assembly, Basic, Forth, Pascal, C, C++, occam,  
Smalltalk, Ada, Linda, Russell, Java, Dylan, Haskell, Perl, Lisp, ML,  
Javascript, Python, shell scripts, batch files, PHP, a couple of  
languages which never got as far as having names and several others that  
I can’t remember just now. Ruby is going to have to be _really_ good to  
persuade me to change 🙂
