I’m using Apache’s Xerces2-j to parse my XSD. I am trying to get the datatype information for the element / attribute declarations in the XSD.
Here’s an example XSD:
<xs:element name="Pretzel">
...
<xs:attribute name="Flavor" type="xs:string"/>
<xs:attribute name="ProductID" type="xs:nonNegativeInteger"/>
...
</xs:element>
In this case, I’d want to get the datatypes of the Flavor and ProductID attributes. According to the W3C Schema API and its Xerces2-j implementation, XSAttributeDeclaration’s getActualVCType() will get me what I want. But for me that method always returns 45, which is UNAVAILABLE_DT. Is this a bug in Xerces2-j, or am I just understanding the API wrong? If I am, I’d appreciate if someone could point me to the right direction here.
You are looking to use the method
for simple types and/or possibly
for complex types.
The method getActualVCType() is deprecated, and its alternative call getValueConstraintValue().getActualValueType() looks into a so-called value constraint
which is not what you are looking for. This argument is also supported by the code in XSAttributeDecl.java:
and
with
suggests that you are indeed getting UNAVAILABLE_DT because it is not set. I suggest looking into the XSSimpleTypeDefinition’s methods, it looks promising to me.