/[suikacvs]/test/html-webhacc/mkdescription.pl
Suika

Diff of /test/html-webhacc/mkdescription.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by wakaba, Sat Aug 16 13:09:08 2008 UTC revision 1.7 by wakaba, Fri Aug 22 13:08:12 2008 UTC
# Line 26  my $doc; Line 26  my $doc;
26  my $target_lang = shift || 'en';  my $target_lang = shift || 'en';
27    
28  my @node = (@{$doc->child_nodes});  my @node = (@{$doc->child_nodes});
29    my $title;
30    my $title_parent;
31  while (@node) {  while (@node) {
32    my $node = shift @node;    my $node = shift @node;
33    if ($node->node_type == $node->ELEMENT_NODE) {    if ($node->node_type == $node->ELEMENT_NODE) {
34      if ($node->namespace_uri eq $HTML_NS) {      if ($node->namespace_uri eq $HTML_NS) {
35        if ($node->manakai_local_name eq 'title') {        if ($node->manakai_local_name eq 'title') {
36          unless ($node->get_attribute_ns ($XML_NS, 'lang') eq $target_lang) {          $title_parent = $node->parent_node;
37            if ($node->get_attribute_ns ($XML_NS, 'lang') eq $target_lang) {
38              $title = $node;
39            } else {
40              $title ||= $node;
41            $node->parent_node->remove_child ($node);            $node->parent_node->remove_child ($node);
42          }          }
43        } else {        } else {
# Line 103  while (@node) { Line 109  while (@node) {
109    }    }
110  }  }
111  $doc->document_element->set_attribute_ns (undef, lang => $target_lang);  $doc->document_element->set_attribute_ns (undef, lang => $target_lang);
112    $title_parent->append_child ($title) if $title;
113    
114  print $doc->inner_html;  print $doc->inner_html;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24