首先我已经阅读了链接文本,它并没有解决我的问题。
我正在使用带有别名的 XStream。
Condition 是一个具有多种不同实现的接口。我想删除类属性。我知道 XStream 在实现类不明确时使用类属性,并且我最多可以为一个实现类设置别名。我想一起删除类属性并使用类型属性加上其他子元素的存在来确定实现类。这可能吗?
这是我目前拥有的 XML:
<NextDestinations>
<Connector>
<DestinationId>2</DestinationId>
</Connector>
<Connector>
<DestinationId>3</DestinationId>
<condition class="com.orchestral.rhapsody.configuration.filter.condition.JavaScriptCondition" type="JAVASCRIPT">
...
</condition>
</Connector>
<Connector>
<DestinationId>4</DestinationId>
<condition class="com.orchestral.rhapsody.configuration.filter.condition.MessageTypeCondition">
<type>CONDITIONAL</type>
...
</condition>
</Connector>
<Connector>
<DestinationId>5</DestinationId>
<condition class="com.orchestral.rhapsody.configuration.filter.condition.MessageTypeCondition">
<type>CONDITIONAL</type>
...
</condition>
</Connector>
<Connector>
<DestinationId>6</DestinationId>
<condition class="com.orchestral.rhapsody.configuration.filter.condition.PropertyCondition">
<type>CONDITIONAL</type>
...
</condition>
</Connector>
<Connector>
<DestinationId>7</DestinationId>
<condition class="com.orchestral.rhapsody.configuration.filter.condition.FieldCondition">
<type>CONDITIONAL</type>
...
</condition>
</Connector>
<noMatchDestination>8</noMatchDestination>
<errorDestination>9</errorDestination>
</NextDestinations>
这是我想要的 XML:
<NextDestinations>
<Connector>
<DestinationId>1</DestinationId>
</Connector>
<Connector>
<DestinationId>2</DestinationId>
<condition type="JAVASCRIPT">
...
</condition>
</Connector>
<Connector>
<DestinationId>3</DestinationId>
<condition type="CONDITIONAL">
...
</condition>
</Connector>
<Connector>
<DestinationId>4</DestinationId>
<condition type="CONDITIONAL"
...
</condition>
</Connector>
<Connector>
<DestinationId>5</DestinationId>
<condition type="CONDITIONAL">
...
</condition>
</Connector>
<Connector>
<DestinationId>6</DestinationId>
<condition type="CONDITIONAL">
...
</condition>
</Connector>
<Connector>
<DestinationId>7</DestinationId>
<condition type="CONDITIONAL"
...
</condition>
</Connector>
<noMatchDestination>8</noMatchDestination>
<errorDestination>9</errorDestination>
</NextDestinations>