Remove commented-out logging on each record modification.
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Record.pm
index 3369948..85d4653 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Record.pm,v 1.7 2006-07-24 15:25:51 mike Exp $
+# $Id: Record.pm,v 1.9 2006-07-24 17:01:46 mike Exp $
 
 package ZOOM::IRSpy::Record;
 
 
 package ZOOM::IRSpy::Record;
 
@@ -71,17 +71,22 @@ sub append_entry {
 
     my @nodes = $xc->findnodes($xpath);
     if (@nodes == 0) {
 
     my @nodes = $xc->findnodes($xpath);
     if (@nodes == 0) {
-       ZOOM::Log::log("irspy", "no matches for '$xpath': can't append");
-       return;
-    } elsif (@nodes > 1) {
-       ZOOM::Log::log("irspy", scalar(@nodes),
-                      " matches for '$xpath': using first");
+       # Make the node that we're inserting into, if possible.  A
+       # fully general version would work its way through each
+       # component of the XPath, but for now we just treat it as a
+       # single chunk to go inside the top-level node.
+       $this->_half_decent_appendWellBalancedChunk($root,
+                                                   "<$xpath></$xpath>");
+       @nodes = $xc->findnodes($xpath);
+       die("still no matches for '$xpath' after creating: can't append")
+           if @nodes == 0;
     }
 
     }
 
-    my $node = $nodes[0];
-    # $node ISA XML::LibXML::ElementXML::LibXML::Element
-    $this->_half_decent_appendWellBalancedChunk($node, $frag);
-    #print STDERR "POST: zeerex='$root' = \n", $root->toString(), "\n";
+    ZOOM::Log::log("irspy",
+                  scalar(@nodes), " matches for '$xpath': using first")
+       if @nodes > 1;
+
+    $this->_half_decent_appendWellBalancedChunk($nodes[0], $frag);
 }
 
 
 }
 
 
@@ -132,7 +137,7 @@ sub _half_decent_appendWellBalancedChunk {
     die "mismatched XML start/end <$open>...<$close>"
        if $close ne $tag;
     print STDERR "tag='$tag', attrs=[$attrs], content='$content'\n";
     die "mismatched XML start/end <$open>...<$close>"
        if $close ne $tag;
     print STDERR "tag='$tag', attrs=[$attrs], content='$content'\n";
-    die "### no code yet to make DOM node";
+    die "## no code yet to make DOM node";
 }
 
 
 }