Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Custom list binding(An existing xsd format has a list that cannot be mapped)
Custom list binding [message #1635678] Wed, 25 February 2015 22:45 Go to next message
Jason Pell is currently offline Jason PellFriend
Messages: 55
Registered: February 2011
Member
I have a xml format like:

<GeneratorConfig>
  <DuplicateConfig>
     <duplicateMatching>SingleValue</duplicateMatching>
     <ignoreFqn>someFqn</ignoreFqn>
    <ignoreFqn>someFqn</ignoreFqn>
  </DuplicateConfig>
</GeneratorConfig>


What I actually end up with is:

<GeneratorConfig>
  <DuplicateConfig>
     <duplicateMatching>SingleValue</duplicateMatching>
     <IgnoreFqn>
         <ignoreFqn>someFqn</ignoreFqn>
    </IgnoreFqn>
     <IgnoreFqn>
         <ignoreFqn>someFqn</ignoreFqn>
     </IgnoreFqn>
  </DuplicateConfig>
</GeneratorConfig>


I have a DuplicateConfig and IgnoreFqn classes below

Should I be using a @CustomXmlListBinding in duplicate config and what particular methods should I be overriding. I have used the best google fu I know but can't find anything useful for this.

public interface DuplicateConfig extends Element {
	ElementType TYPE = new ElementType(DuplicateConfig.class);

	@Type( base = DuplicateMatching.class )
	@XmlBinding(path = "duplicateMatching")
	@Label(standard = "Duplicate Matching")
	@DefaultValue( text = "IgnoreNumericSuffix" )
	ValueProperty PROP_DUPLICATE_MATCHING = new ValueProperty(TYPE, "DuplicateMatching");

	Value<DuplicateMatching> getDuplicateMatching();
	void setDuplicateMatching(String value);
	void setDuplicateMatching(DuplicateMatching value);
	
	@Label( standard = "Ignore Fqns" )
	@XmlListBinding( path = "" )
	@Type( base = IgnoreFqn.class )
    ListProperty PROP_IGNORE_FQNS = new ListProperty( TYPE, "IgnoreFqns" );
    ElementList<IgnoreFqn> getIgnoreFqns();
}


public interface IgnoreFqn extends Element {
	ElementType TYPE = new ElementType(IgnoreFqn.class);
	
	@Label(standard = "Ignore Fqn")
	@Required
	@XmlBinding( path = "ignoreFqn" )
	ValueProperty PROP_LANGUAGE = new ValueProperty(TYPE, "IgnoreFqn");

	Value<String> getIgnoreFqn();

	void setIgnoreFqn(String value);
}

[Updated on: Thu, 26 February 2015 03:26]

Report message to a moderator

Re: Custom list binding [message #1635693 is a reply to message #1635678] Wed, 25 February 2015 22:58 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
<IgnoreFqn>
    <ignoreFqn>someFqn</ignoreFqn>
</IgnoreFqn>


The first level correspond to the list entry. That is, your IgnoreFqn element type. The second level corresponds to the value property within that element. To eliminate the extra level, do the following:

1. Use @XmlBinding( path = "" ) for the value property.
2. Use @XmlBinding( path = "ignoreFqn" ) for the IgnoreFqn element type (annotate the interface declaration). This will give you the correct case for your list element.

Note that your value property uses PROP_LANGUAGE, while the property name IgnoreFqn. These should match or your property annotations will not be found...
Re: Custom list binding [message #1635759 is a reply to message #1635693] Wed, 25 February 2015 23:41 Go to previous message
Jason Pell is currently offline Jason PellFriend
Messages: 55
Registered: February 2011
Member
Thanks so much for your quick and "exactly what I needed" response.

Just what I needed for my second day of Sapphire
Previous Topic:Announcing Sapphire 8.1.2 Release
Next Topic:InitialValue vs DefaultValue and persistence
Goto Forum:
  


Current Time: Tue Sep 24 06:11:17 GMT 2024

Powered by FUDForum. Page generated in 0.03325 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top