[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby / XSLT

Ronald E Jeffries

4/30/2006 11:34:00 PM

My reading of the list suggests to me that there isn't a very good Ruby/XSLT
hookup for Windows. I've been wanting to get a bit more test-driven in my web
site generation, which has a little Ruby in it, and a lot of XSLT.

Recent article on XProgramming, "Grotesque Hackery" describes my dilemma.
(There's also an odd little Ruby thing that a few folks here have noticed.) I'm
taking heat from the XP list and the TDD list saying that just because it's
impossible to test XSL very well, it's no reason not to do it, so I'm looking
for a good way to go.

I gather that there's probably a way to run XALAN under Ruby, and that suggests
to me that with some support classes I might be able to build something up that
was at least semi-convenient for writing a little snippet of XSL, using XALAN to
run it against a little XML, and checking the output. I had hoped for something
a bit more integrated.

Advice welcome. Thanks,

--
Ron Jeffries
www.XProgramming.com
I'm giving the best advice I have. You get to decide if it's true for you.
6 Answers

Ross Bamford

4/30/2006 11:54:00 PM

0

Hi Ron,

On Mon, 01 May 2006 00:33:36 +0100, Ron Jeffries <ronjeffries@acm.org>
wrote:

> My reading of the list suggests to me that there isn't a very good
> Ruby/XSLT
> hookup for Windows. I've been wanting to get a bit more test-driven in
> my web
> site generation, which has a little Ruby in it, and a lot of XSLT.
>
> Recent article on XProgramming, "Grotesque Hackery" describes my dilemma.
> (There's also an odd little Ruby thing that a few folks here have
> noticed.) I'm
> taking heat from the XP list and the TDD list saying that just because
> it's
> impossible to test XSL very well, it's no reason not to do it, so I'm
> looking
> for a good way to go.
>
> I gather that there's probably a way to run XALAN under Ruby, and that
> suggests
> to me that with some support classes I might be able to build something
> up that
> was at least semi-convenient for writing a little snippet of XSL, using
> XALAN to
> run it against a little XML, and checking the output. I had hoped for
> something
> a bit more integrated.
>
> Advice welcome. Thanks,
>

I don't know about Xalan (though I'm sure you're right that there's a way)
but I do need to do my standard libxml(/xsl) plug here - take a look at
http://libxsl.rub... - maybe it can make things easier...

(By all accounts both libxml-ruby and libxsl-ruby are fine on Windows).

--
Ross Bamford - rosco@roscopeco.remove.co.uk

Ronald E Jeffries

5/1/2006 1:45:00 PM

0

On Mon, 01 May 2006 00:54:18 +0100, "Ross Bamford"
<rosco@roscopeco.remove.co.uk> wrote:

>I don't know about Xalan (though I'm sure you're right that there's a way)
>but I do need to do my standard libxml(/xsl) plug here - take a look at
>http://libxsl.rub... - maybe it can make things easier...
>
>(By all accounts both libxml-ruby and libxsl-ruby are fine on Windows).

Thanks, Ross. I had seen the strings libxsl and libxml before. Is there anything
that a person wanting to use these libraries would recognize as documentation? I
mean things like "here's a sample XSL and XML and here's how to put them into
your Ruby code, and here's how to get the transform done, and here's how to get
the transformed document back out?

The documentation provided by rdoc is essentially random-access, and so far i
see no examples.

My rough understanding is that I ...

Create an XSLT instance, which knows both a stylesheet and a document to be
styled.

send parse to the xslt instance, getting a stylesheet attached to the document.
(But why isn't the XSLT instance already one of these? But oh well.)

send apply to the stylesheet. it returns a boolean. means success? or what?

send print or save to the stylesheet, which, rather than printing or saving the
stylesheet (?) prints or saves the transformed document.

Is that about it? Is there an example somewhere?

Then all I'd have to do is figure out how to install it ... or is it in the 1.8
distro already perhaps? ... apparently not, but I can probably work that out.

Thanks,

--
Ron Jeffries
www.XProgramming.com
I'm giving the best advice I have. You get to decide if it's true for you.

Ross Bamford

5/1/2006 5:52:00 PM

0

On Mon, 01 May 2006 14:45:14 +0100, Ron Jeffries <ronjeffries@acm.org>
wrote:

> On Mon, 01 May 2006 00:54:18 +0100, "Ross Bamford"
> <rosco@roscopeco.remove.co.uk> wrote:
>
>> I don't know about Xalan (though I'm sure you're right that there's a
>> way)
>> but I do need to do my standard libxml(/xsl) plug here - take a look at
>> http://libxsl.rub... - maybe it can make things easier...
>>
>> (By all accounts both libxml-ruby and libxsl-ruby are fine on Windows).
>
> Thanks, Ross. I had seen the strings libxsl and libxml before. Is there
> anything
> that a person wanting to use these libraries would recognize as
> documentation? I
> mean things like "here's a sample XSL and XML and here's how to put them
> into
> your Ruby code, and here's how to get the transform done, and here's how
> to get
> the transformed document back out?
>
> The documentation provided by rdoc is essentially random-access, and so
> far i
> see no examples.
>

Yes, I'm afraid we're lacking somewhat in documentation right now. Both
this project and libxml-ruby have been unmaintained for a while but we're
now working on improving the code and documentation as time allows. I take
your point about the lack of an example though, and I've just updated the
docs online with a short example taken from the tests (in the readme at
http://libxsl.rub...).

> My rough understanding is that I ...
>
> Create an XSLT instance, which knows both a stylesheet and a document to
> be
> styled.
>
> send parse to the xslt instance, getting a stylesheet attached to the
> document.
> (But why isn't the XSLT instance already one of these? But oh well.)
>
> send apply to the stylesheet. it returns a boolean. means success? or
> what?
>
> send print or save to the stylesheet, which, rather than printing or
> saving the
> stylesheet (?) prints or saves the transformed document.
>
> Is that about it? Is there an example somewhere?
>

That's about the size of it, yes. I'm not much an XSL expert to be honest,
but my understanding is that the XSLT instance is an XSL Transform, which
combines an XSL with a source document to create a stylesheet, which you
then apply to produce the output.

> Then all I'd have to do is figure out how to install it ... or is it in
> the 1.8
> distro already perhaps? ... apparently not, but I can probably work that
> out.
>

It's not in the standard library, but it should be fairly easy to install
if you have rubygems:

gem install libxsl-ruby

This should auto-install libxml-ruby, too. If you don't have gems, there's
an easy-to-use rake wrapper for the build in the tarball.

However, You will need libxml and libxslt installed before installing the
ruby stuff - I'm afraid I can't vouch personally for the Windows binary
releases but they seem like the quickest option:

http://www.zlatkovic.com/libx...

Hope that helps,
--
Ross Bamford - rosco@roscopeco.remove.co.uk

Ronald E Jeffries

5/2/2006 2:04:00 AM

0

On Mon, 01 May 2006 18:52:25 +0100, "Ross Bamford"
<rosco@roscopeco.remove.co.uk> wrote:

>Yes, I'm afraid we're lacking somewhat in documentation right now. Both
>this project and libxml-ruby have been unmaintained for a while but we're
>now working on improving the code and documentation as time allows. I take
>your point about the lack of an example though, and I've just updated the
>docs online with a short example taken from the tests (in the readme at
>http://libxsl.rub...).

Thanks, Ross. I'll check it out. Looks like libxsl may be a good way to go. Is
it a pretty complete XSLT, then?

Thanks again,

--
Ron Jeffries
www.XProgramming.com
I'm giving the best advice I have. You get to decide if it's true for you.

Ross Bamford

5/2/2006 2:36:00 PM

0

On Tue, 02 May 2006 03:03:51 +0100, Ron Jeffries <ronjeffries@acm.org>
wrote:
>
> Looks like libxsl may be a good way to go. Is
> it a pretty complete XSLT, then?
>

I believe it's a complete implementation of XSLT-1.0, though I'm not
absolutely sure on that. It handles everything I've thrown at it so far
(admittedly nothing too taxing, but still...).

--
Ross Bamford - rosco@roscopeco.remove.co.uk

Ronald E Jeffries

5/3/2006 3:07:00 AM

0

On Tue, 02 May 2006 15:36:09 +0100, "Ross Bamford"
<rosco@roscopeco.remove.co.uk> wrote:

>I believe it's a complete implementation of XSLT-1.0, though I'm not
>absolutely sure on that. It handles everything I've thrown at it so far
>(admittedly nothing too taxing, but still...).

Thanks! I'll see if I can get it working!

--
Ron Jeffries
www.XProgramming.com
I'm giving the best advice I have. You get to decide if it's true for you.