Xerces2-j XML Attribute / Element Schema Type Declaration Type

I am using Apache Xerces2-j to parse my XSD. I am trying to get data type information for element / attribute declarations in XSD.

Here is an XSD example:

<xs:element name="Pretzel">
    ...
    <xs:attribute name="Flavor" type="xs:string"/>
    <xs:attribute name="ProductID" type="xs:nonNegativeInteger"/>
    ...
</xs:element>

In this case, I would like to get the Flavor and ProductID attribute data types. According to the W3C API and its implementation of Xerces2-j , XSAttributeDeclaration getActualVCType () will get me what I want. But for me, this method always returns 45, which is UNAVAILABLE_DT . Is this a bug in Xerces2-j, or am I just misunderstanding the API? If so, I would appreciate it if someone could point me in the right direction.

+3
1

XSAttributeDeclaration.getTypeDefinition(); // returns XSSimpleTypeDefinition

/

XSAttributeDeclaration.getEnclosingCTDefinition(); // returns XSComplexTypeDefinition

.

getActualVCType() , getValueConstraintValue(). getActualValueType() , . XSAttributeDecl.java:

       // variable definition
48     // value constraint type: default, fixed or !specified
49     short fConstraintType = XSConstants.VC_NONE;

183    public short getActualVCType() {
184        return getConstraintType() == XSConstants.VC_NONE ?
185               XSConstants.UNAVAILABLE_DT :
186               fDefault.actualValueType;
187    }

136
137    public short getConstraintType() {
138        return fConstraintType;
139    }

, UNAVAILABLE_DT, . XSSimpleTypeDefinition, .

0

Source: https://habr.com/ru/post/1774979/


All Articles