I am using XMLbeans to bind Java objects to NETCONF (RFC 4741) RPC messages.
The schema fragment below shows an abstract element, rpcOperation, of type
rpcOperationType as the head of a substitution group.
Using substitute(QName, SchemaType), I can easily create concrete instances of
the abstract element because I know the concrete type a priori, but I can't
figure
out how go in the opposite direction, i.e. extract the concrete type from the
abstract
element.
Schema fragment:
<!--
<rpc> element
-->
<xs:complexType name="rpcType">
<xs:sequence>
<xs:element ref="rpcOperation" />
</xs:sequence>
<xs:attribute name="message-id" type="messageIdType" use="required" />
<!-- Arbitrary attributes can be supplied with <rpc> element. -->
<xs:anyAttribute processContents="lax" />
</xs:complexType>
<!--
rpcOperationType: used as a base type for all NETCONF operations
-->
<xs:complexType name="rpcOperationType" />
<xs:element name="rpcOperation" type="rpcOperationType" abstract="true" />
and a number of rpcOperationType substitution types and corresponding elements,
e.g.
<xs:complexType name="xyzType">
<xs:complexContent>
<xs:extension base="rpcOperationType">
<xs:sequence>
{various protocol elements}
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="xyz" type="xyzType" substitutionGroup="rpcOperation" />
When decoding a RPC message, how can I instantiate the concrete element (e.g.
xyz of type xyzType) from
the abstract rpcOperation element?
If I extract the abstract element using the only provided getter
(RpcDocument.getRpcOperation()),
I get an xml-fragment that has the actual type buried in it, but no obvious way
to recast it.
RpcDocument doc = RpcDocument.getRpc() contains:
<xml-fragment message-id="1">
<urn:get xmlns:urn="urn:ietf:params:xml:ns:netconf:base:1.0"/>
</xml-fragment>
but RpcOperationType op = doc.getRpcOperation() contains:
<xml-fragment xmlns:urn="urn:ietf:params:xml:ns:netconf:base:1.0"/>
Looking at the above "op" fragment with a debugger shows that the object is of
type GetTypeImpl,
and there is other information in the object that identifies it's type, but I
don't see any
method to extract this.
The generated methods are:
Interface xmlbeans.RpcDocument
Method Summary
RpcType addNewRpc() Appends and returns a new empty "rpc" element
RpcType getRpc() Gets the "rpc" element
void setRpc(RpcType rpc) Sets the "rpc" element
Interface xmlbeans.RpcType
Method Summary
RpcOperationType addNewRpcOperation() Appends and
returns a new empty "rpcOperation" element
java.lang.String getMessageId() Gets the
"message-id" attribute
RpcOperationType getRpcOperation() Gets the
"rpcOperation" element
void setMessageId(java.lang.String messageId) Sets the
"message-id" attribute
void setRpcOperation(RpcOperationType rpcOperation) Sets the
"rpcOperation" element
MessageIdType xgetMessageId() Gets (as
xml) the "message-id" attribute
void xsetMessageId(MessageIdType messageId) Sets (as
xml) the "message-id" attribute
Interface xmlbeans.RpcOperationType
{no methods other than those inherited from XmlObject and XmlTokenSource
Any advice on how to proceed will be greatly appreciated.
- Andy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]