Package org.openstreetmap.josm.tools
Class XmlUtils
java.lang.Object
org.openstreetmap.josm.tools.XmlUtils
XML utils, mainly used to construct safe factories.
- Since:
- 13901
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ElementgetFirstChildElement(Node parent) Get the first child elementstatic DocumentBuilderReturns a new secure DOM builder, supporting XML namespaces.static SAXParserReturns a new secure SAX parser, supporting XML namespaces.static TransformerFactoryReturns a new secureTransformerFactory.static ValidatornewSafeValidator(Schema schema) Returns a new secureValidator.static XMLInputFactoryReturns a new secureXMLInputFactory.static SchemaFactoryReturns the W3C XML Schema factory implementation.static DocumentParse the content givenInputStreamas XML.static voidparseSafeSAX(InputSource is, DefaultHandler dh) Parse the content givenInputSourceas XML using the specifiedDefaultHandler.
-
Field Details
-
FEATURE_DISALLOW_DOCTYPE_DECL
- See Also:
-
-
Constructor Details
-
XmlUtils
private XmlUtils()
-
-
Method Details
-
newXmlSchemaFactory
Returns the W3C XML Schema factory implementation. Robust method dealing with ContextClassLoader problems.- Returns:
- the W3C XML Schema factory implementation
-
newSafeDOMBuilder
Returns a new secure DOM builder, supporting XML namespaces.- Returns:
- a new secure DOM builder, supporting XML namespaces
- Throws:
ParserConfigurationException- if a parser cannot be created which satisfies the requested configuration.
-
parseSafeDOM
public static Document parseSafeDOM(InputStream is) throws ParserConfigurationException, IOException, SAXException Parse the content givenInputStreamas XML. This method uses a secure DOM builder, supporting XML namespaces.- Parameters:
is- The InputStream containing the content to be parsed.- Returns:
- the result DOM document
- Throws:
ParserConfigurationException- if a parser cannot be created which satisfies the requested configuration.IOException- if any IO errors occur.SAXException- for SAX errors.
-
newSafeSAXParser
Returns a new secure SAX parser, supporting XML namespaces.- Returns:
- a new secure SAX parser, supporting XML namespaces
- Throws:
ParserConfigurationException- if a parser cannot be created which satisfies the requested configuration.SAXException- for SAX errors.
-
parseSafeSAX
public static void parseSafeSAX(InputSource is, DefaultHandler dh) throws ParserConfigurationException, SAXException, IOException Parse the content givenInputSourceas XML using the specifiedDefaultHandler. This method uses a secure SAX parser, supporting XML namespaces.- Parameters:
is- The InputSource containing the content to be parsed.dh- The SAX DefaultHandler to use.- Throws:
ParserConfigurationException- if a parser cannot be created which satisfies the requested configuration.SAXException- for SAX errors.IOException- if any IO errors occur.
-
newSafeXMLInputFactory
Returns a new secureXMLInputFactory.- Returns:
- a new secure
XMLInputFactory, for which external entities are not loaded
-
newSafeTransformerFactory
public static TransformerFactory newSafeTransformerFactory() throws TransformerConfigurationExceptionReturns a new secureTransformerFactory.- Returns:
- a new secure
TransformerFactory - Throws:
TransformerConfigurationException- if the factory or the Transformers or Templates it creates cannot support this feature.
-
newSafeValidator
Returns a new secureValidator.- Parameters:
schema- XML schema- Returns:
- a new secure
Validator - Since:
- 14441
-
getFirstChildElement
Get the first child element- Parameters:
parent- parent node- Returns:
- the first child element
- Since:
- 14348
-