Package org.jdom2.input.stax
Class DTDParser
java.lang.Object
org.jdom2.input.stax.DTDParser
Parses out key information from a single String representing a DOCTYPE
declaration. StAX parsers supply a single string representing the DOCTYPE and
this needs to be processed to get items like the SystemID, etc. Additionally
it needs to be reformatted to create a standardised representation.
The assumption is that the DTD is valid.
We need to pull out 4 elements of data:
- The root element name
- The SystemID (if available)
- The PublicID (if available)
- The internal subset (if available)
We can do this all with a well-structured regular expression, which is actually simpler than trying to fish out all the components ourselves....
- Author:
- Rolf Lear
-
Method Summary
Modifier and TypeMethodDescriptionstatic DocType
parse
(String input, JDOMFactory factory) Parse out a DOCTYPE declaration as supplied by the standard StAX readers.
-
Method Details
-
parse
Parse out a DOCTYPE declaration as supplied by the standard StAX readers.Using 'XML' terminology, this method assumes that the input is both 'well-formed' and 'valid'. The assumptions that this class makes ensure that the 'right thing' is done for valid content, but invalid content may or may not fail with a JDOMException. The behaviour of this method with invalid input is 'undefined'.
- Parameters:
input
- the input DOCTYPE string to parse. Must be valid.factory
- The JDOM factory to use to build the JDOM DocType.- Returns:
- The input string as a DocType.
- Throws:
JDOMException
- if the DocType is not generated.
-