我正在尝试Jaxb2Marshaller在Spring-WS中定义一个bean来使用扩展的自定义适配器XmlAdapter.我在XML文件中有以下内容:
<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<!-- various classes to be bound... -->
</list>
</property>
<property name="schema" value="myschema.xsd" />
<property name="adapters">
<list>
<value>com.lmig.am.claims.clip.ContactAdapter</value>
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误:
Cannot convert value of type [java.lang.String] to required type [javax.xml.bind.annotation.adapters.XmlAdapter] for property 'adapters[0]': no matching editors or conversion strategy found
我有什么想法我做错了吗?谢谢!
我有一个Facebook应用程序,用户可以将其作为页面选项卡应用程序添加到他们的Facebook业务页面.它不需要用户的任何扩展权限.我想知道是否可以使用我的app access_token并对Facebook Graph API进行调用以检索有关年龄限制页面的信息?
facebook facebook-graph-api oauth-2.0 facebook-c#-sdk facebook-opengraph
我想知道是否有可能对我的类进行注释,以便第一次编组遇到一个对象,它会生成一个相应类型的XML元素,但是任何后续对该对象的任何引用都会创建一个XML IDREF条目?
在解组过程中是否可以IDREF在JAXB XmlAdapter中处理XML 元素的前向引用?例如,我有以下XML complexType:
<xs:complexType name="person">
<xs:complexContent>
<xs:sequence>
<xs:element name="dateOfBirth" type="xs:dateTime" minOccurs="0"/>
<xs:element name="firstName" type="xs:string" minOccurs="0"/>
<xs:element name="gender" type="xs:string" minOccurs="0"/>
<xs:element name="guardian" type="xs:IDREF" minOccurs="0"/>
<xs:element name="homePhone" type="xs:string" minOccurs="0"/>
<xs:element name="lastName" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexContent>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)
其中guardian字段可以引用另一个Person文档中的别处型元件.我正在编组时使用XmlAdapter,以便第一次对象进行编组时,它会被包含编组,并且此对象的任何后续出现都将通过引用进行编组.看看我以前的一个问题.但是,由于我的XML实例文档的创建方式,Person元素的第一次出现可能会在IDREF它发生之后发生.
这是可能的吗?或者我需要以不同的方式处理这个问题?谢谢!
我在Facelets页面中有以下下拉列表:
<h:selectOneMenu value="#{contactBean.selectedContact}" converter="#{contactConverter}">
<f:selectItems value="#{contactsHolder.contacts}" var="contact"
itemLabel="#{contact.firstName}" itemValue="#{contact}" />
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)
问题是,无论我放入什么itemLabel(JSF EL表达式或纯文本),它都不会显示.知道我做错了什么吗?
这是ContactConverter:
@ManagedBean(name = "contactConverter")
@RequestScoped
public class ContactConverter implements Converter, Serializable {
@ManagedProperty(value = "#{contactsHolder}")
private ContactsHolder contactsHolder;
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
return contactsHolder.getContacts().get(value);
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
return ((Contact) value).getContactID();
}
//getter & setters...
}
Run Code Online (Sandbox Code Playgroud)
而且ContactsHolder:
@ManagedBean
@SessionScoped
public class ContactsHolder implements Serializable {
private Map<String, Contact> …Run Code Online (Sandbox Code Playgroud) 关于targetNamespaceXML模式中的属性如何影响元素的命名,我有点困惑.我收到错误验证以下内容:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="test" version="1.0">
<xs:element name="testType" type="testType"/>
<xs:complexType name="testType">
<xs:sequence>
<xs:element name="testSubtype" type="testSubType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="testSubType">
<!-- some fields -->
</xs:complexType>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
XMLSpy说明了Cannot resolve the unqualified declaration or definition 'testSubType'.如何解决这个问题?我需要保留targetNamespace属性.我试着改变testSubType,以test:testSubType在各个领域,但是这似乎并没有工作.