使用intelliJ从xsd生成java类

时间:2014-12-08 15:11:47

标签: java xml intellij-idea xsd

我试图使用IntelliJ从一些xml创建java类 - 我正在做的步骤如下:

  1. 通过浏览器从指定的合作伙伴网址保存xml
  2. 使用IntelliJ从XML文件生成XSD架构
  3. 使用IntelliJ从xsd文件生成java类
  4. 我的问题是,唯一发生的事情是它创建指定的包并将xsd复制到这个包 - 没有java类。

    xml im下载看起来像这样

    <?xml version="1.0" encoding="UTF-8"?>
    <oxip version="7.1" created="2014-12-08 15:23:34" lastMsgId="" requestTime="0.1790">
    <response request="getPools" code="001" message="success" debug="" provider="GENERIC">
    <disclaimer>
    </disclaimer>
    <pool id="1081" name="Auto Pool-2014-12-02 09:00:00" poolType="TF12" poolTypeId="12" jackpot="N" provider="Internal" fracBetsAvail="Y" quickPicksAvail="Y" reduceSysAvail="Y" displayOrder="" typeDisplayOrder="1" subsAvail="N" maxSubs="3" numPicks="12" currency="DKK" url="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:19" opensAt="2014-12-02 09:00:00" closesAt="2014-12-08 20:00:00">
    <poolLink id="1082" relationship="child" type="H1"/>
    <poolPrizes>
    <prize numCorrect="10" winners="0" guarantee="0" value="11.70" size="11.7"/>
    <prize numCorrect="11" winners="0" guarantee="0" value="35.10" size="35.1"/>
    <prize numCorrect="12" winners="0" guarantee="0" value="70.20" size="70.2"/>
    </poolPrizes>
    <event id="16382" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Blackpool v Bordeaux" url="/e/16382" date="2014-12-09" time="22:00:00" betTillDate="2014-12-09" betTillTime="22:00:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:10">
    </event>
    <event id="16383" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Clydebank v Ayr United" url="/e/16383" date="2014-12-09" time="22:10:00" betTillDate="2014-12-09" betTillTime="22:10:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:16">
    </event>
    <event id="16384" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Barcelona v Bournemouth" url="/e/16384" date="2014-12-09" time="22:20:00" betTillDate="2014-12-09" betTillTime="22:20:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:16">
    </event>
    <event id="16385" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Derby v Bristol Rovers" url="/e/16385" date="2014-12-09" time="22:30:00" betTillDate="2014-12-09" betTillTime="22:30:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:16">
    </event>
    <event id="16386" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Crystal Palace v Clyde" url="/e/16386" date="2014-12-09" time="22:40:00" betTillDate="2014-12-09" betTillTime="22:40:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:17">
    </event>
    <event id="16387" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Blackpool v Darlington" url="/e/16387" date="2014-12-09" time="22:50:00" betTillDate="2014-12-09" betTillTime="22:50:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:18">
    </event>
    <event id="16388" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Cambridge v Arbroath" url="/e/16388" date="2014-12-09" time="23:00:00" betTillDate="2014-12-09" betTillTime="23:00:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:18">
    </event>
    <event id="16389" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Clydebank v Aston Villa" url="/e/16389" date="2014-12-09" time="23:10:00" betTillDate="2014-12-09" betTillTime="23:10:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:18">
    </event>
    <event id="16390" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Belgien v Cheltenham" url="/e/16390" date="2014-12-09" time="23:20:00" betTillDate="2014-12-09" betTillTime="23:20:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:18">
    </event>
    <event id="16391" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Bournemouth v Coventry" url="/e/16391" date="2014-12-09" time="23:30:00" betTillDate="2014-12-09" betTillTime="23:30:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:18">
    </event>
    <event id="16392" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Deportivo v Chester" url="/e/16392" date="2014-12-09" time="23:40:00" betTillDate="2014-12-09" betTillTime="23:40:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:18">
    </event>
    <event id="16393" classId="97" typeId="13304" typeName="Premijer Liga" displayOrder="0" displayed="Y" name="Chesterfield v Aberdeen" url="/e/16393" date="2014-12-09" time="23:50:00" betTillDate="2014-12-09" betTillTime="23:50:00" suspend="" status="A" channels="IMR" country="" flags="FE" raceNumber="" lastUpdateDate="2014-12-01" lastUpdateTime="09:00:18">
    </event>
    </pool>
    </response>
    </oxip>
    

    并且xsd看起来像这样

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="oxip" type="oxipType"/>
      <xs:complexType name="oxipType">
        <xs:sequence>
          <xs:element type="responseType" name="response"/>
        </xs:sequence>
        <xs:attribute type="xs:float" name="version"/>
        <xs:attribute type="xs:string" name="created"/>
        <xs:attribute type="xs:string" name="lastMsgId"/>
        <xs:attribute type="xs:float" name="requestTime"/>
      </xs:complexType>
      <xs:complexType name="poolType">
        <xs:sequence>
          <xs:element type="poolLinkType" name="poolLink"/>
          <xs:element type="poolPrizesType" name="poolPrizes"/>
          <xs:element type="eventType" name="event" maxOccurs="unbounded" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute type="xs:short" name="id"/>
        <xs:attribute type="xs:string" name="name"/>
        <xs:attribute type="xs:string" name="poolType"/>
        <xs:attribute type="xs:byte" name="poolTypeId"/>
        <xs:attribute type="xs:string" name="jackpot"/>
        <xs:attribute type="xs:string" name="provider"/>
        <xs:attribute type="xs:string" name="fracBetsAvail"/>
        <xs:attribute type="xs:string" name="quickPicksAvail"/>
        <xs:attribute type="xs:string" name="reduceSysAvail"/>
        <xs:attribute type="xs:string" name="displayOrder"/>
        <xs:attribute type="xs:byte" name="typeDisplayOrder"/>
        <xs:attribute type="xs:string" name="subsAvail"/>
        <xs:attribute type="xs:byte" name="maxSubs"/>
        <xs:attribute type="xs:byte" name="numPicks"/>
        <xs:attribute type="xs:string" name="currency"/>
        <xs:attribute type="xs:string" name="url"/>
        <xs:attribute type="xs:date" name="lastUpdateDate"/>
        <xs:attribute type="xs:time" name="lastUpdateTime"/>
        <xs:attribute type="xs:string" name="opensAt"/>
        <xs:attribute type="xs:string" name="closesAt"/>
      </xs:complexType>
      <xs:complexType name="poolPrizesType">
        <xs:sequence>
          <xs:element type="prizeType" name="prize" maxOccurs="unbounded" minOccurs="0"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="responseType">
        <xs:sequence>
          <xs:element type="xs:string" name="disclaimer"/>
          <xs:element type="poolType" name="pool"/>
        </xs:sequence>
        <xs:attribute type="xs:string" name="request"/>
        <xs:attribute type="xs:byte" name="code"/>
        <xs:attribute type="xs:string" name="message"/>
        <xs:attribute type="xs:string" name="debug"/>
        <xs:attribute type="xs:string" name="provider"/>
      </xs:complexType>
      <xs:complexType name="poolLinkType">
        <xs:simpleContent>
          <xs:extension base="xs:string">
            <xs:attribute type="xs:short" name="id"/>
            <xs:attribute type="xs:string" name="relationship"/>
            <xs:attribute type="xs:string" name="type"/>
          </xs:extension>
        </xs:simpleContent>
      </xs:complexType>
      <xs:complexType name="eventType">
        <xs:simpleContent>
          <xs:extension base="xs:string">
            <xs:attribute type="xs:short" name="id" use="optional"/>
            <xs:attribute type="xs:byte" name="classId" use="optional"/>
            <xs:attribute type="xs:short" name="typeId" use="optional"/>
            <xs:attribute type="xs:string" name="typeName" use="optional"/>
            <xs:attribute type="xs:byte" name="displayOrder" use="optional"/>
            <xs:attribute type="xs:string" name="displayed" use="optional"/>
            <xs:attribute type="xs:string" name="name" use="optional"/>
            <xs:attribute type="xs:string" name="url" use="optional"/>
            <xs:attribute type="xs:date" name="date" use="optional"/>
            <xs:attribute type="xs:time" name="time" use="optional"/>
            <xs:attribute type="xs:date" name="betTillDate" use="optional"/>
            <xs:attribute type="xs:time" name="betTillTime" use="optional"/>
            <xs:attribute type="xs:string" name="suspend" use="optional"/>
            <xs:attribute type="xs:string" name="status" use="optional"/>
            <xs:attribute type="xs:string" name="channels" use="optional"/>
            <xs:attribute type="xs:string" name="country" use="optional"/>
            <xs:attribute type="xs:string" name="flags" use="optional"/>
            <xs:attribute type="xs:string" name="raceNumber" use="optional"/>
            <xs:attribute type="xs:date" name="lastUpdateDate" use="optional"/>
            <xs:attribute type="xs:time" name="lastUpdateTime" use="optional"/>
          </xs:extension>
        </xs:simpleContent>
      </xs:complexType>
      <xs:complexType name="prizeType">
        <xs:simpleContent>
          <xs:extension base="xs:string">
            <xs:attribute type="xs:byte" name="numCorrect" use="optional"/>
            <xs:attribute type="xs:byte" name="winners" use="optional"/>
            <xs:attribute type="xs:byte" name="guarantee" use="optional"/>
            <xs:attribute type="xs:float" name="value" use="optional"/>
            <xs:attribute type="xs:float" name="size" use="optional"/>
          </xs:extension>
        </xs:simpleContent>
      </xs:complexType>
    </xs:schema>
    

    有人可以向我解释为什么我不能从上面生成java类吗?

1 个答案:

答案 0 :(得分:0)

因为xsd

中的以下行
<xs:attribute type="xs:float" name="value" use="optional"/>

因为值已在'datatypes.jar'某处

中定义