[
https://issues.apache.org/jira/browse/DOXIA-716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17801373#comment-17801373
]
ASF GitHub Bot commented on DOXIA-716:
--------------------------------------
michael-o commented on code in PR #187:
URL: https://github.com/apache/maven-doxia/pull/187#discussion_r1438663904
##########
doxia-core/src/main/java/org/apache/maven/doxia/util/XmlValidator.java:
##########
@@ -65,57 +86,42 @@ public class XmlValidator {
*/
public void validate(String content) throws ParseException {
try {
- // 1 if there's a doctype
- boolean hasDoctype = false;
- Matcher matcher = PATTERN_DOCTYPE.matcher(content);
- if (matcher.find()) {
- hasDoctype = true;
- }
-
- // 2 check for an xmlns instance
- boolean hasXsd = false;
- matcher = PATTERN_TAG.matcher(content);
- if (matcher.find()) {
- String value = matcher.group(2);
-
- if
(value.contains(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI)) {
- hasXsd = true;
- }
- }
-
- // 3 validate content
- getXmlReader(hasXsd && hasDoctype).parse(new InputSource(new
StringReader(content)));
- } catch (IOException | SAXException e) {
+ getXmlReader().parse(new InputSource(new StringReader(content)));
+ } catch (IOException | SAXException | ParserConfigurationException e) {
throw new ParseException("Error validating the model", e);
}
}
/**
- * @param hasDtdAndXsd to flag the <code>ErrorHandler</code>.
* @return an xmlReader instance.
* @throws SAXException if any
+ * @throws ParserConfigurationException
*/
- private XMLReader getXmlReader(boolean hasDtdAndXsd) throws SAXException {
+ public XMLReader getXmlReader() throws SAXException,
ParserConfigurationException {
if (xmlReader == null) {
Review Comment:
No objections, but that would be a behavioral change and should be a
separate issue.
> Update and unify XMLReader creation and configuration
> -----------------------------------------------------
>
> Key: DOXIA-716
> URL: https://issues.apache.org/jira/browse/DOXIA-716
> Project: Maven Doxia
> Issue Type: Improvement
> Components: Core
> Affects Versions: 2.0.0-M8
> Reporter: Michael Osipov
> Assignee: Michael Osipov
> Priority: Major
> Fix For: 2.0.0-M9
>
>
> * {{XMLReaderFactory}} is deprecated from Java 9
> * Force XML Schema as main language if both DTD and XSD are provided
> * Force {{Locale#ROOT}} for portability
> * Remove old Xerces hack
--
This message was sent by Atlassian Jira
(v8.20.10#820010)