It's not at all possible to keep multiple artifactId
tags in a single dependency
tag.
XML schema definition for Maven will not validate it. It will produce an error like this :
Project build error: Non-parseable POM project/pom.xml: Duplicated tag: 'artifactId' (position: START_TAG seen ...</artifactId>\n
For example :
This is right.
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.0</version>
</dependency>
This is wrong.
<dependency>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<artifactId>xercesImpl</artifactId>
<version>2.12.0</version>
</dependency>
You can simply use like this as artifactId are different (without any issue) :
<dependency>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.0</version>
</dependency>
You can refer to this : Multiple versions of the same dependency in Maven
Note : JDK 8 already gives you SAX parser to validate XML. Please use that. You don't need third party jar to validate XML.
Read here about Java SAX Parser.