blog.pl:
use XML::XSLT; use LWP::Simple; use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; my $xsl = get("blog2.xsl") my $xslt = XML::XSLT->new ($xsl, warnings => 1, base => "/home/bosshof +f/www/blog/"); my $xml = get("posts.xml") $xslt->transform ($xml); print $xslt->toString; $xslt->dispose();
blog2.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Tr +ansform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:output method="xml" indent="yes" encoding="UTF-8"/> <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/> <xsl:output doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-tra +nsitional.dtd"/> <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>test</title> <style type="text/css"> @import url("main.css"); </style> </head> <body> <xsl:call-template name="topMenu"/> </body> </html> </xsl:template> <xsl:template name="topMenu"> <div id="topMenu"> <xsl:for-each select="document('menu.xml')/menu/item"> <span class="topMenu"> <xsl:element name="a"> <xsl:attribute name="href"><xsl:value-of select="href"/></ +xsl:attribute> <xsl:value-of select="name"/> </xsl:element> </span> </xsl:for-each> </div> </xsl:template> </xsl:stylesheet>
posts.xml:
<?xml version="1.0" encoding="UTF-8"?> <posts> <post title="Setting Up Gentoo" date="2005-2-24" id="1"> <para firstLetter="T">he kernel I'll be going with is 2.6.10-gentoo-r6 +, which is the most recent gentoo-enhanced version of the kernel to d +ate. The stage I've chosen to start from is a Stage 2 install: basic +ally, all the low-level system stuff is already provided, which I wou +ld need anyway. No, I'm not yet nuts enough to do a Stage 1. If you + are confused about what I'm talking about, please go to <url>http:// +www.gentoo.org/doc/en/handbook/handbook-x86.xml</url>. That is the g +uide I used to install my system.</para> <para>Though this server will mostly be used for server operations, I +would like a window manager to make rooting through configurations ea +sier. I chose fluxbox (<url>http://fluxbox.sourceforge.net/</url>) f +or its very small overhead, unlike KDE or Gnome, which insist on inst +alling a bunch of stuff I won't need (including all that lame GUI con +fig crap).</para> </post> </posts>
menu.xml:
<?xml version="1.0" encoding="UTF-8"?> <menu> <item> <name>Home</name> <href>http://pansy/main.xhtml</href> </item> <item> <name>Somewhere else</name> <href>#</href> </item> </menu>
It won't work unless you comment out the document command and take out the base argument when instantiating the XML::XSLT object.

In reply to Re^2: XML::XSLT 'base' parameter by bosshoff
in thread XML::XSLT 'base' parameter by bosshoff

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.