Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > XSLT

Reply
 
 
trans. (T. Onoma)
Guest
Posts: n/a
 
      10-19-2004
What's the preferred way to do XSL transformations?

Is their a reliable Ruby tool out there for the task? Or is there a fairly
standard unix tool one uses?

Thanks,
T.


 
Reply With Quote
 
 
 
 
Will Drewry
Guest
Posts: n/a
 
      10-19-2004
On Tue, 19 Oct 2004 22:28:27 +0900, trans. (T. Onoma)
<(E-Mail Removed)> wrote:
> What's the preferred way to do XSL transformations?
>
> Is their a reliable Ruby tool out there for the task? Or is there a fairly
> standard unix tool one uses?
>
> Thanks,
> T.
>
>


On the commandline, you can use xsltproc or xalan. (I'm sure there are
others too). Both of these are apt-gettable in Debian. Xalan is from
the Apache Foundation. It's been pretty solid for a while now.

I've also seen these ruby projects floating around

http://raa.ruby-lang.org/project/ruby-xslt/
http://raa.ruby-lang.org/project/libxslt/
http://raa.ruby-lang.org/project/xslt4r/

Ruby-xslt looks to have had a new version was released just recently.
You'll probably want ruby-xpath to go with it too.

The examples make it look as easy as this -

require 'xml/xslt'

xslt = XML::XSLT.new()
xslt.xmlfile = "fuzface.xml"
xslt.xslfile = "fuzface.xsl"

out = xslt.serve()
print out;

(This is also the libxslt-ruby package in Debian.)

I have to admit, though, that I tend to avoid XSL transformations
except in the direst of circumstances, instead using Ruby itself as my
transformation language (via the DOM, SAX, or REXML interfaces).

Just my two cents. good luck,
wad


 
Reply With Quote
 
 
 
 
trans. (T. Onoma)
Guest
Posts: n/a
 
      10-19-2004
Nice. Thanks you for such a great reply! Very informative.

Why do you avoid XSLT? Because it is slow? Or?

Thanks,
T.


On Tuesday 19 October 2004 10:44 am, Will Drewry wrote:
| On the commandline, you can use xsltproc or xalan. (I'm sure there are
| others too). Both of these are apt-gettable in Debian. Xalan is from
| the Apache Foundation. It's been pretty solid for a while now.
|
| I've also seen these ruby projects floating around
|
| http://raa.ruby-lang.org/project/ruby-xslt/
| http://raa.ruby-lang.org/project/libxslt/
| http://raa.ruby-lang.org/project/xslt4r/
|
| Ruby-xslt looks to have had a new version was released just recently.
| You'll probably want ruby-xpath to go with it too.
|
| The examples make it look as easy as this -
|
| require 'xml/xslt'
|
| xslt = XML::XSLT.new()
| xslt.xmlfile = "fuzface.xml"
| xslt.xslfile = "fuzface.xsl"
|
| out = xslt.serve()
| print out;
|
| (This is also the libxslt-ruby package in Debian.)
|
| I have to admit, though, that I tend to avoid XSL transformations
| except in the direst of circumstances, instead using Ruby itself as my
| transformation language (via the DOM, SAX, or REXML interfaces).
|
| Just my two cents. good luck,
| wad



 
Reply With Quote
 
Francis Hwang
Guest
Posts: n/a
 
      10-19-2004
If your generation logic is at all sophisticated, XSLT is going to be a
profoundly cumbersome way to express that logic. It is reasonably
simple with boolean switches and simple loops, but anything more
complex then that and you find yourself typing in 50 lines of XSLT to
do what could be done in 5 lines in Ruby.

My personal website publishing experiment uses XSLT for very simple
transformations, and then Ruby for anything at all complicated. Then
you just have to find a way to stitch those two together.

Francis

On Oct 19, 2004, at 10:52 AM, trans. (T. Onoma) wrote:

> Nice. Thanks you for such a great reply! Very informative.
>
> Why do you avoid XSLT? Because it is slow? Or?
>
> Thanks,
> T.
>
>
> On Tuesday 19 October 2004 10:44 am, Will Drewry wrote:
> | On the commandline, you can use xsltproc or xalan. (I'm sure there
> are
> | others too). Both of these are apt-gettable in Debian. Xalan is from
> | the Apache Foundation. It's been pretty solid for a while now.
> |
> | I've also seen these ruby projects floating around
> |
> | http://raa.ruby-lang.org/project/ruby-xslt/
> | http://raa.ruby-lang.org/project/libxslt/
> | http://raa.ruby-lang.org/project/xslt4r/
> |
> | Ruby-xslt looks to have had a new version was released just recently.
> | You'll probably want ruby-xpath to go with it too.
> |
> | The examples make it look as easy as this -
> |
> | require 'xml/xslt'
> |
> | xslt = XML::XSLT.new()
> | xslt.xmlfile = "fuzface.xml"
> | xslt.xslfile = "fuzface.xsl"
> |
> | out = xslt.serve()
> | print out;
> |
> | (This is also the libxslt-ruby package in Debian.)
> |
> | I have to admit, though, that I tend to avoid XSL transformations
> | except in the direst of circumstances, instead using Ruby itself as
> my
> | transformation language (via the DOM, SAX, or REXML interfaces).
> |
> | Just my two cents. good luck,
> | wad
>
>




 
Reply With Quote
 
James Britt
Guest
Posts: n/a
 
      10-19-2004
trans. (T. Onoma) wrote:
> What's the preferred way to do XSL transformations?
>
> Is their a reliable Ruby tool out there for the task? Or is there a fairly
> standard unix tool one uses?


The last time I took a serious look at XSLT and Ruby as about a year
ago. A big reason for the gap is that I've become happier doing XML
transformations using REXML's pullparser, or simple regexen. But that's
not to everyone's taste or choice


My recollection is that there are no complete, pure-Ruby XSLT tools.
If you require access to all the bells and whistles, you may need to use
the bindings/wrappers for Sablotron or libxslt.

http://www.rubyxml.com/rubyConf2003/...cessingInRuby/

will tell you what I knew a year ago. Otherwise, Google around for the
libxslt or Sablotron stuff.

Or see here:

http://www.rubygarden.org/ruby?AlexNetkachev


James



 
Reply With Quote
 
Florian Weber
Guest
Posts: n/a
 
      10-19-2004

On Oct 19, 2004, at 16:52 Uhr, trans. (T. Onoma) wrote:

> Nice. Thanks you for such a great reply! Very informative.
>
> Why do you avoid XSLT? Because it is slow? Or?


you will run into tons of situations where xslt can't do what you
wanna do, because it's based on xml.. and when it's possible
you are either forced to duplicate code or using a even more
verbose way of expressing what you wanna do..

well, and sooner or later its verbosity will also annoy the hell out of
you.

personally i would never recommend anybody to use xslt if you
are not absolutely forced to or doing something very simple.

ciao!
florian



 
Reply With Quote
 
trans. (T. Onoma)
Guest
Posts: n/a
 
      10-19-2004
On Tuesday 19 October 2004 04:22 pm, Florian Weber wrote:
| On Oct 19, 2004, at 16:52 Uhr, trans. (T. Onoma) wrote:
| > Nice. Thanks you for such a great reply! Very informative.
| >
| > Why do you avoid XSLT? Because it is slow? Or?
|
| you will run into tons of situations where xslt can't do what you
| wanna do, because it's based on xml.. and when it's possible
| you are either forced to duplicate code or using a even more
| verbose way of expressing what you wanna do..
|
| well, and sooner or later its verbosity will also annoy the hell out of
| you.
|
| personally i would never recommend anybody to use xslt if you
| are not absolutely forced to or doing something very simple.

That's too bad. So there is no _worthy_ standard declarative XML
transformation language then? So much for standards. I will use Ruby. Thanks.

T.


 
Reply With Quote
 
Francis Hwang
Guest
Posts: n/a
 
      10-20-2004

On Oct 19, 2004, at 4:39 PM, trans. (T. Onoma) wrote:

> On Tuesday 19 October 2004 04:22 pm, Florian Weber wrote:
> | On Oct 19, 2004, at 16:52 Uhr, trans. (T. Onoma) wrote:
> | > Nice. Thanks you for such a great reply! Very informative.
> | >
> | > Why do you avoid XSLT? Because it is slow? Or?
> |
> | you will run into tons of situations where xslt can't do what you
> | wanna do, because it's based on xml.. and when it's possible
> | you are either forced to duplicate code or using a even more
> | verbose way of expressing what you wanna do..
> |
> | well, and sooner or later its verbosity will also annoy the hell out
> of
> | you.
> |
> | personally i would never recommend anybody to use xslt if you
> | are not absolutely forced to or doing something very simple.
>
> That's too bad. So there is no _worthy_ standard declarative XML
> transformation language then? So much for standards. I will use Ruby.
> Thanks.


Standards are great for some things, awful for others. Data interchange
and compatibility is a place where standards make our lives much
easier. Turing-completeness is a place where standards are much less
helpful. (Of course, the line between the two isn't always clear ...)

F.



 
Reply With Quote
 
Dido Sevilla
Guest
Posts: n/a
 
      10-20-2004
On Tue, 19 Oct 2004 23:52:10 +0900, trans. (T. Onoma)
<(E-Mail Removed)> wrote:
> Why do you avoid XSLT? Because it is slow? Or?


Well, the fact that XSLT is slow is one really annoying thing about
it. Another thing is that the syntax (XML!) is so cumbersome. As
others have pointed out the logic of a stylesheet for a nontrivial
transformation can be tricky, and the fact that XSLT syntax is so
messy makes an already difficult task harder than it should be.


 
Reply With Quote
 
James Britt
Guest
Posts: n/a
 
      10-20-2004
trans. (T. Onoma) wrote:
> On Tuesday 19 October 2004 04:22 pm, Florian Weber wrote:
> | On Oct 19, 2004, at 16:52 Uhr, trans. (T. Onoma) wrote:
> | > Nice. Thanks you for such a great reply! Very informative.
> | >
> | > Why do you avoid XSLT? Because it is slow? Or?
> |
> | you will run into tons of situations where xslt can't do what you
> | wanna do, because it's based on xml.. and when it's possible
> | you are either forced to duplicate code or using a even more
> | verbose way of expressing what you wanna do..
> |
> | well, and sooner or later its verbosity will also annoy the hell out of
> | you.
> |
> | personally i would never recommend anybody to use xslt if you
> | are not absolutely forced to or doing something very simple.
>
> That's too bad. So there is no _worthy_ standard declarative XML
> transformation language then? So much for standards. I will use Ruby. Thanks.


I find XSLT quite worthy in its own way. It is a functional language,
so you have to think in a different way to do looping and such. But for
most simple things it seems to be too much work, though. If, for
example, I want to take all foo elements and convert them to bar
elements, REXML shines. As might Regexp.

If I want to do conditional transformations based on element names and
attributes, REXML is simple. XSLT may be better for defining complex
templates and patterns, as I have a hard time setting up state tracking
past a certain level. But maybe that's just me.

An advantage to XSLT is that it is (presumably) portable. But I suspect
that once people have settled on a platform and programming language,
they are unlikely to switch down the line. (As an aside, how many
people have worked on projects where Java was selected because it was
"cross-platform", yet there was never any foreseeable need to jump
platforms, and indeed the development company had complete say over the
development and production platforms?)

I would like to see an XML transformation lib in Ruby that helped solve
most general cases, so that people would not have to rewrite essentially
the same code. REXSLT or something. But so far, in my work converting
between OOo XML and HTML, the Ruby code seems simple enough. But I've
not covered all transformation cases, and there have been times I
thought XSLT might have been easier.



James


>
> T.
>
>




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Including XSLT/XML document within a XSLT document dar_imiro@hotmail.com XML 4 12-13-2005 02:26 AM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
xslt alone or xslt/java for static site? ted XML 1 01-26-2004 10:41 AM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments