C
Chris W
Hi All,
I have hundreds of small XML files of the form (extrabeous stuff removed):
<?xml version="1.0"?>
<!DOCTYPE page PUBLIC "-//LOCAL//DTD PAGE 0.1//EN" "page.dtd">
<page>
<graphic boardno="entityname1" />
<graphic boardno="entityname2" />
</page>
that I would like to process into this form:
<?xml version="1.0"?>
<!DOCTYPE page [
<!ENTITY entityname1 SYSTEM "entityname1.gif" NDATA gif>
<!ENTITY entityname2 SYSTEM "entityname2.gif" NDATA gif>
<!NOTATION gif SYSTEM "image/gif">
]>
<page>
<graphic boardno="entityname1" />
<graphic boardno="entityname2" />
</page>
That is, I'd like to load each file, find all the boardno attributes,
insert an ENTITY declaration, insert a NOTATION declaration, and write
the result to a file. The XML markup is unchanged, just the internal
DTD is altered. Finding the boardno attributes in a DOM is trivial, but
manipulating the internal DTD subset and getting it to file is eluding me.
Apart from doing the DTD manipulation as a text file, any suggested tool
sets/approaches. Perl, Python, Java, whatever.
Regards,
Chris W
I have hundreds of small XML files of the form (extrabeous stuff removed):
<?xml version="1.0"?>
<!DOCTYPE page PUBLIC "-//LOCAL//DTD PAGE 0.1//EN" "page.dtd">
<page>
<graphic boardno="entityname1" />
<graphic boardno="entityname2" />
</page>
that I would like to process into this form:
<?xml version="1.0"?>
<!DOCTYPE page [
<!ENTITY entityname1 SYSTEM "entityname1.gif" NDATA gif>
<!ENTITY entityname2 SYSTEM "entityname2.gif" NDATA gif>
<!NOTATION gif SYSTEM "image/gif">
]>
<page>
<graphic boardno="entityname1" />
<graphic boardno="entityname2" />
</page>
That is, I'd like to load each file, find all the boardno attributes,
insert an ENTITY declaration, insert a NOTATION declaration, and write
the result to a file. The XML markup is unchanged, just the internal
DTD is altered. Finding the boardno attributes in a DOM is trivial, but
manipulating the internal DTD subset and getting it to file is eluding me.
Apart from doing the DTD manipulation as a text file, any suggested tool
sets/approaches. Perl, Python, Java, whatever.
Regards,
Chris W