Shlomi Fish avatar Shlomi Fish committed e668039

Add more.

Comments (0)

Files changed (3)

XML-GrammarBase/Changes

 Revision history for XML-GrammarBase
 
+0.1.0    Thu  3 Jan 13:33:10 IST 2013
+         Add the 'encoding' parameter for output_as_chars() vs.
+         output_as_bytes().
+
 0.0.3    Sat 29 Dec 22:26:34 IST 2012
          Change a wrong synopsis - it was "use Any::Moose;" instead of
          "use MooX 'late';".

XML-GrammarBase/lib/XML/GrammarBase/Role/XSLT.pm

 L<XML::LibXML> DOM object. If it is a hash ref then it specifies a
 C<'file'> or a C<'fh'> with a filepath or filehandle respectively.
 
+An optional C<'encoding'> parameter determines if one should output the string
+as C<'utf8'> (the deafult - using L<XML::LibXSLT>'s
+output_as_chars()) or as C<'bytes'> - using its output_as_bytes() .
+
 =cut
 
 =head2 BUILD

XML-GrammarBase/lib/XML/GrammarBase/Role/XSLT/Global.pm

     my ($self, $args) = @_;
 
     my $output_format = $args->{output_format};
+    my $encoding = ($args->{encoding} || 'utf8');
+
     my $source_dom = $self->_get_dom_from_source($args);
 
     my $stylesheet_method = "_to_${output_format}_stylesheet";
         return
             $is_dom
             ? $results
-            : $stylesheet->output_string($results)
+            : ($encoding eq 'bytes')
+            ? $stylesheet->output_as_bytes($results)
+            : $stylesheet->output_as_chars($results)
             ;
     }
     elsif (ref($medium) eq 'HASH')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.