Re: how do I detect internal subset when part of external subset?
Elliotte Harold <[email protected]>
| Newsgroups | gmane.text.xml.general |
|---|---|
| Message-ID | <[email protected]> |
The trick is to look for the entity name "[dtd]". XOM accomplishes this
thusly using pure SAX:
protected boolean inExternalSubset = false;
// We have a problem here. Xerces gets this right,
// but Crimson and possibly other parsers don't properly
// report these entities, or perhaps just not tag them
// with [dtd] like they're supposed to.
public void startEntity(String name) {
if (name.equals("[dtd]")) inExternalSubset = true;
}
public void endEntity(String name) {
if (name.equals("[dtd]")) inExternalSubset = false;
}
You can just reverse the logic if you prefer inInternalSubset.
--
Elliotte Rusty Harold [email protected]
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim