-1

次のXMLを取得しました

<webservice>
  <object name="exe" type="Exercise" id="197999416">
    <prop type="Timestamp" name="created">2013-09-10T18:23:09.000</prop>
    <prop type="Timestamp" name="creationDate">2013-09-10T18:23:09.000</prop>
    <prop type="String" name="description"/>
    <ref name="exerciseProgram" type="ExerciseProgram"/>
    <object name="feed" type="Feed"/>
    <prop type="Boolean" name="hasWeight">false</prop>
    <prop type="String" name="name"/>
    <prop type="String" name="note"/>
    <object name="result" type="Result">
      <object name="activityInfo" type="ActivityInfo"/>
      <object name="altitude" type="AltitudeRange" id="10601842">
        <prop type="MetersFeets" name="avg">874.0</prop>
        <prop type="MetersFeets" name="max">889.0</prop>
        <prop type="MetersFeets" name="min">856.0</prop>
      </object>
      <object name="altitudeInfo" type="AltitudeInfo" id="11988106">
        <prop type="MetersFeets" name="ascent">50.0</prop>
        <prop type="Number" name="declineMax"/>
        <prop type="MetersFeets" name="descent">50.0</prop>
        <prop type="Number" name="inclineMax"/>
        <prop type="MetersFeets" name="vspeedDownAvg"/>
        <prop type="MetersFeets" name="vspeedDownMax"/>
        <prop type="MetersFeets" name="vspeedUpAvg"/>
        <prop type="MetersFeets" name="vspeedUpMax"/>
      </object>
      <map name="autolapAnnotations"/>
      <prop type="Number" name="autolapCount"/>
      <list name="autolaps"/>
      <list name="baseZones"/>
      <prop type="Number" name="calories">194</prop>
      <prop type="Distance" name="distance">7080.0</prop>
      <prop type="Duration" name="duration">00:36:31.200</prop>
      <set name="equipments">
        <ref type="Equipment" id="350901"/>
      </set>
      <ref name="exercise" type="Exercise" id="197999416"/>
      <prop type="Number" name="fatConsumption">28</prop>
      <object name="feedback" type="TrainingFeedback">
        <prop type="TrainingFeedbackType" name="feedback">STEADY_STATE_AND_TEMPO_TRAINING</prop>
        <list name="zones">
          <item index="0" type="HeartRateZone">
            <prop type="Number" name="expenditure"/>
            <prop type="Number" name="index">0</prop>
            <prop type="Duration" name="inzone">00:00:09</prop>
            <prop type="Number" name="lower"/>
            <prop type="Number" name="upper"/>
          </item>
          <item index="1" type="HeartRateZone">
            <prop type="Number" name="expenditure"/>
            <prop type="Number" name="index">0</prop>
            <prop type="Duration" name="inzone">00:14:30</prop>
            <prop type="Number" name="lower"/>
            <prop type="Number" name="upper"/>
          </item>
          <item index="2" type="HeartRateZone">
            <prop type="Number" name="expenditure"/>
            <prop type="Number" name="index">0</prop>
            <prop type="Duration" name="inzone">00:11:54</prop>
            <prop type="Number" name="lower"/>
            <prop type="Number" name="upper"/>
          </item>
          <item index="3" type="HeartRateZone">
            <prop type="Number" name="expenditure"/>
            <prop type="Number" name="index">0</prop>
            <prop type="Duration" name="inzone">00:09:58</prop>
            <prop type="Number" name="lower"/>
            <prop type="Number" name="upper"/>
          </item>
          <item index="4" type="HeartRateZone">
            <prop type="Number" name="expenditure"/>
            <prop type="Number" name="index">0</prop>
            <prop type="Duration" name="inzone">00:00:00</prop>
            <prop type="Number" name="lower"/>
            <prop type="Number" name="upper"/>
          </item>
        </list>
      </object>
      <prop type="Number" name="feeling"/>
      <prop type="Boolean" name="fromWristUnit">true</prop>
      <prop type="heartrate" name="hrAvg">132</prop>
      <prop type="heartrate" name="hrMax">154</prop>
      <prop type="heartrate" name="hrMin">107</prop>
      <prop type="Number" name="id">197999416</prop>
      <map name="lapAnnotations"/>
      <object name="lapCommentRecap" type="LapCommentRecap"/>
      <prop type="Number" name="lapCount"/>
      <list name="laps"/>
      <prop type="Timestamp" name="lastModified">2013-09-10T18:23:09.000</prop>
      <list name="limits"/>
      <prop type="Number" name="maxLimit"/>
      <prop type="Number" name="minLimit"/>
      <prop type="Number" name="moveCount"/>
      <list name="moves"/>
      <list name="phases"/>
      <object name="power" type="Power"/>
      <prop type="Number" name="recordingRate">1</prop>
      <prop type="Duration" name="recoveryTime">03:00:00</prop>
      <prop type="Duration" name="ridingTime">00:25:02.200</prop>
      <prop type="Number" name="runningIndex"/>
<object name="speed" type="Speed">
        <prop type="Number" name="cadenceAvg"/>
        <prop type="Number" name="cadenceMax"/>
        <prop type="Number" name="id">79248070</prop>
        <prop type="Pace" name="paceAvg">05:07</prop>
        <prop type="Pace" name="paceMax">01:29</prop>
        <prop type="SpeedKmHmph" name="speedAvg">11.7</prop>
        <prop type="SpeedKmHmph" name="speedMax">40.3</prop>
        <prop type="SpeedType" name="type">CYCLING</prop>
      </object>
      <prop type="Number" name="strideLengthAvg"/>
      <object name="summaryZone" type="FullZone"/>
      <object name="temperature" type="TemperatureRange"/>
      <prop type="Duration" name="timeAbove100BPM">00:36:31</prop>
      <prop type="Number" name="totalTimeInZone" read-only="true">2191000</prop>
      <prop type="Number" name="trainingLoad">45.4544</prop>
      <object name="userSettings" type="UserSettings">
        <prop type="Number" name="aerobicThreshold">130</prop>
        <prop type="Number" name="anaerobicThreshold">156</prop>
        <prop type="Number" name="height">153.0</prop>
        <prop type="Number" name="hrMax">180</prop>
        <prop type="Number" name="hrRest">70</prop>
        <prop type="Number" name="vo2max">30</prop>
        <prop type="Number" name="weight">61.0</prop>
      </object>
      <ref name="wristUnit" type="WristUnit" id="174"/>
      <list name="zones">
        <item index="0" type="HeartRateZone">
          <prop type="Number" name="expenditure"/>
          <prop type="Number" name="index">0</prop>
          <prop type="Duration" name="inzone">00:00:09</prop>
          <prop type="Number" name="lower">90</prop>
          <prop type="Number" name="upper">108</prop>
        </item>
        <item index="1" type="HeartRateZone">
          <prop type="Number" name="expenditure"/>
          <prop type="Number" name="index">0</prop>
          <prop type="Duration" name="inzone">00:14:30</prop>
          <prop type="Number" name="lower">108</prop>
          <prop type="Number" name="upper">126</prop>
        </item>
        <item index="2" type="HeartRateZone">
          <prop type="Number" name="expenditure"/>
          <prop type="Number" name="index">0</prop>
          <prop type="Duration" name="inzone">00:11:54</prop>
          <prop type="Number" name="lower">126</prop>
          <prop type="Number" name="upper">144</prop>
        </item>
        <item index="3" type="HeartRateZone">
          <prop type="Number" name="expenditure"/>
          <prop type="Number" name="index">0</prop>
          <prop type="Duration" name="inzone">00:09:58</prop>
          <prop type="Number" name="lower">144</prop>
          <prop type="Number" name="upper">162</prop>
        </item>
        <item index="4" type="HeartRateZone">
          <prop type="Number" name="expenditure"/>
          <prop type="Number" name="index">0</prop>
          <prop type="Duration" name="inzone">00:00:00</prop>
          <prop type="Number" name="lower">162</prop>
          <prop type="Number" name="upper">180</prop>
        </item>
      </list>
    </object>
    <prop type="String" name="shortName"/>
    <object name="sport" type="Sport" id="6163057">
      <prop type="Number" name="commonSportId"/>
      <ref name="icon" type="SportIcon" id="6163057"/>
      <prop type="String" name="name">Cycling 2</prop>
      <prop type="Boolean" name="preset">true</prop>
      <prop type="String" name="shortName">Cycling 2</prop>
      <prop type="SpeedUnit" name="speedUnit">SPEED</prop>
      <prop type="SportType" name="type">CYCLING</prop>
      <prop type="Timestamp" name="websyncId">2013-09-10T18:22:43.000</prop>
    </object>
    <prop type="Number" name="sportId">0</prop>
    <list name="sportResults"/>
    <prop type="Boolean" name="strength">false</prop>
    <object name="target" type="Target"/>
    <prop type="Timestamp" name="time">2013-09-10T12:14:40.000</prop>
    <prop type="Boolean" name="visible">true</prop>
    <prop type="Timestamp" name="websyncId">2013-09-10T12:14:40.000</prop>
  </object>
</webservice>

Javaオブジェクトにアンマーシャリングしたいのですが、最善の方法は何ですか? 作成されたフィールド、作成日、説明など、1 つのオブジェクトを返す必要があります。

JAXB が機能せず、XSLT 変換を実行したくありません :-(

よろしくMeex

4

1 に答える 1

0

JAXB を使用して XML からオブジェクトを取得するための XmlAdapter を作成できます。別の代替手段は、カスタムの解析を作成することです。

XML アダプターの例を参照

于 2013-09-30T06:45:18.137 に答える