--- loncom/homework/cleanxml/xml_to_loncapa.pm 2015/12/03 20:40:31 1.1 +++ loncom/homework/cleanxml/xml_to_loncapa.pm 2015/12/18 22:08:51 1.2 @@ -1,7 +1,7 @@ # The LearningOnline Network # convert_file takes a well-formed XML file content and converts it to LON-CAPA syntax. # -# $Id: xml_to_loncapa.pm,v 1.1 2015/12/03 20:40:31 damieng Exp $ +# $Id: xml_to_loncapa.pm,v 1.2 2015/12/18 22:08:51 damieng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -92,7 +92,7 @@ sub node_to_string { $s .= ' '; $s .= $attribute->nodeName; $s .= '="'; - $s .= escape($attribute->nodeValue); + $s .= escape_attribute($attribute->nodeValue); $s .= '"'; } if ($node->hasChildNodes()) { @@ -110,13 +110,14 @@ sub node_to_string { } } -# Escapes a string for LON-CAPA output (used for text nodes, not attribute values) -sub escape { +# Escapes an attribute value +sub escape_attribute { my ($s) = @_; - $s =~ s/&/&/sg; - $s =~ s//>/sg; - # quot and apos do not need to be escaped outside attribute values + # normal XML escapes do not work with LON-CAPA, for instance with reactionresponse + #$s =~ s/&/&/sg; + #$s =~ s//>/sg; + $s =~ s/"/"/sg; return $s; }