Subject: Re: [xsl] Modifying a DTD with XSLT From: dvint@xxxxxxxxx Date: Mon, 4 Oct 2010 07:37:46 -0700 |
An easuier way to manage this might be with slightly different DTDs. You can use entities in the DTD such that all the common stuff stays in one file, then place all the id/idref element definitions in a second file. Make two versions of this second file. One in which evertyhing is the same (IDREF) definitions. Take the other and make these CDATA types so the parser no longer validates them. You can then either use one file to manage this DTD and just change the references, or create two files that live in different locations. The rest of this sort of depends on the capabilities of the system in question. If it uses XML catalogs it is real easy, if not then you might have to do some manipulation by hand (or change the DTD reference on chunking). I'm sort or assuming you will have a corresponding tool to put the chunks back together. DTD1.dtd <!ENTITY commonstuff SYSTEM "commonstuff.ent"> <!ENTITY IDvalidation SYSTEM "IDvalid.ent"> %commonstuff; %IDvalidation; DTD2.dtd <!ENTITY commonstuff SYSTEM "commonstuff.ent"> <!ENTITY loosevalidation SYSTEM "loosevalid.ent"> %commonstuff; %loosevalidation; IDvalid.ent <!ELEMENT xref EMPTY> <!ATTLIST xref idref IDREF #REQUIRED> loosevalid.ent <!ELEMENT xref EMPTY> <!ATTLIST xref idref CDATA #REQUIRED> commonstuff.ent content is everything but those elements with IDref attributes from the original DTD This could also be done with internal entity references and just manage them by hand in that file. Change the pointer to the entity you want on the given system depending upon the capabilities. I would just use DTD1.dtd internally and provide them with dtd2.dtd. > Hello, > > My original task is to split a source XML file into certain chunks to make > handling with translation systems easier (if you want to have several > translators work in parallel some systems apparently cannot split received > data into chunks on their own). Since the source document contains > cross-references with idref/id attributes throughout the content I cannot > use the original DTD which specifies attributes like > > <!ATTLIST crossref idref IDREF #IMPLIED> > <!ATTLIST section id ID #IMPLIED> > > because @idref and @id might end up in different chunks. The XML parser > would then complain. > > I could create XML chunks without any DTD reference, but this would not > allow validation of the structure after translation. So I thought of > creating a slightly modified version of the DTD with > > <!ATTLIST crossref idref CDATA #IMPLIED> > > Since the original DTD is likely to change at other places, I plan to make > that change on-the-fly with the splitting of the source XML. > > Long story short: Can you think of another way to make such a change than > with a combination of > <xsl:result-document method="text">, > unparsed-text($dtdpath), and > replace($dtdstring, 'idref\s+IDREF', 'idref CDATA') > > Thanks a lot for your comments, > > - Michael M|ller-Hillebrand > > PS: I can see that XSL could be used more elegantly with an XML Schema, > but this is no option currently.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Modifying a DTD with XSLT, David Carlisle | Thread | [xsl] Copying all comments [xsltpro, pankaj . c |
Re: [xsl] Copying all comments [xsl, pankaj . c | Date | [xsl] nested grouping problem, Terry Ofner |
Month |