Reputation: 29
In my application built on JDK17, we are xerces2 for xml functionality but you may know that development of Xerces2 has became stagnant and the last release was in 2022. So, I want to remove it from out codebase. Now, after JDK 9 that introduced module concept in java it kinda locked us to use internal JDK xerces based method directly and we had to use --add-exports to be able to use this in our.
--add-exports java.xml/com.sun.org.apache.xerces.internal.impl.xs=ALL-UNNAMED
I want to know what is possible alternative that can be used for xml parsing, validation and help us in removing xerces.
These are some of the imports we are doing for xml...
import static com.sun.org.apache.xerces.internal.xs.XSConstants.ELEMENT_DECLARATION;
import com.sun.org.apache.xerces.internal.xs.XSAttributeUse;
import com.sun.org.apache.xerces.internal.xs.XSComplexTypeDefinition;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
import com.sun.org.apache.xerces.internal.xs.XSElementDeclaration;
import com.sun.org.apache.xerces.internal.xs.XSModelGroup;
import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import com.sun.org.apache.xerces.internal.xs.XSParticle;
import com.sun.org.apache.xerces.internal.xs.XSTerm;
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
I looked upon jakarta.xml can be an alternative but I actually didn't find like a similar method that can be replaced with the once I am using.
Upvotes: -1
Views: 1386
Reputation: 163587
It's not at all clear what you are trying to achieve. The XML specification has been stable for a quarter of a century so why are you reluctant to use an XML parser that is equally stable? There may be valid reasons for wanting something better but the fact that the product is stable is not by itself a reason for moving to something else.
There are in fact two versions of Xerces: the version from Apache, and the version built into the JDK. At one time I used to recommend the Apache version because bugs were fixed more quickly, but I think that is no longer the case.
The list of imports you show suggests that you are using the JDK version of Xerces, and moreover that you are using some of its specialised APIs exposing the schema component model: which means it's some schema access functionality you're concerned about, rather than the core XML parsing and XSD validation capability. The simplest and most obvious way to keep using that is to switch to the Apache version of Xerces. But the APIs you are using are rather specialised and it would help to know what you are using them for - something that you don't seem to fully understand yourself.
Upvotes: 2