From: <dg...@su...> - 2009-01-19 14:04:56
|
Author: bellmich Date: Mon Jan 19 15:03:54 2009 New Revision: 167 URL: http://libwbxml.opensync.org/changeset/167 Log: added support for CDATA Modified: wbxmlTestSuite/trunk/normalize_xml.pl Modified: wbxmlTestSuite/trunk/normalize_xml.pl ============================================================================== --- wbxmlTestSuite/trunk/normalize_xml.pl Mon Jan 19 15:02:52 2009 (r166) +++ wbxmlTestSuite/trunk/normalize_xml.pl Mon Jan 19 15:03:54 2009 (r167) @@ -151,12 +151,19 @@ $char = substr($line, 0, 1); $line = substr($line, 1); if ($char eq "!") { - ## this should be a comment - $char = substr($line, 0, 2); - die "A comment must always start with '<!--' and not with '<!${char}'." - if ($char ne "--"); - $line = substr($line, 2); - $state = "COMMENT"; + if ($line =~ q{^--}) { + ## this should be a comment + $char = substr($line, 0, 2); + $line = substr($line, 2); + $state = "COMMENT"; + } elsif ($line =~ q{^\[CDATA\[}) { + ## CDATA section detected + $line =~ s{^\[CDATA\[}{}; + $state = "CDATA"; + } else { + die "Only comments and CDATA sections are supported and not with '<!${line}'." + if ($char ne "--"); + } } elsif ($char =~ q{[a-zA-Z]}) { ## this is an element for (my $i = 0; $i < $indent; $i++) { @@ -330,6 +337,17 @@ next; } + # handle CDATA + if ($state eq "CDATA" and $char eq "]" and substr($line , 0, 2) eq "]>") { + $line = substr($line, 2); + print $NEW_FD "]]>"; + $state = "NEUTRAL"; + next; + } + if ($state eq "CDATA") { + print $NEW_FD $char; + next; + } }; # close files |