Re: [Simple-support] Invalid reference
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2012-05-08 09:44:23
|
The way cycle checking currently works, is that id defines the object, and ref references the definition. In your example, ref appears before id, so the reference has not been defined. If you swap the two it will work.
--- On Tue, 8/5/12, Andreas Limber <and...@gm...> wrote:
From: Andreas Limber <and...@gm...>
Subject: [Simple-support] Invalid reference
To: sim...@li...
Received: Tuesday, 8 May, 2012, 2:34 AM
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
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|