How can I parse DTD files?

S

Sherif ElMetainy

Hello
I am developing a WAP application, in which I want to process some xml
documents like the one below.

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE si PUBLIC "-//WAPFORUM//DTD SI 1.0//EN"
"http://www.wapforum.org/DTD/si.dtd">
<si><indication href="http://www.example.com/example.wml"
action="signal-medium" created="2004-03-21T00:00:00Z"
si-expires="2004-04-21T00:00:00Z">
Test Description</indication>
</si>

System.Xml classes can parse the documents without a problem. .NET framework
reads the dtd document in the <!DOCTYPE > declaration and uses it for
validation. But there is I can't access the data in the dtd parsed by the
framework. I am looking for <!ATTLIST > declaration in dtd, like the one
below, because I want to give %Datetime; fields special handling. In VS
debugger I found a SchemaInfo field containing all the information I need,
but it is private and all the classes it its tree are internal. So I must
use reflection to access it, and it will be bad for performance, and
requires full trust. I used regular expressions to parse the DTD file, but I
wonder if there a library to parse DTD file or a better way

<!ATTLIST indication
href %URI; #IMPLIED
si-id CDATA #IMPLIED
created %Datetime; #IMPLIED
si-expires %Datetime; #IMPLIED
action (signal-none|signal-low|signal-medium|signal-high|delete)
"signal-medium"
Best regards,
Sherif
 
M

michelletjtan

I face the same problem with you that I need to find a proper DTD
parser in c#. Do you have any idea on this? :(
 
S

Sherif ElMetainy

Hello

I didn't find any. As I said in my original post, I used regular expressions
to parse the DTD files. In my case I don't need to parse the whole file,
only the <!ATTLIST declarations. Currently this is working for me now,
although I don't like it. The .NET framework itself has a very good DTD
parser. But unfortunately all its classes and members are private. I wish
Microsoft makes it public in the next framework release.

Anyways I will tell you if I find any library, and I hope you tell me if you
find any :)

Best regards,
Sherif


michelletjtan said:
I face the same problem with you that I need to find a proper DTD
parser in c#. Do you have any idea on this? :(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top