0 Replies - 795 Views - Last Post: 23 September 2011 - 06:43 PM Rate Topic: -----

#1 Skaggles   User is offline

  • member icon

Reputation: 255
  • View blog
  • Posts: 641
  • Joined: 01-March 09

Is it possible to style XML that is generated using HAML and Sinatra?

Posted 23 September 2011 - 06:43 PM

Curious if what I'm trying to do is even possible. I was messing around with XSLT and was trying to output dynamic XML (using HAML) as styled HTML (using Sinatra web framework). However, when I access the page, I just get unformatted XML and the page title does not change. I've already checked if the path to the XSL file was correct, which it is. Perhaps, I'm just going about this wrong, or it's just not possible. Any thoughts?

Here is my HAML code for the XML document:
<?xml version='1.0' encoding='utf-8' ?>
<?xml-stylesheet type='text/xsl' href='/styles/application.xsl' ?>

%page([email protected])

Here is the XSLT code:
<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
    <xsl:output method='html' indent='no'/>
    <xsl:template match='page'>
        <html lang='en'>
                <title><xsl:value-of select='@name'/></title>
                <xsl:apply-templates select='content'/>

And, the Ruby code to serve the page:
get '/' do
    @title = 'Page Title'
    haml :index, :layout => :application

Is This A Good Question/Topic? 0
  • +

Page 1 of 1