[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

[PATCH] Another update to DTD to XML Scheme tool

  • From: Chris Meyer <cmeyer@g...>
  • To: xml-dev@l...
  • Date: Fri, 24 Aug 2001 12:08:17 -0700

xml scheme
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.
  #

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.