This page (revision-87) was last changed on 16-Aug-2019 12:51 by Dieter Käppel

This page was created on 18-Aug-2009 22:25 by Dieter Käppel

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
87 16-Aug-2019 12:51 53 KB Dieter Käppel to previous Technologie ==> Technologien
86 16-Aug-2019 12:51 53 KB Dieter Käppel to previous | to last
85 28-Nov-2015 11:16 53 KB Dieter Käppel to previous | to last
84 28-Nov-2015 11:16 53 KB Dieter Käppel to previous | to last
83 18-Feb-2015 09:14 52 KB Dieter Käppel to previous | to last
82 18-Feb-2015 08:51 52 KB Dieter Käppel to previous | to last
81 25-Jul-2014 11:27 52 KB Dieter Käppel to previous | to last

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 595 changed 2 lines
!!Beispiele
!Maven
!!Maven Beispiel
Es liegt folgende XML-Datei als simple.xml vor:
{{{
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://intersult.com/test/simple">
<value>
<some-element>1</some-element>
<some-element>2</some-element>
</value>
<another-value>
<some-element>3</some-element>
<some-element>4</some-element>
<nested>
<value>
<another-element>1</another-element>
<another-element>2</another-element>
<another-element>3</another-element>
</value>
</nested>
</another-value>
</root>
}}}
At line 641 added one line
...
At line 620 changed one line
</plugin>
</plugin>
At line 625 changed one line
Ansonst kann die erzeugte XSD auch verwendet werden, um mit generate-schema in einem weiteren Execution-Schritt die Java-Klassen zu generieren.
Ansonst kann die erzeugte XSD auch verwendet werden, um mit generate-schema in einem weiteren Execution-Schritt die Java-Klassen zu generieren. Dies kann innerhalb der selben Instanz des Build-Plugins abraxas-maven geschehen:
At line 627 changed one line
!Java
{{{
<execution>
<id>generate-schema</id>
<goals>
<goal>generate-schema</goal>
</goals>
<configuration>
<schemas>
<schema>
<xsdPath>${project.build.directory}/generated-sources/simple</xsdPath>
<xsd>file:/${project.build.directory}/generated-resources/xsd/simple.xsd</xsd>
</schema>
</schemas>
</configuration>
</execution>
}}}
Die Klasse Root sieht dann wie folgt aus:
{{{
@Name("root")
@XmlNamespace(value = "http://intersult.com/test/simple", localPart = "root")
public class Root {
private Value value;
private AnotherValue anotherValue;
private URI xmlns;
public Value getValue() {
return value;
}
public void setValue(Value value) {
this.value = value;
}
@Name("another-value")
public AnotherValue getAnotherValue() {
return anotherValue;
}
public void setAnotherValue(AnotherValue anotherValue) {
this.anotherValue = anotherValue;
}
public URI getXmlns() {
return xmlns;
}
public void setXmlns(URI xmlns) {
this.xmlns = xmlns;
}
}
}}}
In einem Test kann nun die Datei simple.xml eingelesen werden:
{{{
@Test
public void testUnmarshal() {
XmlConfig config = new XmlConfig();
config.register(Root.class);
InputStream inputStream = getClass().getResourceAsStream("/simple.xml");
Root root = (Root)Xml.unmarshall(inputStream, config, "/simple.xml");
Assert.assertNotNull(root);
}
}}}
!!Java Beispiel