common/tools/csvToSysDef.pl
changeset 961 94716c328941
parent 344 348670fc497a
child 976 50e351dfaafe
equal deleted inserted replaced
960:b0315c337be6 961:94716c328941
   151 
   151 
   152 	my $tagName = ref $tree;
   152 	my $tagName = ref $tree;
   153 	$tagName =~ s{^main::}{};
   153 	$tagName =~ s{^main::}{};
   154 	if ($tagName eq "Characters")
   154 	if ($tagName eq "Characters")
   155 	{
   155 	{
   156 		print $tree->{Text};
   156 		if ($tree->{Text} =~ m{[<>&]})
       
   157 		{
       
   158 			print "<![CDATA[$tree->{Text}]]>";
       
   159 		}
       
   160 		else
       
   161 		{
       
   162 			print $tree->{Text};
       
   163 		}
   157 		return;
   164 		return;
   158 	}
   165 	}
   159 	
   166 	
   160 	print "<$tagName";
   167 	print "<$tagName";
   161 
   168 
   170 		grep {
   177 		grep {
   171 			! ref $tree->{$_}
   178 			! ref $tree->{$_}
   172 		}
   179 		}
   173 		keys %$tree)
   180 		keys %$tree)
   174 	{
   181 	{
   175 		print " $attr=\"$tree->{$attr}\"";
   182 		my $value_escaped = $tree->{$attr};
       
   183 		$value_escaped =~ s/&/&amp;/g;
       
   184 		$value_escaped =~ s/</&lt;/g;
       
   185 		$value_escaped =~ s/>/&gt;/g;
       
   186 		print " $attr=\"$value_escaped\"";
   176 	}
   187 	}
   177 
   188 
   178 	my $children = $tree->{Kids};
   189 	my $children = $tree->{Kids};
   179 	if (scalar @$children)
   190 	if (scalar @$children)
   180 	{
   191 	{