Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何停止JAXB限定属性_Java_Xml_Jaxb - Fatal编程技术网

Java 如何停止JAXB限定属性

Java 如何停止JAXB限定属性,java,xml,jaxb,Java,Xml,Jaxb,如何让JAXB只限定元素而不限定属性 我得到了以下内容,它正确地限定了具有给定前缀的元素。但是,它也使用该前缀限定属性,这不是必需的 @XmlSchema(xmlns = {@XmlNs(namespaceURI = "http://www.w3.org/2005/Atom", prefix = "atom") }, elementFormDefault = XmlNsForm.QUALIFIED, attributeFormDefault = XmlNsForm.UNSET) 它产生了以下结

如何让JAXB只限定元素而不限定属性

我得到了以下内容,它正确地限定了具有给定前缀的元素。但是,它也使用该前缀限定属性,这不是必需的

@XmlSchema(xmlns = {@XmlNs(namespaceURI = "http://www.w3.org/2005/Atom", prefix = "atom") }, elementFormDefault = XmlNsForm.QUALIFIED, attributeFormDefault = XmlNsForm.UNSET)
它产生了以下结果:

<atom:link atom:rel="self" atom:href="/accounts/123456XZ" atom:type="application/xml"></atom:link>

//重新编译源架构时,对此文件的任何修改都将丢失。
//生成日期:2013.08.19英国夏令时下午12:28:23
//
包org.w3._2005.atom;
导入java.math.biginger;
导入java.util.HashMap;
导入java.util.Map;
导入javax.xml.bind.annotation.XmlAccessType;
导入javax.xml.bind.annotation.XmlAccessorType;
导入javax.xml.bind.annotation.XmlAnyAttribute;
导入javax.xml.bind.annotation.XmlAttribute;
导入javax.xml.bind.annotation.XmlSchemaType;
导入javax.xml.bind.annotation.XmlType;
导入javax.xml.bind.annotation.XmlValue;
导入javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
导入javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
导入javax.xml.namespace.QName;
导入net.karneim.pojobuilder.generateJobuilder;
导入org.jvnet.jaxb2_commons.lang.Equals;
导入org.jvnet.jaxb2_commons.lang.EqualsStrategy;
导入org.jvnet.jaxb2_commons.lang.jaxbequalstrategy;
导入org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy;
导入org.jvnet.jaxb2_commons.lang.ToString;
导入org.jvnet.jaxb2_commons.lang.toString策略;
导入org.jvnet.jaxb2_commons.locator.ObjectLocator;
导入org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
/**
* 
*Atom链接构造在格式规范的第3.4节中定义。
*             
* 
*linkType复杂类型的Java类。
* 
*以下架构片段指定此类中包含的预期内容。
* 
* 
*complexType name=“linkType”>
*complexContent>
*限制基数=”{http://www.w3.org/2001/XMLSchema}任何类型“>
*ATTGOUP ref=”{http://www.w3.org/2005/Atom}公共属性“/>
*属性名称=“rel”类型=”{http://www.w3.org/2001/XMLSchema}字符串“/>
*attribute name=“href”use=“required”type=”{http://www.w3.org/2001/XMLSchema}anyURI“/>
*属性名称=“类型”类型=”{http://www.w3.org/2001/XMLSchema}字符串“/>
*属性名称=“hreflang”类型=”{http://www.w3.org/2001/XMLSchema}NMTOKEN“/>
*属性名称=“title”类型=”{http://www.w3.org/2001/XMLSchema}字符串“/>
*属性名称=“长度”类型=”{http://www.w3.org/2001/XMLSchema}正整数“/>
*anyAttribute名称空间='##其他'/>
*/限制>
*/complexContent>
*/complexType>
* 
* 
* 
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name=“linkType”,比例器={
“内容”
})
@生成作业生成器
公共类链接类型
实现等于,ToString
{
@XmlValue
受保护的字符串内容;
@XmlAttribute(name=“rel”)
受保护字符串rel;
@XmlAttribute(name=“href”,required=true)
@XmlSchemaType(name=“anyURI”)
受保护字符串href;
@XmlAttribute(name=“type”)
保护字符串类型;
@XmlAttribute(name=“hreflang”)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name=“NMTOKEN”)
保护串法兰;
@XmlAttribute(name=“title”)
受保护的字符串标题;
@XmlAttribute(name=“length”)
@XmlSchemaType(name=“positiveInteger”)
受保护的整数长度;
@XmlAttribute(name=“base”,命名空间=”http://www.w3.org/XML/1998/namespace")
@XmlSchemaType(name=“anyURI”)
保护线脚;
@XmlAttribute(name=“lang”,命名空间=”http://www.w3.org/XML/1998/namespace")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name=“language”)
保护字符串语言;
@XmlAnyAttribute
私有映射otherAttributes=newhashmap();
/**
* 
*Atom链接构造在格式规范的第3.4节中定义。
*             
* 
*@返回
*可能的对象是
*{@link String}
*     
*/
公共字符串getContent(){
返回内容;
}
/**
*设置内容属性的值。
* 
*@param值
*允许的对象是
*{@link String}
*     
*/
公共void setContent(字符串值){
这个。内容=价值;
}
/**
*获取rel属性的值。
* 
*@返回
*可能的对象是
*{@link String}
*     
*/
公共字符串getRel(){
返回rel;
}
/**
*设置rel属性的值。
* 
*@param值
*允许的对象是
*{@link String}
*     
*/
公共void setRel(字符串值){
this.rel=值;
}
/**
*获取href属性的值。
* 
*@返回
*可能的对象是
*{@link String}
*     
*/
公共字符串getHref(){
返回href;
}
/**
*设置href属性的值。
* 
*@param值
*允许的对象是
*{@link String}
*     
*/
公共void setHref(字符串值){
this.href=值;
}
/**
*获取类型属性的值。
* 
*@返回
*可能的对象是
*{@link String}
*     
*/
公共字符串getType(){
返回类型;
}
/**
*设置类型属性的值。
* 
*@param值
*允许的对象是
*{@link String}
*     
*/
公共void集合类型(字符串值){
this.type=值;
}
/**
*获取hreflang属性的值。
* 
*@返回
*可能的对象是
*{@link String}
*     
*/
公共字符串getHreflang(){
回程;
}
/**
*设置hreflang属性的值。
* 
*@param值
*阿洛韦
<atom:link rel="self" href="/accounts/123456XZ" type="application/xml"></atom:link>
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.6 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2013.08.19 at 12:28:23 PM BST 
//


package org.w3._2005.atom;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.namespace.QName;
import net.karneim.pojobuilder.GeneratePojoBuilder;
import org.jvnet.jaxb2_commons.lang.Equals;
import org.jvnet.jaxb2_commons.lang.EqualsStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBEqualsStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy;
import org.jvnet.jaxb2_commons.lang.ToString;
import org.jvnet.jaxb2_commons.lang.ToStringStrategy;
import org.jvnet.jaxb2_commons.locator.ObjectLocator;
import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;


/**
 * 
 *                 The Atom link construct is defined in section 3.4 of the format spec.
 *             
 * 
 * <p>Java class for linkType complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="linkType">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 *       &lt;attribute name="rel" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       &lt;attribute name="href" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
 *       &lt;attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       &lt;attribute name="hreflang" type="{http://www.w3.org/2001/XMLSchema}NMTOKEN" />
 *       &lt;attribute name="title" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       &lt;attribute name="length" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
 *       &lt;anyAttribute namespace='##other'/>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "linkType", propOrder = {
    "content"
})
@GeneratePojoBuilder
public class LinkType
    implements Equals, ToString
{

    @XmlValue
    protected String content;
    @XmlAttribute(name = "rel")
    protected String rel;
    @XmlAttribute(name = "href", required = true)
    @XmlSchemaType(name = "anyURI")
    protected String href;
    @XmlAttribute(name = "type")
    protected String type;
    @XmlAttribute(name = "hreflang")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "NMTOKEN")
    protected String hreflang;
    @XmlAttribute(name = "title")
    protected String title;
    @XmlAttribute(name = "length")
    @XmlSchemaType(name = "positiveInteger")
    protected BigInteger length;
    @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace")
    @XmlSchemaType(name = "anyURI")
    protected String base;
    @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "language")
    protected String lang;
    @XmlAnyAttribute
    private Map<QName, String> otherAttributes = new HashMap<QName, String>();

    /**
     * 
     *                 The Atom link construct is defined in section 3.4 of the format spec.
     *             
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getContent() {
        return content;
    }

    /**
     * Sets the value of the content property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setContent(String value) {
        this.content = value;
    }

    /**
     * Gets the value of the rel property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getRel() {
        return rel;
    }

    /**
     * Sets the value of the rel property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setRel(String value) {
        this.rel = value;
    }

    /**
     * Gets the value of the href property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getHref() {
        return href;
    }

    /**
     * Sets the value of the href property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setHref(String value) {
        this.href = value;
    }

    /**
     * Gets the value of the type property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getType() {
        return type;
    }

    /**
     * Sets the value of the type property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setType(String value) {
        this.type = value;
    }

    /**
     * Gets the value of the hreflang property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getHreflang() {
        return hreflang;
    }

    /**
     * Sets the value of the hreflang property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setHreflang(String value) {
        this.hreflang = value;
    }

    /**
     * Gets the value of the title property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getTitle() {
        return title;
    }

    /**
     * Sets the value of the title property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setTitle(String value) {
        this.title = value;
    }

    /**
     * Gets the value of the length property.
     * 
     * @return
     *     possible object is
     *     {@link BigInteger }
     *     
     */
    public BigInteger getLength() {
        return length;
    }

    /**
     * Sets the value of the length property.
     * 
     * @param value
     *     allowed object is
     *     {@link BigInteger }
     *     
     */
    public void setLength(BigInteger value) {
        this.length = value;
    }

    /**
     * Gets the value of the base property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getBase() {
        return base;
    }

    /**
     * Sets the value of the base property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setBase(String value) {
        this.base = value;
    }

    /**
     * Gets the value of the lang property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLang() {
        return lang;
    }

    /**
     * Sets the value of the lang property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLang(String value) {
        this.lang = value;
    }

    /**
     * Gets a map that contains attributes that aren't bound to any typed property on this class.
     * 
     * <p>
     * the map is keyed by the name of the attribute and 
     * the value is the string value of the attribute.
     * 
     * the map returned by this method is live, and you can add new attribute
     * by updating the map directly. Because of this design, there's no setter.
     * 
     * 
     * @return
     *     always non-null
     */
    public Map<QName, String> getOtherAttributes() {
        return otherAttributes;
    }

    public String toString() {
        final ToStringStrategy strategy = JAXBToStringStrategy.INSTANCE;
        final StringBuilder buffer = new StringBuilder();
        append(null, buffer, strategy);
        return buffer.toString();
    }

    public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) {
        strategy.appendStart(locator, this, buffer);
        appendFields(locator, buffer, strategy);
        strategy.appendEnd(locator, this, buffer);
        return buffer;
    }

    public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) {
        {
            String theContent;
            theContent = this.getContent();
            strategy.appendField(locator, this, "content", buffer, theContent);
        }
        {
            String theRel;
            theRel = this.getRel();
            strategy.appendField(locator, this, "rel", buffer, theRel);
        }
        {
            String theHref;
            theHref = this.getHref();
            strategy.appendField(locator, this, "href", buffer, theHref);
        }
        {
            String theType;
            theType = this.getType();
            strategy.appendField(locator, this, "type", buffer, theType);
        }
        {
            String theHreflang;
            theHreflang = this.getHreflang();
            strategy.appendField(locator, this, "hreflang", buffer, theHreflang);
        }
        {
            String theTitle;
            theTitle = this.getTitle();
            strategy.appendField(locator, this, "title", buffer, theTitle);
        }
        {
            BigInteger theLength;
            theLength = this.getLength();
            strategy.appendField(locator, this, "length", buffer, theLength);
        }
        {
            String theBase;
            theBase = this.getBase();
            strategy.appendField(locator, this, "base", buffer, theBase);
        }
        {
            String theLang;
            theLang = this.getLang();
            strategy.appendField(locator, this, "lang", buffer, theLang);
        }
        return buffer;
    }

    public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) {
        if (!(object instanceof LinkType)) {
            return false;
        }
        if (this == object) {
            return true;
        }
        final LinkType that = ((LinkType) object);
        {
            String lhsContent;
            lhsContent = this.getContent();
            String rhsContent;
            rhsContent = that.getContent();
            if (!strategy.equals(LocatorUtils.property(thisLocator, "content", lhsContent), LocatorUtils.property(thatLocator, "content", rhsContent), lhsContent, rhsContent)) {
                return false;
            }
        }
        {
            String lhsRel;
            lhsRel = this.getRel();
            String rhsRel;
            rhsRel = that.getRel();
            if (!strategy.equals(LocatorUtils.property(thisLocator, "rel", lhsRel), LocatorUtils.property(thatLocator, "rel", rhsRel), lhsRel, rhsRel)) {
                return false;
            }
        }
        {
            String lhsHref;
            lhsHref = this.getHref();
            String rhsHref;
            rhsHref = that.getHref();
            if (!strategy.equals(LocatorUtils.property(thisLocator, "href", lhsHref), LocatorUtils.property(thatLocator, "href", rhsHref), lhsHref, rhsHref)) {
                return false;
            }
        }
        {
            String lhsType;
            lhsType = this.getType();
            String rhsType;
            rhsType = that.getType();
            if (!strategy.equals(LocatorUtils.property(thisLocator, "type", lhsType), LocatorUtils.property(thatLocator, "type", rhsType), lhsType, rhsType)) {
                return false;
            }
        }
        {
            String lhsHreflang;
            lhsHreflang = this.getHreflang();
            String rhsHreflang;
            rhsHreflang = that.getHreflang();
            if (!strategy.equals(LocatorUtils.property(thisLocator, "hreflang", lhsHreflang), LocatorUtils.property(thatLocator, "hreflang", rhsHreflang), lhsHreflang, rhsHreflang)) {
                return false;
            }
        }
        {
            String lhsTitle;
            lhsTitle = this.getTitle();
            String rhsTitle;
            rhsTitle = that.getTitle();
            if (!strategy.equals(LocatorUtils.property(thisLocator, "title", lhsTitle), LocatorUtils.property(thatLocator, "title", rhsTitle), lhsTitle, rhsTitle)) {
                return false;
            }
        }
        {
            BigInteger lhsLength;
            lhsLength = this.getLength();
            BigInteger rhsLength;
            rhsLength = that.getLength();
            if (!strategy.equals(LocatorUtils.property(thisLocator, "length", lhsLength), LocatorUtils.property(thatLocator, "length", rhsLength), lhsLength, rhsLength)) {
                return false;
            }
        }
        {
            String lhsBase;
            lhsBase = this.getBase();
            String rhsBase;
            rhsBase = that.getBase();
            if (!strategy.equals(LocatorUtils.property(thisLocator, "base", lhsBase), LocatorUtils.property(thatLocator, "base", rhsBase), lhsBase, rhsBase)) {
                return false;
            }
        }
        {
            String lhsLang;
            lhsLang = this.getLang();
            String rhsLang;
            rhsLang = that.getLang();
            if (!strategy.equals(LocatorUtils.property(thisLocator, "lang", lhsLang), LocatorUtils.property(thatLocator, "lang", rhsLang), lhsLang, rhsLang)) {
                return false;
            }
        }
        return true;
    }

    public boolean equals(Object object) {
        final EqualsStrategy strategy = JAXBEqualsStrategy.INSTANCE;
        return equals(null, null, object, strategy);
    }

}
import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
public class Link {

    @XmlAttribute(namespace="http://www.w3.org/2005/Atom")
    private String rel;

    @XmlAttribute(namespace="http://www.w3.org/2005/Atom")
    private String href;

    @XmlAttribute(namespace="http://www.w3.org/2005/Atom")
    private String type;

}
import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
public class Link {

    @XmlAttribute
    private String rel;

    @XmlAttribute
    private String href;

    @XmlAttribute
    private String type;

}