1. Shlomi Fish
  2. perl-XML-LibXML

Commits

ma...@9ae0c189-cd1f-4510-a509-f4891f5cf20d  committed 57077c7

Added new files to MANIFEST
Updated Changes to 1.00
Fixed findvalue() to use find() instead of findnodes()
Documented find, findvalue and updated findnodes docs

  • Participants
  • Parent commits 60e23e3
  • Branches default

Comments (0)

Files changed (4)

File Changes

View file
  • Ignore whitespace
 Revision history for Perl extension XML::LibXSLT.
 
+1.00
+    - Added SAX serialisation
+    - Added a SAX builder module
+    - Fixed findnodes in scalar context to return a NodeList object
+    - Added findvalue($xpath)
+    - Added find(), which returns different things depending on the XPath
+    - Added Boolean, Number and Literal data types
+
+0.99
+    - Added support for $doc->URI getter/setter
+
 0.98
     - New have_library implementation
 

File LibXML.pm

View file
  • Ignore whitespace
 
 sub XML::LibXML::Node::findvalue {
     my ($node, $xpath) = @_;
-    return $node->findnodes($xpath)->to_literal->value;
+    return $node->find($xpath)->to_literal->value;
 }
 
 sub XML::LibXML::Node::find {

File MANIFEST

View file
  • Ignore whitespace
 t/11memory.t
 t/12html.t
 t/13dtd.t
+t/14sax.t
+t/15nodelist.t
 lib/XML/LibXML/Attr.pod
 lib/XML/LibXML/Comment.pod
 lib/XML/LibXML/Dtd.pod
 lib/XML/LibXML/Literal.pm
 lib/XML/LibXML/Boolean.pm
 lib/XML/LibXML/Number.pm
+lib/XML/LibXML/SAX/Generator.pm
+lib/XML/LibXML/SAX/Builder.pm

File example/libxml.xml

View file
  • Ignore whitespace
 <method name="findnodes" 
     synopsis="@nodes = $node->findnodes( $xpath_statement );">
 	<b>findnodes</b> performs the xpath statement on the current node and 
-	returns the result as an array. 
+	returns the result as an array. In scalar context returns a
+	<i>XML::LibXML::NodeList</i> object.
+</method>
+
+<method name="find"
+    synopsis="$result = $node->find( $xpath );">
+        <b>find</b> performs the xpath expression using the current
+        node as the context of the expression, and returns the result
+        depending on what type of result the XPath expression had. For
+        example, the XPath "1 * 3 + 52" results in a
+        <i>XML::LibXML::Number</i> object being returned. Other
+        expressions might return a <i>XML::LibXML::Boolean</i> object,
+        or a <i>XML::LibXML::Literal</i> object (a string). Each of
+        those objects uses Perl's overload feature to "do the right thing"
+        in different contexts.
+</method>
+
+<method name="findvalue"
+    synopsis="print $node->findvalue( $xpath );">
+        <b>findvalue</b> is exactly equivalent to:
+<example>
+$node->find( $xpath )->to_literal;
+</example>
+        That is, it returns the literal value of the results. This enables
+        you to ensure that you get a string back from your search, allowing
+        certain shortcuts. This could be used as the equivalent of
+        &lt;xsl:value-of select="some_xpath"/>.
 </method>
 
 <method name="getChildnodes" synopsis="@children = $node->getChildnodes();">