Java Xerces“;固定的;XML模式中的元素属性

Java Xerces“;固定的;XML模式中的元素属性,java,xsd,xerces,Java,Xsd,Xerces,我有一个XML模式元素,定义如下: <xsd:element name="Test"> <xsd:complexType> <xsd:sequence> <xsd:element name="ElementFixed" fixed="SomeFixedValue"/> </xsd:sequence> </xsd:complexType> </xsd:element&

我有一个XML模式元素,定义如下:

<xsd:element name="Test">
   <xsd:complexType>
      <xsd:sequence>
         <xsd:element name="ElementFixed" fixed="SomeFixedValue"/>
      </xsd:sequence>
   </xsd:complexType>
</xsd:element>

据我所知,“ElementFixed”是一个通配符元素。(由于未定义类型,因此其类型为“anyType”。)


现在,这可能是相关的或无关的(与通配符的元素有关),但我正在尝试使用Xerces库提取“固定”值“SomeFixedValue”,并且正在努力解决如何做到这一点。我怀疑这可能与XSAttributeUse或XSAttributeDeclaration有关,但我还无法确定需要调用哪些方法来提取这些信息。有人能给我指一下正确的方向吗?谢谢

我能解决这个问题。事实证明,我需要在XSElementDeclaration上调用getConstraintType(),它返回XSConstants.VC_NONE、VC_DEFAULT或VC_FIXED。然后,如果约束类型不是none,则通过调用getValueConstraintValue().getActualValue()来访问该值。例如:

short vcKind = xsElementDecl.getConstraintType();
System.out.println("Constraint Type: " + vcKind);
if (vcKind != XSConstants.VC_NONE) {
   System.out.println("Value: " + xsElementDecl.getValueConstraintValue().getActualValue());
}

我能解决这个问题。事实证明,我需要在XSElementDeclaration上调用getConstraintType(),它返回XSConstants.VC_NONE、VC_DEFAULT或VC_FIXED。然后,如果约束类型不是none,则通过调用getValueConstraintValue().getActualValue()来访问该值。例如:

short vcKind = xsElementDecl.getConstraintType();
System.out.println("Constraint Type: " + vcKind);
if (vcKind != XSConstants.VC_NONE) {
   System.out.println("Value: " + xsElementDecl.getValueConstraintValue().getActualValue());
}