Java 混合=”;“真的”;从xml生成xsd时

Java 混合=”;“真的”;从xml生成xsd时,java,xml,intellij-idea,xsd,Java,Xml,Intellij Idea,Xsd,我正在尝试使用intelliJ从现有XML文件生成XSD。但是生成的xsd有这个-'mixed=“true”'属性,我不希望它作为最终生成的类(使用xjc)出现,现在它的成员包含为可序列化属性,这是我不想要的。有人知道我该如何防止这种情况吗 XML文件- <?xml version="1.0" encoding="UTF-8"?> <STEPS> <STEP> <taskId>1</taskId>

我正在尝试使用intelliJ从现有XML文件生成XSD。但是生成的xsd有这个-'mixed=“true”'属性,我不希望它作为最终生成的类(使用xjc)出现,现在它的成员包含为可序列化属性,这是我不想要的。有人知道我该如何防止这种情况吗

XML文件-

<?xml version="1.0" encoding="UTF-8"?>
<STEPS>
    <STEP>
        <taskId>1</taskId>
        <dependency>

        </dependency>
        <task>Sample Step</task>
        <techDetail>SVN Script path</techDetail>
        <description>Sample step</description>
        <comments>No commnets</comments>
    </STEP>
    <STEP>
        <taskId>2</taskId>
        <dependency>
            <dependanttaskId>1</dependanttaskId>
        </dependency>
        <task>Second Sample Step</task>
        <techDetail>SVN Script Path Again</techDetail>
        <description>Sample step 2</description>
        <comments>No comments again</comments>
    </STEP>
    <STEP>
        <taskId>3</taskId>
        <dependency>
            <dependanttaskId>1</dependanttaskId>
            <dependanttaskId>2</dependanttaskId>
        </dependency>
        <task>Third Sample Step</task>
        <techDetail>SVN Script Path Again</techDetail>
        <description>Sample step 3</description>
        <comments>No comments again 3</comments>
    </STEP>
</STEPS>
* * * *列表中允许以下类型的对象 *{@link String} *{@link JAXBElement}{@code} * * */ 公共列表getContent(){ if(content==null){ content=newarraylist(); } 返回此.content; } }
删除
`
中的空白,并将其命名为

  • 当需要允许父元素的子元素之间有一些字符时,mixed=true出现。在这种情况下,父元素是
    依赖项
    。所以我假设在
    依赖项
    元素中存在一个类似空格的字符

按照你的要求做了。但我还是犯了同样的错误。你找到解决办法了吗。我离开了一个星期,没有。但我意识到我用xsd做了错误的事情。我应该先做一个xsd,而不是从XML中派生出来
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="task">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="Sample Step"/>
        <xs:enumeration value="Second Sample Step"/>
        <xs:enumeration value="Third Sample Step"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="comments">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="No commnets"/>
        <xs:enumeration value="No comments again"/>
        <xs:enumeration value="No comments again 3"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="dependency">
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:element ref="dependanttaskId" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="techDetail">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="SVN Script path"/>
        <xs:enumeration value="SVN Script Path Again"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="description">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="Sample step"/>
        <xs:enumeration value="Sample step 2"/>
        <xs:enumeration value="Sample step 3"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="STEP">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="taskId"/>
        <xs:element ref="dependency"/>
        <xs:element ref="task"/>
        <xs:element ref="techDetail"/>
        <xs:element ref="description"/>
        <xs:element ref="comments"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="taskId">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="1"/>
        <xs:enumeration value="2"/>
        <xs:enumeration value="3"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="dependanttaskId">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="1"/>
        <xs:enumeration value="2"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="STEPS">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="STEP" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 
// 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: 2015.05.14 at 04:02:08 PM IST 
//


package generated;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element ref="{}dependanttaskId" maxOccurs="unbounded" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "content"
})
@XmlRootElement(name = "dependency")
public class Dependency {

    @XmlElementRef(name = "dependanttaskId", type = JAXBElement.class, required = false)
    @XmlMixed
    protected List<Serializable> content;

    /**
     * Gets the value of the content property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the content property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getContent().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link String }
     * {@link JAXBElement }{@code <}{@link String }{@code >}
     * 
     * 
     */
    public List<Serializable> getContent() {
        if (content == null) {
            content = new ArrayList<Serializable>();
        }
        return this.content;
    }

}