我是jaxb的新手,我有这样的xml:
<testSuite name="suite1">
<testCase name = "testCase1">
<step name = "user">
<driverlicence>true</driverlicence>
<driversMinAge>18</driversMinAge>
<driversMinExperience>2</driversMinExperience>
<city_regestration>Boston</city_regestration>
</step>
<step name = "car">
<model>Ford</model>
<make>Focus</make>
<engineHorsepower>/resources/metadata/car_meta</engineHorsepower>
<modification>/resources/metadata/car_meta</modification>
</step>
<step name = "fullquota">
<driversListType>multidrive</driversListType>
</step>
</testCase>
<testCase name = "testCase2">
<step name = "user">
<driverlicence>false</driverlicence>
<driversMinAge>21</driversMinAge>
<driversMinExperience>11</driversMinExperience>
<city_regestration>LA</city_regestration>
</step>
<step name = "car">
<model>Audi</model>
<make>A6</make>
<engineHorsepower>user_meta</engineHorsepower>
<modification>user_meta</modification>
</step>
<step name = "fullquota">
<driversListType>nonemultidrive</driversListType>
</step>
</testCase>
</testSuite>
此外,我还有一个类,我想要映射到上面的xml:
@XmlRootElement(name="testSuite")
public class TestSuite {
private TestCase testcase;
public class TestCase {
private Step step;
public class Step {
Map<String, String> metaData = new HashMap<String, String>();
} //End of StepClass
@XmlAnyElement
public void setStep(Step step) { this.step = step; }
} //End of TestCase class
@XmlElement(name="testCase")
public void setTestcase(TestCase testcase) { this.testcase = testcase; }
}
这个类有一些内部类,内部嵌套到内部类。
我需要将我的xml文档传输到对象TestSuite类。一个重要的是,我从来不知道我会在<step>
标签之间记下多少和哪种类型的文件。
我需要在step
标记