This is an automated email from the git hooks/post-receive script. js pushed a commit to tag 0.007 in repository libxml-saxon-xslt2-perl.
commit fc404f13c84a47886dd851cfe13c31887e6ba5f6 Author: Toby Inkster <m...@tobyinkster.co.uk> Date: Mon Jul 19 07:39:49 2010 +0000 XSLT2 support in XML-GRDDL; this needs XSLT-Saxon-XSLT2 to provide output media-type info, so a change to that dist too. --HG-- branch : XML-Saxon-XSLT2 extra : convert_revision : svn%3A3fe8e991-6959-4966-b76d-b07eca2b6e37/XML-Saxon-XSLT2%40426 --- Changes | 8 ++- Changes.ttl | 13 ++++- Changes.xml | 77 ---------------------------- META.yml | 2 +- Makefile.PL | 7 ++- README | 30 +++++++++++ XML-Saxon-XSLT2-0.003.tar.gz | Bin 0 -> 31643 bytes example1.pl | 20 ++++++-- lib/XML/Saxon/XSLT2.pm | 118 ++++++++++++++++++++++++++++++++++++++++--- 9 files changed, 182 insertions(+), 93 deletions(-) diff --git a/Changes b/Changes index e4fe031..72ca919 100644 --- a/Changes +++ b/Changes @@ -10,11 +10,15 @@ Home page: <http://search.cpan.org/dist/XML-Saxon-XSLT2/> Bug tracker: <http://rt.cpan.org/Dist/Display.html?Queue=XML-Saxon-XSLT2> Maintainer: Toby Inkster <mailto:toby...@cpan.org> +0.003 [2010-07-19] + - (Addition) Can determine <xsl:output> media-type, doctype-public, + doctype-system, encoding and version attributes. + 0.002 [2010-07-15] - - (Addition) Can specify a base URI in the constructor. - - (Addition) Can capture output from <xsl:message>. - No longer default to 'xml' output method, but respect XSLT's specified output method. + - (Addition) Can capture output from <xsl:message>. + - (Addition) Can specify a base URI in the constructor. 0.001 [2010-07-15] # Original version diff --git a/Changes.ttl b/Changes.ttl index 2325105..3619e55 100644 --- a/Changes.ttl +++ b/Changes.ttl @@ -41,6 +41,17 @@ my:v_0-002 dcs:item [ rdfs:label "No longer default to 'xml' output method, but respect XSLT's specified output method."@en ] ] . +my:v_0-003 + + a :Version ; + dc:issued "2010-07-19"^^xsd:date ; + :revision "0.003"^^xsd:string ; + :file-release <http://backpan.cpan.org/authors/id/T/TO/TOBYINK/XML-Saxon-XSLT2-0.003.tar.gz> ; + dcs:changeset [ + dcs:versus my:v_0-002 ; + dcs:item [ rdfs:label "Can determine <xsl:output> media-type, doctype-public, doctype-system, encoding and version attributes."@en ; a dcs:Addition ] + ] . + ############################################################# my:project @@ -59,7 +70,7 @@ my:project :tester toby:i ; :created "2010-07-14"^^xsd:date ; :license <http://dev.perl.org/licenses/> ; - :release my:v_0-001 , my:v_0-002 . + :release my:v_0-001 , my:v_0-002 , my:v_0-003 . ############################################################# diff --git a/Changes.xml b/Changes.xml index e4fbb4c..e69de29 100644 --- a/Changes.xml +++ b/Changes.xml @@ -1,77 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<rdf:RDF - xmlns:dc="http://purl.org/dc/terms/" - xmlns:dcs="http://ontologi.es/doap-changeset#" - xmlns:foaf="http://xmlns.com/foaf/0.1/" - xmlns:my="http://purl.org/NET/cpan-uri/dist/XML-Saxon-XSLT2/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" - xmlns:toby="http://tobyinkster.co.uk/#" - xmlns:xsd="http://www.w3.org/2001/XMLSchema#" - xmlns="http://usefulinc.com/ns/doap#"> - <rdf:Description rdf:about="file:///home/tai/src/perlmods/XML-Saxon-XSLT2/Changes.ttl"> - <dc:creator rdf:resource="http://tobyinkster.co.uk/#i"/> - <dc:description xml:lang="en">Revision history for Perl extension XML::Saxon::XSLT2.</dc:description> - <dc:subject rdf:resource="http://purl.org/NET/cpan-uri/dist/XML-Saxon-XSLT2/project"/> - <dc:title>Changes</dc:title> - </rdf:Description> - <Version rdf:about="http://purl.org/NET/cpan-uri/dist/XML-Saxon-XSLT2/v_0-001"> - <dc:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2010-07-15</dc:issued> - <file-release rdf:resource="http://backpan.cpan.org/authors/id/T/TO/TOBYINK/XML-Saxon-XSLT2-0.001.tar.gz"/> - <revision rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.001</revision> - <rdfs:label xml:lang="en">Original version</rdfs:label> - </Version> - <Version rdf:about="http://purl.org/NET/cpan-uri/dist/XML-Saxon-XSLT2/v_0-002"> - <dcs:changeset> - <rdf:Description> - <dcs:item> - <dcs:Addition> - <rdfs:label xml:lang="en">Can capture output from <xsl:message>.</rdfs:label> - </dcs:Addition> - </dcs:item> - <dcs:item> - <dcs:Addition> - <rdfs:label xml:lang="en">Can specify a base URI in the constructor.</rdfs:label> - </dcs:Addition> - </dcs:item> - <dcs:item> - <rdf:Description> - <rdfs:label xml:lang="en">No longer default to 'xml' output method, but respect XSLT's specified output method.</rdfs:label> - </rdf:Description> - </dcs:item> - <dcs:versus rdf:resource="http://purl.org/NET/cpan-uri/dist/XML-Saxon-XSLT2/v_0-001"/> - </rdf:Description> - </dcs:changeset> - <dc:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2010-07-15</dc:issued> - <file-release rdf:resource="http://backpan.cpan.org/authors/id/T/TO/TOBYINK/XML-Saxon-XSLT2-0.002.tar.gz"/> - <revision rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.002</revision> - </Version> - <Project rdf:about="http://purl.org/NET/cpan-uri/dist/XML-Saxon-XSLT2/project"> - <bug-database rdf:resource="http://rt.cpan.org/Dist/Display.html?Queue=XML-Saxon-XSLT2"/> - <created rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2010-07-14</created> - <developer rdf:resource="http://tobyinkster.co.uk/#i"/> - <documenter rdf:resource="http://tobyinkster.co.uk/#i"/> - <download-page rdf:resource="http://search.cpan.org/dist/XML-Saxon-XSLT2/"/> - <homepage rdf:resource="http://search.cpan.org/dist/XML-Saxon-XSLT2/"/> - <license rdf:resource="http://dev.perl.org/licenses/"/> - <maintainer rdf:resource="http://tobyinkster.co.uk/#i"/> - <name>XML-Saxon-XSLT2</name> - <programming-language>Perl</programming-language> - <release rdf:resource="http://purl.org/NET/cpan-uri/dist/XML-Saxon-XSLT2/v_0-001"/> - <release rdf:resource="http://purl.org/NET/cpan-uri/dist/XML-Saxon-XSLT2/v_0-002"/> - <repository> - <SVNRepository> - <browse rdf:resource="http://goddamn.co.uk/viewvc/perlmods/XML-Saxon-XSLT2/"/> - </SVNRepository> - </repository> - <shortdesc xml:lang="en">process XSLT 2.0 using Saxon 9.x</shortdesc> - <tester rdf:resource="http://tobyinkster.co.uk/#i"/> - </Project> - <foaf:Person rdf:about="http://tobyinkster.co.uk/#i"> - <ns1:sameAs xmlns:ns1="http://www.w3.org/2002/07/owl#" rdf:resource="http://purl.org/NET/cpan-uri/person/tobyink"/> - <foaf:homepage rdf:resource="http://tobyinkster.co.uk/"/> - <foaf:mbox rdf:resource="mailto:toby...@cpan.org"/> - <foaf:name>Toby Inkster</foaf:name> - <foaf:page rdf:resource="http://search.cpan.org/~tobyink/"/> - </foaf:Person> -</rdf:RDF> diff --git a/META.yml b/META.yml index 4eb471b..d112f04 100644 --- a/META.yml +++ b/META.yml @@ -31,4 +31,4 @@ resources: homepage: http://search.cpan.org/dist/XML-Saxon-XSLT2/ license: http://dev.perl.org/licenses/ repository: http://goddamn.co.uk/viewvc/perlmods/XML-Saxon-XSLT2/ -version: 0.002 +version: 0.003 diff --git a/Makefile.PL b/Makefile.PL index 72f0f2f..352411f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -3,9 +3,12 @@ use warnings; use inc::Module::Install; -unless (-e '/usr/share/java/saxon9he.jar' or -e '/usr/local/share/java/saxon9he.jar') +unless (-e '/usr/share/java/saxon9he.jar' + or -e '/usr/local/share/java/saxon9he.jar' + or -e '/usr/share/java/saxonb.jar' + or -e '/usr/local/share/java/saxonb.jar') { - warn "Need saxon9he.jar in /usr/share/java or /usr/local/share/java."; + warn "Need saxon9he.jar or saxonb.jar to be installed in /usr/share/java or /usr/local/share/java."; exit 0; } diff --git a/README b/README index ffab54b..48ecf33 100644 --- a/README +++ b/README @@ -70,6 +70,36 @@ DESCRIPTION Returns a list of string representations of messages output by <xsl:message> during the last transformation run. + "$trans->media_type($default)" + Returns the output media type for the transformation. + + If the transformation doesn't specify an output type, returns the + default. + + "$trans->doctype_public($default)" + Returns the output DOCTYPE public identifier for the transformation. + + If the transformation doesn't specify a doctype, returns the + default. + + "$trans->doctype_system($default)" + Returns the output DOCTYPE system identifier for the transformation. + + If the transformation doesn't specify a doctype, returns the + default. + + "$trans->version($default)" + Returns the output XML version for the transformation. + + If the transformation doesn't specify a version, returns the + default. + + "$trans->encoding($default)" + Returns the output encoding for the transformation. + + If the transformation doesn't specify an encoding, returns the + default. + BUGS Please report any bugs to <http://rt.cpan.org/>. diff --git a/XML-Saxon-XSLT2-0.003.tar.gz b/XML-Saxon-XSLT2-0.003.tar.gz new file mode 100644 index 0000000..58f5d81 Binary files /dev/null and b/XML-Saxon-XSLT2-0.003.tar.gz differ diff --git a/example1.pl b/example1.pl index c05e469..acbd689 100644 --- a/example1.pl +++ b/example1.pl @@ -1,5 +1,6 @@ #!/usr/bin/perl +use 5.010; use lib "lib"; use XML::Saxon::XSLT2; @@ -18,6 +19,7 @@ XML my $xslt = <<'XSLT'; <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> +<xsl:output media-type="text/foo+xml" version="1.1" encoding="ascii" doctype-system="foo.dtd" indent="yes" /> <xsl:param name="bar"/> <xsl:template match="/"> <xsl:variable name="allauthors"> @@ -33,6 +35,18 @@ my $xslt = <<'XSLT'; </xsl:stylesheet> XSLT -my $transformation = XML::Saxon::XSLT2->new($xslt); -$transformation->parameters('bar' => [date=>'2010-02-28']); -print $transformation->transform($xml) . "\n"; +eval { + my $transformation = XML::Saxon::XSLT2->new($xslt); + $transformation->parameters('bar' => [date=>'2010-02-28']); + say $transformation->transform($xml); + say $transformation->media_type('text/xml'); + say $transformation->doctype_public; + say $transformation->doctype_system; + say $transformation->version; + say $transformation->encoding; +}; +if ($@) +{ + my $msg = $@; + warn $msg->printStackTrace; +} \ No newline at end of file diff --git a/lib/XML/Saxon/XSLT2.pm b/lib/XML/Saxon/XSLT2.pm index f7f7034..870425d 100644 --- a/lib/XML/Saxon/XSLT2.pm +++ b/lib/XML/Saxon/XSLT2.pm @@ -8,12 +8,15 @@ use IO::Handle; use Scalar::Util qw[blessed]; use XML::LibXML; -our $VERSION = '0.002'; +our $VERSION = '0.003'; my $classpath; BEGIN { - foreach my $path (qw(/usr/share/java/saxon9he.jar /usr/local/share/java/saxon9he.jar)) + foreach my $path (qw(/usr/share/java/saxon9he.jar + /usr/local/share/java/saxon9he.jar + /usr/share/java/saxonb.jar + /usr/local/share/java/saxonb.jar)) { $classpath = $path if -e $path; } @@ -87,7 +90,7 @@ sub parameters sub transform { my ($self, $doc, $type) = @_; - $type = ($type =~ /^(text|html|xhtml|xml)$/i) ? (lc $type) : ''; + $type = ($type =~ /^(text|html|xhtml|xml)$/i) ? (lc $type) : 'default'; $doc = $self->_xml($doc); return $self->{'transformer'}->transform($doc, $type); } @@ -103,10 +106,40 @@ sub transform_document sub messages { - my $self = shift; + my ($self) = @_; return @{ $self->{'transformer'}->messages }; } +sub media_type +{ + my ($self, $default) = @_; + return $self->{'transformer'}->media_type || $default; +} + +sub doctype_public +{ + my ($self, $default) = @_; + return $self->{'transformer'}->doctype_public || $default; +} + +sub doctype_system +{ + my ($self, $default) = @_; + return $self->{'transformer'}->doctype_system || $default; +} + +sub version +{ + my ($self, $default) = @_; + return $self->{'transformer'}->version || $default; +} + +sub encoding +{ + my ($self, $default) = @_; + return $self->{'transformer'}->encoding || $default; +} + sub _xml { my ($proto, $xml) = @_; @@ -218,6 +251,36 @@ This method is slower than C<transform>. Returns a list of string representations of messages output by E<lt>xsl:messageE<gt> during the last transformation run. +=item C<< $trans->media_type($default) >> + +Returns the output media type for the transformation. + +If the transformation doesn't specify an output type, returns the default. + +=item C<< $trans->doctype_public($default) >> + +Returns the output DOCTYPE public identifier for the transformation. + +If the transformation doesn't specify a doctype, returns the default. + +=item C<< $trans->doctype_system($default) >> + +Returns the output DOCTYPE system identifier for the transformation. + +If the transformation doesn't specify a doctype, returns the default. + +=item C<< $trans->version($default) >> + +Returns the output XML version for the transformation. + +If the transformation doesn't specify a version, returns the default. + +=item C<< $trans->encoding($default) >> + +Returns the output encoding for the transformation. + +If the transformation doesn't specify an encoding, returns the default. + =back =head1 BUGS @@ -265,6 +328,7 @@ import javax.xml.transform.SourceLocator; import javax.xml.transform.TransformerException; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; +import javax.xml.transform.OutputKeys; import java.io.*; import java.math.BigDecimal; import java.net.URI; @@ -373,6 +437,46 @@ public class Transformer { return messagelist.toArray(); } + + public String media_type () + { + return xslt.getUnderlyingCompiledStylesheet().getOutputProperties().getProperty(OutputKeys.MEDIA_TYPE); + } + + public String doctype_public () + { + return xslt.getUnderlyingCompiledStylesheet().getOutputProperties().getProperty(OutputKeys.DOCTYPE_PUBLIC); + } + + public String doctype_system () + { + return xslt.getUnderlyingCompiledStylesheet().getOutputProperties().getProperty(OutputKeys.DOCTYPE_SYSTEM); + } + + public String method () + { + return xslt.getUnderlyingCompiledStylesheet().getOutputProperties().getProperty(OutputKeys.METHOD); + } + + public String version () + { + return xslt.getUnderlyingCompiledStylesheet().getOutputProperties().getProperty(OutputKeys.VERSION); + } + + public String standalone () + { + return xslt.getUnderlyingCompiledStylesheet().getOutputProperties().getProperty(OutputKeys.STANDALONE); + } + + public String encoding () + { + return xslt.getUnderlyingCompiledStylesheet().getOutputProperties().getProperty(OutputKeys.ENCODING); + } + + public String indent () + { + return xslt.getUnderlyingCompiledStylesheet().getOutputProperties().getProperty(OutputKeys.INDENT); + } public String transform (String doc, String method) throws SaxonApiException @@ -389,7 +493,7 @@ public class Transformer out.setOutputWriter(sw); trans.setDestination(out); - if (method != "") + if (!method.equals("default")) { out.setOutputProperty(Serializer.Property.METHOD, method); } @@ -411,9 +515,9 @@ public class Transformer } } ); - - trans.transform(); + trans.transform(); + return sw.toString(); } } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libxml-saxon-xslt2-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits