私の仕事は、指定された複合型の任意の属性の(名前、デフォルト値)のペアを取り出すことです。XSAttributeUse.getValueConstraintValue()を使用するとApache Xercesがjava.lang.NoSuchMethodErrorをスローします
Exception in thread "main" java.lang.NoSuchMethodError: org/apache/xerces/xs/XSAttributeUse.getValueConstraintValue()Lorg/apache/xerces/xs/XSValue; (loaded from path\to\sdk\jre\lib\xml.jar by <Bootstrap Loader>) called from class my.package.xsd.XSDParser (loaded from file:/path/to/the/project/SwidSigner/target/classes/ by [email protected]).
at my.package.xsd.XSDParser.getTypeAttributes(XSDParser.java:54)
at my.package.xsd.XSDParser.getAttributes(XSDParser.java:37)
at my.package.Main.main(Main.java:29)
何より、私はそれを変更する場合:
はXSObjectList attrList = typeDefinition.getAttributeUses();
for (int i = 0; i < attrList.getLength(); i++) {
XSAttributeUse attributeUse = (XSAttributeUse) attrList.item(i);
XSAttributeDeclaration attributeDecl = attributeUse.getAttrDeclaration();
if (!attributeUse.getRequired()) {
String name = attributeDecl.getValueConstraintValue().getNormalizedValue();
String value = /* extracting the default value */;
}
}
それでもエラーが発生しますが、これはエラーを生成します
XSObjectList attrList = typeDefinition.getAttributeUses();
for (int i = 0; i < attrList.getLength(); i++) {
XSAttributeUse attributeUse = (XSAttributeUse) attrList.item(i);
if (!attributeUse.getRequired()) {
String name = attributeUse.getValueConstraintValue().getNormalizedValue();
String value = /* extracting the default value */;
}
}
: は、私は次のコードを持っています代わりにXSAttributeDeclarationクラスについて不平を言います。
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
使用しているJavaのバージョンは?あなたのJREのlibディレクトリからXercesクラスをロードしようとしているようです。 – rmlan
私はJava 8を使用しています。どうすればMavenからXercesクラスを読み込ませることができますか? –