1 # $Id: Literal.pm 785 2009-07-16 14:17:46Z pajas $
3 # This is free software, you may use it and distribute it under the same terms as
6 # Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas
10 package XML::LibXML::Literal;
11 use XML::LibXML::Boolean;
12 use XML::LibXML::Number;
15 use vars qw ($VERSION);
16 $VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE
26 # $string =~ s/"/"/g;
27 # $string =~ s/'/'/g;
29 bless \$string, $class;
35 $string =~ s/'/'/g;
42 return "<Literal>$string</Literal>\n";
52 my ($cmp, $swap) = @_;
54 return $cmp cmp $$self;
56 return $$self cmp $cmp;
66 return (length($$self) > 0) ? XML::LibXML::Boolean->True : XML::LibXML::Boolean->False;
69 sub to_number { return XML::LibXML::Number->new($_[0]->value); }
70 sub to_literal { return $_[0]; }
72 sub string_value { return $_[0]->value; }
79 XML::LibXML::Literal - Simple string values.
83 In XPath terms a Literal is what we know as a string.
89 Create a new Literal object with the value in $string. Note that " and
90 ' will be converted to " and ' respectively. That is not part of the XPath
91 specification, but I consider it useful. Note though that you have to go
92 to extraordinary lengths in an XML template file (be it XSLT or whatever) to
95 <xsl:value-of select=""I'm feeling &quot;sad&quot;""/>
97 Which produces a Literal of:
103 Also overloaded as stringification, simply returns the literal string value.
107 Returns the equivalent of perl's cmp operator against the given $literal.