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

#1 Skaggles  Icon User is offline

  • THE PEN IS MIGHTIER
  • member icon





Reputation: 251
  • View blog
  • Posts: 640
  • 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(name=@title)
    %content
        =yield



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'>
            <head>
                <title><xsl:value-of select='@name'/></title>
            </head>
            <body>
                <xsl:apply-templates select='content'/>
            </body>
        </html>
        
    </xsl:template>
</xsl:stylesheet>



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



Is This A Good Question/Topic? 0
  • +

Page 1 of 1