OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Another update to DTD to XML Scheme tool



I don't know if anyone's using dtd2xsd.pl anymore, but these changes 
allow it to make it through the docbook 4.1.2 DTD without crashing 
and including modules properly. No guarantees beyond that :) Little 
testing has been done beyond the docbook so someone "in the know" 
might want to review the changes below.

The main changes are:

- openFile substitution now done using a temporary variable; this 
avoids a malloc bug I was getting in Perl.

- IGNORE/INCLUDE entities are now done in openFile (so they work in 
included modules).

Here's a udiff from the 1.17 version current on w3c.

--- dtd2xsd.pl  Thu Jan 18 21:59:15 2001
+++ dtd2xsd_new.pl      Thu Aug 23 11:13:22 2001
@@ -196,10 +196,6 @@
          $buf =~ s/%([a-zA-Z0-9_\.-]+);?/$i++,$pent{$1}/gse;
  } while ($i != 0);

-# treat conditional sections
-while($buf =~ s/<!\[\s*?INCLUDE\s*?\[(.*)\]\]>/\1/gsie) {};
-while($buf =~ s/<!\[\s*?IGNORE\s*?\[.*\]\]>//gsie) {};
-
  # store attribute lists
  $buf =~ s/<!ATTLIST\s+(\S+)\s+(.*?)>/store_att($1, $2)/gsie;

@@ -796,6 +792,10 @@
          # remove processing instructions
          $bufbuf =~ s/<\?.*?>//gso;

+# treat conditional sections
+while($bufbuf =~ s/<!\[\s*?INCLUDE\s*?\[(.*)\]\]>/$1/gsie) {};
+while($bufbuf =~ s/<!\[\s*?IGNORE\s*?\[.*\]\]>//gsie) {};
+
          # store external parameter entities
          while ($bufbuf =~ 
s/<!ENTITY\s+%\s+(\S+)\s+PUBLIC\s+$str\s+$str.*?>//sie) {
                   $extent{$1} = $4.$5;
@@ -806,13 +806,19 @@

          # read external entity files
          foreach my $key (keys(%extent)) {
-                 $bufbuf =~ s/%$key;/openFile($extent{$key})/gsie;
+       my $subst = openFile($extent{$key});
+                 $bufbuf =~ s/%$key;/$subst/gsie;
          }

          return $bufbuf;
  }

  # $Log: dtd2xsd.pl,v $
+#
+# 2001/08/23 cmeyer
+# include/ignore entities are now treated recursively
+# changed module substitution to be a little more friendly (was 
getting malloc errors)
+#
  # Revision 1.17  2001/01/19 05:59:12  connolly
  # more changelog stuff; link to MH's announcement etc.
  #