Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

In trying to test some XSLT code I've been working on, I'm trying to produce valid XHTML and use Test::XML to verify the results. Unfortunately, XML::LibXSLT appears to be generating an unclosed meta tag for the HTML content type. Even if I include my own meta tag, it's removing mine and substituting the invalid one.

As a workaround, I've stripped the meta tag from the resulting HTML and used is_xml() in my test, but I'd much rather have my code produce a valid meta tag. A minimal test case is below with my output in the __DATA__ section. Does anyone get valid XHTML results? If so, I'm running this on OS X. xslt-config returns 1.1.11.

#!/usr/bin/perl use strict; use warnings; use XML::LibXML; use XML::LibXSLT; my $parser = XML::LibXML->new; my $doc = $parser->parse_string(_xml()); my $style_doc = $parser->parse_string(_stylesheet()); my $xslt = XML::LibXSLT->new; my $sheet = $xslt->parse_stylesheet($style_doc); my $html = $sheet->transform($doc); print $sheet->output_string($html); sub _xml { return <<' END_XML'; <?xml version="1.0"?> <resources> <description>Available instances</description> <resource id="foo"/> <resource id="bar"/> <resource id="bar"/> </resources> END_XML } sub _stylesheet { return <<' END_STYLE_SHEET'; <xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:fo=""> <xsl:template match="/"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UT +F-8"/> <title><xsl:value-of select="/resources/description" /></title +> </head> <body> <table> <xsl:for-each select="resources"> <xsl:apply-templates select="./resource" /> </xsl:for-each> </table> </body> </html> </xsl:template> <xsl:template match="resource"> <tr> <td> <xsl:value-of select="@id" /> </td> </tr> </xsl:template> </xsl:stylesheet> END_STYLE_SHEET } __DATA__ <html xmlns:fo=""> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Available instances</title> </head> <body><table> <tr><td>foo</td></tr> <tr><td>bar</td></tr> <tr><td>bar</td></tr> </table></body> </html>


New address of my CGI Course.

In reply to XML::LibXSLT generates invalid XHTML by Ovid

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (3)
    As of 2020-12-05 14:56 GMT
    Find Nodes?
      Voting Booth?
      How often do you use taint mode?

      Results (64 votes). Check out past polls.