Package org.geotools.xml
Class DocumentFactory
Object
DocumentFactory
This is the main entry point into the XSI parsing routines.
Example Use:
Object x = DocumentFactory.getInstance(new URI("MyInstanceDocumentURI");
A selection of the hints available to configure parsing:
VALIDATION_HINT- Boolean.FALSE to disable validationDocumentHandler.DEFAULT_NAMESPACE_HINT_KEY-Schemafor parsing and validationXMLHandlerHints.FLOW_HANDLER_HINTXMLHandlerHints.NAMESPACE_MAPPING- Map<String,URL> namespace mappingXMLHandlerHints.ENTITY_RESOLVER- control entry resolutionDISABLE_EXTERNAL_ENTITIES- Boolean.TRUE to disable entity resolutionXMLHandlerHints.SAX_PARSER_FACTORY- supply factory used bygetParser(Map)
- Author:
- dzwiers, Refractions Research, Inc. http://www.refractions.net
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringWhen this hint is contained and set toBoolean.TRUE(the default value), external entities will be disabled.static final StringWhen this hint is contained and set toBoolean.TRUE, parsing and validation supports use of DTD.static final Stringstatic final StringWhen this hint is contained and set toBoolean.FALSE, element ordering will not be validated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetInstance(InputStream is, Map<String, Object> hints, Level defaultLevel) Parses the instance data provided.static ObjectgetInstance(URI desiredDocument, Map<String, Object> hints) Calls getInstance(URI,Level) with Level.WARNING.static ObjectParses the instance data provided.static <T> TSafely check hints for provided key.static booleanSafely check hints for provided key.
-
Field Details
-
VALIDATION_HINT
When this hint is contained and set toBoolean.FALSE, element ordering will not be validated. This key may also affect data validation within the parse routines.The inherent safety of the resulting objects is weakened by turning this param to
false.- See Also:
-
DISABLE_EXTERNAL_ENTITIES
When this hint is contained and set toBoolean.TRUE(the default value), external entities will be disabled.This setting is used to alleviate XXE attacks, preventing both
VALIDATION_HINTandXMLHandlerHints.ENTITY_RESOLVERfrom being effective.- See Also:
-
ENABLE_DTD
When this hint is contained and set toBoolean.TRUE, parsing and validation supports use of DTD.A few standards such as SLD1.0 and WMS1.1 make use of DTD support and require this hint to be set to true.
- See Also:
-
LOG_LEVEL
- See Also:
-
-
Constructor Details
-
DocumentFactory
public DocumentFactory()
-
-
Method Details
-
getInstance
Calls getInstance(URI,Level) with Level.WARNING.- Parameters:
hints- May be null.- Returns:
- Object
- Throws:
SAXException- See Also:
-
getInstance
public static Object getInstance(URI desiredDocument, Map<String, Object> hints, Level defaultLevel) throws SAXExceptionParses the instance data provided. This method assumes that the XML document is fully described using XML Schemas. Failure to be fully described as Schemas will result in errors, as opposed to a vid parse.- Parameters:
hints- May be null.- Returns:
- Object
- Throws:
SAXException
-
getInstance
public static Object getInstance(InputStream is, Map<String, Object> hints, Level defaultLevel) throws SAXExceptionParses the instance data provided. This method assumes that the XML document is fully described using XML Schemas. Failure to be fully described as Schemas will result in errors, as opposed to a vid parse.- Parameters:
is- InputStream to parse, will be closed by this method.hints- DocumentFactory parsing hintsdefaultLevel- Log level to use for logging during parsing, may be null (defaults to Level.WARNING).- Returns:
- Parsed
- Throws:
SAXException- If an error occurs during parsing, or if the provided InputStream cannot be read.
-
hint
Safely check hints for provided key.- Parameters:
hints- Map of hints, may be if not provided.key- Key to look up hint valuedefaultValue- Default value returned if value is not available, or not aBoolean.- Returns:
- Value of hint if available and a
Boolean, otherwisedefaultValue.
-
hint
Safely check hints for provided key.- Parameters:
hints- Map of hints, may be if not provided.key- Key to look up hint valuedefaultValue- Default value returned if value is not available, or not aBoolean.- Returns:
- Value of hint if available and a
Boolean, otherwisedefaultValue.
-