You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Benson Cheng <Be...@viacore.net> on 2001/03/29 04:40:09 UTC

How to add DocumentType(DTD) into an existing DOM

Can someone show me how to add a DoumentType(DTD) into an existing DOM?

Thanks,
Benson.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: How to add DocumentType(DTD) into an existing DOM

Posted by chandru <cu...@connextive.com>.
Hi,
Following snippet can help  u .try .

                        ByteArrayInputStream bis = new
ByteArrayInputStream(xmlmessage);     //xmlmessage is byte arraay of xml
doc
                        InputSource source = new InputSource(bis);
                        String sysid = "file:///"+"c:\abc.dtd";
                        source.setSystemId(sysid);
                      try
                      {
                           Parser parser =
ParserFactory.makeParser(DEFAULT_PARSER_NAME );
                           parser.setDocumentHandler(this);
                            parser.setErrorHandler(this);
                        }


for an existing parser try this:

                        DOMParser domp = new DOMParser();
                        InputSource insrc = new InputSource(b);
                        String sysid = insrc.getSystemId();
                        String userdir = System.getProperty("user.dir");
                        sysid =
"file:///"+userdir+"\\fmc\\xml\\dtd\\";//+sysid;
                        insrc.setSystemId(sysid);
                        domp.parse(insrc);  /// added by ucs
                       Document doc = domp.getDocument();
                        dtype = (DocumentType)doc.getDoctype();

The above snippet will supply a changed location of dtd .for my code the
parser is looking in user directory i changed the input source to the sub
directory of the user .try it.


from
chandru

Benson Cheng wrote:

> Can someone show me how to add a DoumentType(DTD) into an existing DOM?
>
> Thanks,
> Benson.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org