version 1.1, 2015/12/03 20:40:31
|
version 1.3, 2015/12/23 20:33:10
|
Line 92 sub node_to_string {
|
Line 92 sub node_to_string {
|
$s .= ' '; |
$s .= ' '; |
$s .= $attribute->nodeName; |
$s .= $attribute->nodeName; |
$s .= '="'; |
$s .= '="'; |
$s .= escape($attribute->nodeValue); |
$s .= escape_attribute($attribute->nodeValue); |
$s .= '"'; |
$s .= '"'; |
} |
} |
if ($node->hasChildNodes()) { |
if ($node->hasChildNodes() || $tag eq 'script') { |
$s .= '>'; |
$s .= '>'; |
foreach my $child ($node->childNodes) { |
foreach my $child ($node->childNodes) { |
$s .= node_to_string($child); |
$s .= node_to_string($child); |
Line 110 sub node_to_string {
|
Line 110 sub node_to_string {
|
} |
} |
} |
} |
|
|
# Escapes a string for LON-CAPA output (used for text nodes, not attribute values) |
# Escapes an attribute value |
sub escape { |
sub escape_attribute { |
my ($s) = @_; |
my ($s) = @_; |
$s =~ s/&/&/sg; |
# normal XML escapes do not work with LON-CAPA, for instance with reactionresponse |
$s =~ s/</</sg; |
#$s =~ s/&/&/sg; |
$s =~ s/>/>/sg; |
#$s =~ s/</</sg; |
# quot and apos do not need to be escaped outside attribute values |
#$s =~ s/>/>/sg; |
|
$s =~ s/"/"/sg; |
return $s; |
return $s; |
} |
} |
|
|