Skip to content

Instantly share code, notes, and snippets.

@sjaakd
Created January 2, 2014 16:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjaakd/8222007 to your computer and use it in GitHub Desktop.
Save sjaakd/8222007 to your computer and use it in GitHub Desktop.
OGC JAXB project to demonstrate what's needed foor custom factories in MapStruct
<jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc">
<jaxb:globalBindings
fixedAttributeAsConstantProperty="true"
typesafeEnumBase="xs:string"
typesafeEnumMemberName="generateName"
generateIsSetMethod="true"
generateElementProperty="true" >
<xjc:noValidator />
<xjc:noValidatingUnmarshaller />
</jaxb:globalBindings>
<jaxb:bindings schemaLocation="http://www.w3.org/1999/xlink.xsd" node="/xs:schema">
<jaxb:bindings>
<jaxb:bindings node="//xs:attributeGroup[@name='locatorAttrs']/xs:attribute[@ref='xlink:title']">
<jaxb:property name="locatorTitle" />
</jaxb:bindings>
<jaxb:bindings node="//xs:group[@name='arcModel']/xs:sequence/xs:element[@ref='xlink:title']">
<jaxb:property name="arcModelTitle" />
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
<!-- bindings for gml, origin: https://java.net/projects/ogc/sources/svn/show/ogc-schemas/trunk/gml/3.2.1/schema/src/main/resources/ -->
<jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd" node="/xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="net.opengis.gml.v_3_2_1"/>
<jaxb:nameXmlTransform>
<jaxb:elementName suffix="Element"/>
</jaxb:nameXmlTransform>
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/geometryPrimitives.xsd" node="/xs:schema">
<jaxb:bindings>
<jaxb:nameXmlTransform>
<jaxb:elementName suffix="Element"/>
</jaxb:nameXmlTransform>
<jaxb:bindings node="//xs:group[@name='PointGrid']/xs:sequence/xs:element[@name='rows']">
<jaxb:property name="Arows"/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/datums.xsd" node="/xs:schema">
<jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='secondDefiningParameter']">
<jaxb:class name="SecondDefiningParameterPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='ellipsoid']">
<jaxb:factoryMethod name="EllipsoidPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='primeMeridian']">
<jaxb:factoryMethod name="PrimeMeridianPropertyElement"/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/coordinateReferenceSystems.xsd" node="/xs:schema">
<jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='userDefinedCS']">
<jaxb:factoryMethod name="UserDefinedCSPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='cartesianCS']">
<jaxb:factoryMethod name="CartesianCSPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='sphericalCS']">
<jaxb:factoryMethod name="SphericalCSPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='polarCS']">
<jaxb:factoryMethod name="PolarCSPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='linearCS']">
<jaxb:factoryMethod name="LinearCSPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='verticalCS']">
<jaxb:factoryMethod name="VerticalCSPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='cylindricalCS']">
<jaxb:factoryMethod name="CylindricalCSPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='ellipsoidalCS']">
<jaxb:factoryMethod name="EllipsoidalCSPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='affineCS']">
<jaxb:factoryMethod name="AffineCSPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='timeCS']">
<jaxb:factoryMethod name="TimeCSPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='imageDatum']">
<jaxb:factoryMethod name="ImageDatumPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='geodeticDatum']">
<jaxb:factoryMethod name="GeodeticDatumPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='temporalDatum']">
<jaxb:factoryMethod name="TemporalDatumPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='engineeringDatum']">
<jaxb:factoryMethod name="EngineeringDatumPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='verticalDatum']">
<jaxb:factoryMethod name="VerticalDatumPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='conversion']">
<jaxb:factoryMethod name="ConversionPropertyElement"/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/coordinateOperations.xsd" node="/xs:schema">
<jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='coordinateOperationAccuracy']//xs:element[@ref='gmd:AbstractDQ_PositionalAccuracy']">
<xjc:dom/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='parameterValue']">
<jaxb:factoryMethod name="ParameterValuePropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='operationParameter']">
<jaxb:factoryMethod name="OperationParameterPropertyElement"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='formulaCitation']//xs:element[@ref='gmd:CI_Citation']">
<xjc:dom/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/referenceSystems.xsd" node="/xs:schema">
<jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='domainOfValidity']//xs:element[@ref='gmd:EX_Extent']">
<xjc:dom/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
<!-- binding for measure type -->
<jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/basicTypes.xsd" node="/xs:schema">
<jaxb:bindings multiple="true" node="//xs:complexType[@name='MeasureType']">
<jaxb:property>
<jaxb:baseType name="java.math.BigDecimal"/>
</jaxb:property>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>MapStructJaxbExample</artifactId>
<version>1.0-SNAPSHOT</version>
<name>MapStructJaxbExample</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.build.resources[0].directory}/schema/</schemaDirectory>
<schemaIncludes>
<include>**/test.xsd</include> <!-- must be relative to schema -->
</schemaIncludes>
<bindingDirectory>${project.build.resources[0].directory}/META-INF/</bindingDirectory>
<bindingIncludes>
<include>binding.xjb</include>
</bindingIncludes>
<extension>true</extension>
<verbose>true</verbose>
<specVersion>2.1</specVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="utf-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:sa="http://www.opengis.net/sampling/2.0" xmlns:om="http://www.opengis.net/om/2.0"
xmlns:test="http://www.test.nl/xsd/test"
targetNamespace="http://www.test.nl/xsd/test"
elementFormDefault="qualified" version="1.0.0">
<import namespace="http://www.opengis.net/sampling/2.0"
schemaLocation="http://schemas.opengis.net/sampling/2.0/samplingFeature.xsd" />
<import namespace="http://www.opengis.net/gml/3.2"
schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd" />
<import namespace="http://www.opengis.net/om/2.0"
schemaLocation="http://schemas.opengis.net/om/2.0/observation.xsd" />
<element name="SomeFeature" type="test:SomeFeatureType" substitutionGroup="gml:AbstractFeature" />
<complexType name="SomeFeatureType">
<annotation>
<documentation></documentation>
</annotation>
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element name="someId" minOccurs="0" maxOccurs="1">
<simpleType>
<restriction base="string">
<maxLength value="15" />
</restriction>
</simpleType>
</element>
<element name="someName" minOccurs="0" maxOccurs="1">
<simpleType>
<restriction base="string">
<maxLength value="40" />
</restriction>
</simpleType>
</element>
<element name="function" type="gml:CodeType" minOccurs="1" maxOccurs="1" />
<element name="someEmbedded" type="test:SomeEmbeddedType" minOccurs="1" maxOccurs="unbounded" />
<element name="position" type="gml:PointType" minOccurs="1" maxOccurs="1" />
</sequence>
</extension>
</complexContent>
</complexType>
<element name="SomeEmbedded" type="test:SomeEmbeddedType" />
<complexType name="SomeEmbeddedType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element name="someEmbeddedNr" minOccurs="0" maxOccurs="1">
<simpleType>
<restriction base="string">
<maxLength value="3" />
</restriction>
</simpleType>
</element>
</sequence>
</extension>
</complexContent>
</complexType>
</schema>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment