[Simple-support] Invalid reference
Brought to you by:
niallg
|
From: Andreas L. <and...@gm...> - 2012-05-08 09:34:44
|
Hi all,
(Sorry if this is a duplicate now, I tried sending it to the list before I
registered.)
I have a problem that I cannot get my head around. I am trying to do
references in my xml. Everything else has worked fine, but this is hard to
grasp. Here is all the relevant info (edited/stripped for clarity):
*Deserializing:*
CycleStrategy cycleStrategy = new CycleStrategy("id", "ref");
Strategy annotationStrategy = new AnnotationStrategy(cycleStrategy);
Serializer serializer = new Persister(annotationStrategy);
*Class 1:*
@Element
public class Unit {
@ElementList(name="special_rules",required=false)
private List<Rule> specialRules = new ArrayList<Rule>();
public Unit() {
super();
}
*Class 2:*
@Element
public class Rule {
@Attribute
private String name;
@Element(required=false)
private String text;
public Rule() {
super();
}
*XML:*
<?xml version="1.0" encoding="UTF-8"?>
<codex name="Space Marines 5th ed" version="1.0">
<units>
<unit name="Captain" q="1" foc="HQ" type="Infantry" base_cost="100">
<stats>
<stat key="WS">6</stat>
<stat key="BS">5</stat>
<stat key="S">4</stat>
<stat key="T">4</stat>
<stat key="W">3</stat>
<stat key="I">5</stat>
<stat key="A">3</stat>
<stat key="Ld">10</stat>
<stat key="Sv">3+</stat>
</stats>
<wargears>
<wargear name="Power armour" />
<wargear name="Chainsword" />
<wargear name="Bolt pistol" />
<wargear name="Frag and krak grenades" />
<wargear name="Iron Halo" />
</wargears>
<special_rules>
<rule ref="atsknf" />
<rule ref="ct" />
<rule ref="ic" />
</special_rules>
</unit>
</units>
<rules>
<rule name="Combat Squads" id="cs">
<text>Divide from 10 to 2x5.</text>
</rule>
<rule name="Combat Tactics" id="ct">
<text>Choose to fail any morale test.</text>
</rule>
<rule name="And They Shall Know No Fear" id="atsknf">
<text>Badass...</text>
</rule>
<rule name="Independent Character" id="ic">
<text>See 40k rules</text>
</rule>
</rules>
*
*
*Error:*
org.simpleframework.xml.strategy.CycleException: Invalid reference 'atsknf'
found
at
org.simpleframework.xml.strategy.ReadGraph.readReference(ReadGraph.java:155)
at
org.simpleframework.xml.strategy.ReadGraph.readInstance(ReadGraph.java:123)
at org.simpleframework.xml.strategy.ReadGraph.read(ReadGraph.java:104)
at
org.simpleframework.xml.strategy.CycleStrategy.read(CycleStrategy.java:153)
at
org.simpleframework.xml.convert.AnnotationStrategy.read(AnnotationStrategy.java:100)
at org.simpleframework.xml.core.Source.getOverride(Source.java:370)
Thanks in advance for any help on this matter!
BR,
Andreas Limber
|