在从xml生成xsd时,mixed =“true”

时间:2015-05-14 10:39:04

标签: java xml intellij-idea xsd

我正在尝试使用intelliJ从现有的XML文件生成XSD。但是生成的xsd有这个''mixed =“true”'属性,我不希望这个属性因为最终生成的类(使用xjc)现在包含其成员作为我不想要的Serializable属性。有谁知道我怎么能阻止这个?

XML文件 -

<Bundle-SymbolicName>servicebus</Bundle-SymbolicName>

生成的XSD -

<?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>

生成类 -

<?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>

1 个答案:

答案 0 :(得分:1)

<dependency>``</dependency>中删除空白区域,并将其提及为<dependency/>

  • mixed = true当需要允许父元素的子元素之间的某些字符时出现,在这种情况下,父元素为dependency。所以我假设dependency元素中有一个像空格一样的字符。