title: Perl Error while performing xslt transformation
body: <p>I am trying to perform a simple xml transformation using XSLT 1.0.
  Here are my xml and xslt files.</p>
  
  <p><strong>XML File</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?xml-stylesheet type="xsl" href="trans.xsl"?&gt;
  &lt;Article&gt;
    &lt;Title&gt;My Article&lt;/Title&gt;
    &lt;Authors&gt;
      &lt;Author&gt;Mr. Foo&lt;/Author&gt;
      &lt;Author&gt;Mr. Bar&lt;/Author&gt;
    &lt;/Authors&gt;
    &lt;Body&gt;This is my article text.&lt;/Body&gt;
  &lt;/Article&gt;
  </code></pre>
  
  <p><strong>XSLT File</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;    
    &lt;xsl:output method="text"/&gt;    
    &lt;xsl:template match="/"&gt;
      Article - &lt;xsl:value-of select="/Article/Title"/&gt;
      Authors: &lt;xsl:apply-templates select="/Article/Authors/Author"/&gt;
    &lt;/xsl:template&gt;    
    &lt;xsl:template match="Author"&gt;
      - &lt;xsl:value-of select="." /&gt;
    &lt;/xsl:template&gt;    
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>And here is my perl script that I am using.</p>
  
  <pre><code>use strict;
  use warnings;
  use Getopt::Std;
  use File::Path;
  use File::Spec;
  use File::Basename;
  use Env;
  use XML::LibXSLT;
  use XML::LibXML;
  
  my %opts = ();
  getopts('p:f:'\%opts);
  
  my $xsltfile = $opts{'p'};
  die "XSLT file not specified" if !defined($xsltfile);
  
  my $xmlfile = $opts{'f'};
  die "XML file not specified" if !defined($xmlfile);
  
  # XSLT Transformation code starts here
  
  #my $xml_parser = XML::LibXML-&gt;new();
  #my $source = $xml_parser-&gt;parse_file($msgcatfile);
  
  my $source = XML::LibXML-&gt;load_xml(location =&gt; $xmlfile);
  
  #my $xslt_parser = XML::LibXML-&gt;new();
  #my $xslt_source = $xslt_parser-&gt;parse_file($xsltfile);
  
  my $xslt_source = XML::LibXML-&gt;load_xml(location =&gt; $xsltfile);    
  my $xslt = XML::LibXSLT-&gt;new();
  
  my $stylesheet;
  
  eval { $stylesheet = $xslt-&gt;parse_stylesheet($xslt_source); };
  
  if ($@)
  {
      print "$@";
      die "\n!******************Error in parsing the stylesheet file : $xsltfile ************************!\n";
  }
  
  eval { my $results = $stylesheet-&gt;transform_file($source); };
  
  if ($@)
  {
      print "$@";
      die "\n!******************Error in transforming the input xml file : $source ************************!\n";
  }
  print $stylesheet-&gt;output_as_bytes($results);
  0;
  </code></pre>
  
  <p>I am not sure what is going wrong but when run this perl script, I am getting following errors which I am not able decipher.</p>
  
  <pre><code>Bareword found where operator expected at trans.xslt line 2, near ""1.0" xmlns"
          (Missing operator before xmlns?)
  Bareword found where operator expected at trans.xslt line 11, near "&lt;/xsl"
    (Might be a runaway multi-line // string starting on line 10)
          (Missing operator before l?)
  syntax error at trans.xslt line 2, near "xsl:"
  Execution of trans.xslt aborted due to compilation errors.
  </code></pre>
  
  <p>I could not find any similar posts (relevant to XML/XSLT) when I searched for keywords in the error message. 
  Am I missing something obvious?</p>
  
  <p><strong>:UPDATE:</strong></p>
  
  <p>I ran my program as </p>
  
  <p><code>perl transform.pl -p trans.xslt -f example.xml</code></p>