Author: desruisseaux
Date: Sun Feb 18 17:25:11 2018
New Revision: 1824677
URL: http://svn.apache.org/viewvc?rev=1824677&view=rev
Log:
Replace the hard-coded renaming rules in TransformVersion by the use of of
"ImageryExtensions.lst" file (which will need to be renamed).
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/LE_ProcessStep.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/LE_Source.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Band.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_CoverageDescription.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Georectified.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Georeferenceable.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_ImageDescription.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Metadata.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/package-info.java
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultLineageTest.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformVersion.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Transformer.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingNamespaces.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingReader.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingWriter.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/ImageryExtensions.lst
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/LE_ProcessStep.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/LE_ProcessStep.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/LE_ProcessStep.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/LE_ProcessStep.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.lineage.ProcessStep;
import org.apache.sis.metadata.iso.lineage.DefaultProcessStep;
+import org.apache.sis.xml.Namespaces;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
@@ -29,12 +30,12 @@ import static org.apache.sis.util.collec
*
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
-@XmlType(name = "LE_ProcessStep_Type")
-@XmlRootElement(name = "LE_ProcessStep")
+@XmlType(name = "LE_ProcessStep_Type", namespace = Namespaces.MRL)
+@XmlRootElement(name = "LE_ProcessStep", namespace = Namespaces.MRL)
@SuppressWarnings("CloneableClassWithoutClone")
public class LE_ProcessStep extends DefaultProcessStep {
/**
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/LE_Source.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/LE_Source.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/LE_Source.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/LE_Source.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.lineage.Source;
import org.apache.sis.metadata.iso.lineage.DefaultSource;
+import org.apache.sis.xml.Namespaces;
/**
@@ -27,12 +28,12 @@ import org.apache.sis.metadata.iso.linea
*
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
-@XmlType(name = "LE_Source_Type")
-@XmlRootElement(name = "LE_Source")
+@XmlType(name = "LE_Source_Type", namespace = Namespaces.MRL)
+@XmlRootElement(name = "LE_Source", namespace = Namespaces.MRL)
@SuppressWarnings("CloneableClassWithoutClone")
public class LE_Source extends DefaultSource {
/**
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Band.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Band.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Band.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Band.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.content.Band;
import org.apache.sis.metadata.iso.content.DefaultBand;
+import org.apache.sis.xml.Namespaces;
/**
@@ -27,12 +28,12 @@ import org.apache.sis.metadata.iso.conte
*
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
-@XmlType(name = "MI_Band_Type")
-@XmlRootElement(name = "MI_Band")
+@XmlType(name = "MI_Band_Type", namespace = Namespaces.MRC)
+@XmlRootElement(name = "MI_Band", namespace = Namespaces.MRC)
@SuppressWarnings("CloneableClassWithoutClone")
public class MI_Band extends DefaultBand {
/**
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_CoverageDescription.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_CoverageDescription.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_CoverageDescription.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_CoverageDescription.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.content.CoverageDescription;
import org.apache.sis.metadata.iso.content.DefaultCoverageDescription;
+import org.apache.sis.xml.Namespaces;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
@@ -29,12 +30,12 @@ import static org.apache.sis.util.collec
*
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
-@XmlType(name = "MI_CoverageDescription_Type")
-@XmlRootElement(name = "MI_CoverageDescription")
+@XmlType(name = "MI_CoverageDescription_Type", namespace = Namespaces.MRC)
+@XmlRootElement(name = "MI_CoverageDescription", namespace = Namespaces.MRC)
@SuppressWarnings("CloneableClassWithoutClone")
public class MI_CoverageDescription extends DefaultCoverageDescription {
/**
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Georectified.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Georectified.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Georectified.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Georectified.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.spatial.Georectified;
import org.apache.sis.metadata.iso.spatial.DefaultGeorectified;
+import org.apache.sis.xml.Namespaces;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
@@ -29,12 +30,12 @@ import static org.apache.sis.util.collec
*
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
-@XmlType(name = "MI_Georectified_Type")
-@XmlRootElement(name = "MI_Georectified")
+@XmlType(name = "MI_Georectified_Type", namespace = Namespaces.MSR)
+@XmlRootElement(name = "MI_Georectified", namespace = Namespaces.MSR)
@SuppressWarnings("CloneableClassWithoutClone")
public class MI_Georectified extends DefaultGeorectified {
/**
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Georeferenceable.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Georeferenceable.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Georeferenceable.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Georeferenceable.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.spatial.Georeferenceable;
import org.apache.sis.metadata.iso.spatial.DefaultGeoreferenceable;
+import org.apache.sis.xml.Namespaces;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
@@ -29,12 +30,12 @@ import static org.apache.sis.util.collec
*
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
-@XmlType(name = "MI_Georeferenceable_Type")
-@XmlRootElement(name = "MI_Georeferenceable")
+@XmlType(name = "MI_Georeferenceable_Type", namespace = Namespaces.MSR)
+@XmlRootElement(name = "MI_Georeferenceable", namespace = Namespaces.MSR)
@SuppressWarnings("CloneableClassWithoutClone")
public class MI_Georeferenceable extends DefaultGeoreferenceable {
/**
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_ImageDescription.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_ImageDescription.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_ImageDescription.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_ImageDescription.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.content.ImageDescription;
import org.apache.sis.metadata.iso.content.DefaultImageDescription;
+import org.apache.sis.xml.Namespaces;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
@@ -29,12 +30,12 @@ import static org.apache.sis.util.collec
*
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
-@XmlType(name = "MI_ImageDescription_Type")
-@XmlRootElement(name = "MI_ImageDescription")
+@XmlType(name = "MI_ImageDescription_Type", namespace = Namespaces.MRC)
+@XmlRootElement(name = "MI_ImageDescription", namespace = Namespaces.MRC)
@SuppressWarnings("CloneableClassWithoutClone")
public class MI_ImageDescription extends DefaultImageDescription {
/**
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Metadata.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Metadata.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Metadata.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/MI_Metadata.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.Metadata;
import org.apache.sis.metadata.iso.DefaultMetadata;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
@@ -33,8 +34,8 @@ import static org.apache.sis.util.collec
* @since 0.3
* @module
*/
-@XmlType(name = "MI_Metadata_Type")
-@XmlRootElement(name = "MI_Metadata")
+@XmlType(name = "MI_Metadata_Type", namespace = LegacyNamespaces.GMI)
+@XmlRootElement(name = "MI_Metadata", namespace = LegacyNamespaces.GMI)
@SuppressWarnings("CloneableClassWithoutClone")
public class MI_Metadata extends DefaultMetadata {
/**
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/package-info.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/package-info.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/package-info.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gmi/package-info.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -16,8 +16,8 @@
*/
/**
- * Extends some classes from the {@link org.apache.sis.metadata.iso} package
in order
- * to give them the {@code "gmi"} namespace. This is required for XML
(un)marshalling
+ * Extends some classes from {@link org.apache.sis.metadata.iso} packages in
order to give them
+ * the name used by imagery extensions (ISO 19115-2). This is required for XML
(un)marshalling
* because GeoAPI merged some classes which were dissociated in the ISO
specifications.
* The GeoAPI merge were done in order to simplify the conceptual model for
developers,
* since the classes were different in ISO specifications for historical
reasons - not
@@ -32,12 +32,15 @@
*
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
-@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace =
Namespaces.GMI, xmlns = {
- @XmlNs(prefix = "gmi", namespaceURI = Namespaces.GMI)
+@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, xmlns = {
+ @XmlNs(prefix = "mrc", namespaceURI = Namespaces.MRC),
+ @XmlNs(prefix = "mrl", namespaceURI = Namespaces.MRL),
+ @XmlNs(prefix = "msr", namespaceURI = Namespaces.MSR),
+ @XmlNs(prefix = "gmi", namespaceURI = LegacyNamespaces.GMI)
})
@XmlAccessorType(XmlAccessType.NONE)
package org.apache.sis.internal.jaxb.gmi;
@@ -47,4 +50,5 @@ import javax.xml.bind.annotation.XmlNsFo
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
import org.apache.sis.xml.Namespaces;
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultLineageTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultLineageTest.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultLineageTest.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultLineageTest.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -18,6 +18,7 @@ package org.apache.sis.metadata.iso.line
import java.util.Arrays;
import javax.xml.bind.JAXBException;
+import org.apache.sis.xml.Namespaces;
import org.apache.sis.internal.jaxb.LegacyNamespaces;
import org.apache.sis.util.iso.SimpleInternationalString;
import org.apache.sis.metadata.iso.DefaultIdentifier;
@@ -55,6 +56,29 @@ public final strictfp class DefaultLinea
}
/**
+ * Tests the marshalling of a {@code "mrl:LI_Source"} element.
+ * If this case, the test uses only ISO 19115-1 elements (no ISO 19115-2).
+ * Consequently the XML name shall be {@code "mrl:LI_Source"}.
+ *
+ * @throws JAXBException if an error occurred while marshalling the XML.
+ */
+ @Test
+ public void testSource() throws JAXBException {
+ String actual = marshal(create(false));
+ assertXmlEquals(
+ "<mrl:LI_Lineage xmlns:mrl=\"" + Namespaces.MRL + '"' +
+ " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+ " <mrl:source>\n" +
+ " <mrl:LI_Source>\n" +
+ " <mrl:description>\n" +
+ " <gco:CharacterString>Description of source data
level.</gco:CharacterString>\n" +
+ " </mrl:description>\n" +
+ " </mrl:LI_Source>\n" +
+ " </mrl:source>\n" +
+ "</mrl:LI_Lineage>", actual, "xmlns:*");
+ }
+
+ /**
* Tests the marshalling of a legacy {@code "gmd:LI_Source"} element.
* If this case, the test uses only ISO 19115-1 elements (no ISO 19115-2).
* Consequently the legacy XML name shall be {@code "gmd:LI_Source"}.
@@ -62,6 +86,7 @@ public final strictfp class DefaultLinea
* @throws JAXBException if an error occurred while marshalling the XML.
*/
@Test
+ @DependsOnMethod("testSource")
public void testLegacySource() throws JAXBException {
String actual = marshal(create(false), VERSION_2007);
assertXmlEquals(
@@ -78,6 +103,39 @@ public final strictfp class DefaultLinea
}
/**
+ * Tests the marshalling of a {@code "mrl:LE_Source"} element.
+ * This test starts with the same metadata than {@link #testSource()} and
adds an
+ * ISO 19115-2 specific property. Consequently the XML name, which was
originally
+ * {@code "mrl:LI_Source"}, shall become {@code "mrl:LE_Source"}.
+ *
+ * @throws JAXBException if an error occurred while marshalling the XML.
+ */
+ @Test
+ @DependsOnMethod("testSource")
+ public void testSourceImagery() throws JAXBException {
+ String actual = marshal(create(true));
+ assertXmlEquals(
+ "<mrl:LI_Lineage xmlns:mrl=\"" + Namespaces.MRL + '"' +
+ " xmlns:mcc=\"" + Namespaces.MCC + '"' +
+ " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+ " <mrl:source>\n" +
+ " <mrl:LE_Source>\n" +
+ " <mrl:description>\n" +
+ " <gco:CharacterString>Description of source data
level.</gco:CharacterString>\n" +
+ " </mrl:description>\n" +
+ " <mrl:processedLevel>\n" +
+ " <mcc:MD_Identifier>\n" +
+ " <mcc:code>\n" +
+ "
<gco:CharacterString>DummyLevel</gco:CharacterString>\n" +
+ " </mcc:code>\n" +
+ " </mcc:MD_Identifier>\n" +
+ " </mrl:processedLevel>\n" +
+ " </mrl:LE_Source>\n" +
+ " </mrl:source>\n" +
+ "</mrl:LI_Lineage>", actual, "xmlns:*");
+ }
+
+ /**
* Tests the marshalling of a legacy {@code "gmi:LE_Source"} element.
* This test starts with the same metadata than {@link
#testLegacySource()} and adds
* an ISO 19115-2 specific property. Consequently the XML name, which was
originally
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformVersion.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformVersion.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformVersion.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformVersion.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -20,7 +20,6 @@ import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Collections;
-import org.apache.sis.util.Debug;
import org.apache.sis.internal.jaxb.LegacyNamespaces;
@@ -58,6 +57,7 @@ final class TransformVersion {
Namespaces.MD2,
Namespaces.MDA,
Namespaces.MDB,
+ Namespaces.MDQ,
Namespaces.MDS,
Namespaces.MDT,
Namespaces.MEX,
@@ -68,36 +68,16 @@ final class TransformVersion {
Namespaces.MRI,
Namespaces.MRL,
Namespaces.MRS,
+ Namespaces.MSR,
Namespaces.RCE
}, LegacyNamespaces.GMD);
/*
- * SV_OperationMetadata has two properties that are identical except
for the name
- * between ISO 19115-3:2016 and legacy ISO 19139:2007. Instead than
complicating
- * the class with JAXB annotations, we perform the renaming in this
package.
- * We apply the same mechanic to some other namespaces too.
- */
- Replacement r = new Replacement(LegacyNamespaces.SRV, 4);
- r.addProperty("distributedComputingPlatform", "DCP");
- r.addProperty("parameter", "parameters");
- ISO19139.exports.put(Namespaces.SRV, r);
-
- // Metadata for Spatial Representation
- r = new Replacement(LegacyNamespaces.GMD, "centrePoint",
"centerPoint");
- ISO19139.exports.put(Namespaces.MSR, r);
-
- // Metadata for Data Quality
- r = new Replacement(LegacyNamespaces.GMD, "valueRecordType",
"valueType");
- ISO19139.exports.put(Namespaces.MDQ, r);
-
- // Metadata for Acquisition
- r = new Replacement(LegacyNamespaces.GMD, "objectiveOccurence",
"objectiveOccurance");
- ISO19139.exports.put(Namespaces.MAC, r);
- /*
* For the way back from legacy ISO 19139:2007 to new ISO
19115-3:2016, we must rely on TransformingReader
* (do NOT declare entries in 'imports', because some namespaces must
be left unchanged). An exception to
* this rule is the "gco" namespace, because our reader renames only
element namespaces while we need to
* rename also attributes in "gco" namespace (e.g. "gco:nilReason").
*/
+ ISO19139.addSurjective(Namespaces.SRV, LegacyNamespaces.SRV);
ISO19139.addSurjective(Namespaces.GCX, LegacyNamespaces.GMX);
ISO19139.addBijective (Namespaces.GCO, LegacyNamespaces.GCO);
}
@@ -118,71 +98,6 @@ final class TransformVersion {
static final TransformVersion ALL = GML31;
/**
- * The exported namespace used in the XML file instead then the namespaces
used by JAXB annotations.
- * Contains also the properties renamed in that exported namespaces if any.
- */
- static final class Replacement {
- /**
- * The exported namespace (used in XML document).
- */
- final String namespace;
-
- /**
- * The properties having a different name in the exported namespace.
Keys are property names
- * as declared in JAXB annotations, and values are property names used
in the XML document.
- */
- private final Map<String,String> exports;
-
- /**
- * Constructs a replacement for a namespace only (no renamed property).
- */
- Replacement(final String namespace) {
- this.namespace = namespace;
- this.exports = Collections.emptyMap();
- }
-
- /**
- * Constructs a replacement for a namespace with exactly one property
renaming.
- */
- Replacement(final String namespace, final String jaxb, final String
xml) {
- this.namespace = namespace;
- this.exports = Collections.singletonMap(jaxb, xml);
- }
-
- /**
- * Constructs a replacement for a namespace, together with the map of
properties
- * that need to be renamed for that exported namespace.
- */
- Replacement(final String namespace, final int capacity) {
- this.namespace = namespace;
- this.exports = new HashMap<>(capacity);
- }
-
- /**
- * Adds a two-directional association between a property used in JAXB
annotation and a property
- * used in XML document. A bijective association means that the
renaming is reversible.
- */
- final void addProperty(final String jaxb, final String xml) {
- exports.put(jaxb, xml);
- }
-
- /**
- * Converts a property name used in JAXB annotations to a property
name used in XML document.
- */
- final String exportProperty(final String localPart) {
- return exports.getOrDefault(localPart, localPart);
- }
-
- /**
- * Returns the namespace for debugging purpose.
- */
- @Override @Debug
- public String toString() {
- return namespace;
- }
- }
-
- /**
* The URI replacements to apply when going from the model implemented by
Apache SIS
* to the transforming reader/writer. Keys are the URIs as declared in
JAXB annotations,
* and values are the URIs to write instead of the actual ones.
@@ -192,7 +107,7 @@ final class TransformVersion {
*
* @see #exports()
*/
- private final Map<String, Replacement> exports;
+ private final Map<String,String> exports;
/**
* The URI replacements to apply when going from the transforming
reader/writer to
@@ -203,7 +118,7 @@ final class TransformVersion {
* <p>This map shall not be modified after construction.
* We do not wrap in {@link Collections#unmodifiableMap(Map)} for
efficiency.</p>
*/
- private final Map<String, String> imports;
+ private final Map<String,String> imports;
/**
* Creates a new enumeration initialized to the given capacity.
@@ -230,7 +145,7 @@ final class TransformVersion {
* used in XML document. A bijective association means that the renaming
is reversible.
*/
private void addBijective(final String jaxb, final String xml) {
- exports.put(jaxb, new Replacement(xml));
+ exports.put(jaxb, xml);
imports.put(xml, jaxb);
}
@@ -240,7 +155,7 @@ final class TransformVersion {
* ISO 19139:2007 namespace. Consequently this association is not easily
reversible.
*/
private void addSurjective(final String jaxb, final String xml) {
- exports.put(jaxb, new Replacement(xml));
+ exports.put(jaxb, xml);
}
/**
@@ -249,9 +164,8 @@ final class TransformVersion {
* and the new schema (represented by {@code jaxb}) has been separated in
many smaller modules.
*/
private void addSurjectives(final String[] jaxb, final String xml) {
- final Replacement r = new Replacement(xml);
for (final String e : jaxb) {
- exports.put(e, r);
+ exports.put(e, xml);
}
}
@@ -260,8 +174,7 @@ final class TransformVersion {
* Returns the same URI if there is no replacement.
*/
final String exportNS(final String uri) {
- final TransformVersion.Replacement r = exports.get(uri);
- return (r != null) ? r.namespace : uri;
+ return exports.getOrDefault(uri, uri);
}
/**
@@ -273,20 +186,11 @@ final class TransformVersion {
}
/**
- * Converts a namespace used in JAXB annotation to the namespace used in
XML document,
- * together with a map of properties to rename.
- * Returns {@code null} if there is no replacement.
- */
- final Replacement export(final String uri) {
- return exports.get(uri);
- }
-
- /**
* Returns the URI replacements to apply when going from the model
implemented by Apache SIS to the
* transforming reader/writer. Used only for more sophisticated work than
what {@link #exportNS(String)} does.
* Returned as an iterator for avoiding to expose modifiable map; do not
invoke {@link Iterator#remove()}.
*/
- final Iterator<Map.Entry<String, Replacement>> exports() {
+ final Iterator<Map.Entry<String,String>> exports() {
return exports.entrySet().iterator();
}
}
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Transformer.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Transformer.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Transformer.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Transformer.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -96,9 +96,9 @@ abstract class Transformer {
private static final char RENAME_SEPARATOR = '/';
/**
- * A sentinel value in files loaded by {@link #load(String)} meaning that
the identifier stands for the type
- * name instead than for a property name. This sentinel value is used in
{@value TransformingReader#FILENAME}
- * and {@value TransformingWriter#FILENAME} resource files. For example in
the following:
+ * A sentinel value in files loaded by {@link #load(String, int)} meaning
that the identifier stands for the type
+ * name instead than for a property name. This sentinel value is used in
{@value TransformingReader#FILENAME} and
+ * {@value TransformingWriter#FILENAME} resource files. For example in the
following:
*
* {@preformat text
* http://standards.iso.org/iso/19115/-3/cit/1.0
@@ -174,7 +174,7 @@ abstract class Transformer {
/**
* Returns {@code true} if the given string is a namespace URI, or {@code
false} if it is a property name.
* This method implements a very fast check based on the presence of
{@code ':'} in {@code "http://foo.bar"}.
- * It assumes that all namespaces declared in files loaded by {@link
#load(String)} use the {@code "http"}
+ * It assumes that all namespaces declared in files loaded by {@link
#load(String, int)} use the {@code "http"}
* protocol and no property name use the {@code ':'} character.
*/
static boolean isNamespace(final String candidate) {
@@ -209,9 +209,12 @@ abstract class Transformer {
* </ul></li>
* </ul></li>
* </ul>
+ *
+ * @param filename name of the file to load.
+ * @param capacity initial hash map capacity. This is only a hint.
*/
- static Map<String, Map<String,String>> load(final String filename) {
- final Map<String, Map<String,String>> m = new HashMap<>(250);
+ static Map<String, Map<String,String>> load(final String filename, final
int capacity) {
+ final Map<String, Map<String,String>> m = new HashMap<>(capacity);
try (LineNumberReader in = new LineNumberReader(new InputStreamReader(
TransformingReader.class.getResourceAsStream(filename),
"UTF-8")))
{
@@ -309,7 +312,7 @@ abstract class Transformer {
* Notifies that we are opening an element of the given name.
*
* @param name element name as declared in JAXB annotations.
- * @param namespaces namespaces map loaded by {@link #load(String)}.
+ * @param namespaces namespaces map loaded by {@link #load(String, int)}.
*/
final void open(final QName name, final Map<String, Map<String,String>>
namespaces) {
final String localPart = name.getLocalPart();
@@ -325,7 +328,7 @@ abstract class Transformer {
* the list anyway as a safety.
*
* @param name element name as declared in JAXB annotations.
- * @param namespaces namespaces map loaded by {@link #load(String)}.
+ * @param namespaces namespaces map loaded by {@link #load(String, int)}.
*/
final void close(final QName name, final Map<String, Map<String,String>>
namespaces) {
if (isTypeElement(name.getLocalPart())) {
@@ -373,7 +376,7 @@ abstract class Transformer {
*/
final String oldNS = name.getNamespaceURI();
if (namespace == null) {
- namespace = version.importNS(oldNS);
+ namespace = relocate(oldNS);
}
if (!namespace.equals(oldNS) ||
!localPart.equals(name.getLocalPart())) {
name = new QName(namespace, localPart,
prefixReplacement(name.getPrefix(), namespace));
@@ -382,6 +385,13 @@ abstract class Transformer {
}
/**
+ * Returns the new namespace for elements (types and properties) in the
given namespace.
+ * This method is used only for default relocations, i.e. the fallback to
apply when no
+ * explicit rule has been found.
+ */
+ abstract String relocate(String namespace);
+
+ /**
* Returns the prefix to use for a name in a new namespace.
*
* @param previous the prefix associated to old namespace.
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingNamespaces.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingNamespaces.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingNamespaces.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingNamespaces.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -177,10 +177,10 @@ class TransformingNamespaces implements
* legacy ISO 19139:2007) is mapped to multiple namespaces in the new
ISO 19115-3:2016 or other standard.
* In such case, we have to iterate over 'exports' entries until we
find an inverse mapping.
*/
- final Iterator<Map.Entry<String, TransformVersion.Replacement>> it =
version.exports();
+ final Iterator<Map.Entry<String,String>> it = version.exports();
while (it.hasNext()) {
- final Map.Entry<String, TransformVersion.Replacement> e =
it.next();
- if (namespaceURI.equals(e.getValue().namespace)) {
+ final Map.Entry<String,String> e = it.next();
+ if (namespaceURI.equals(e.getValue())) {
p = context.getPrefix(e.getKey());
if (p != null) return p;
}
@@ -210,7 +210,7 @@ class TransformingNamespaces implements
private final NamespaceContext context;
/** Iterator over the namespace replacements. */
- private final Iterator<Map.Entry<String,
TransformVersion.Replacement>> exports;
+ private final Iterator<Map.Entry<String,String>> exports;
/** Iterator over some (not all) prefixes, or {@code null} if a new
iterator needs to be fetched. */
private Iterator<String> prefixes;
@@ -219,7 +219,7 @@ class TransformingNamespaces implements
private String next;
/** Creates a new iterator for the prefixes associated to the given
namespace URI. */
- Prefixes(final NamespaceContext context, final
Iterator<Map.Entry<String, TransformVersion.Replacement>> exports,
+ Prefixes(final NamespaceContext context, final
Iterator<Map.Entry<String,String>> exports,
final String namespaceURI)
{
this.context = context;
@@ -239,8 +239,8 @@ class TransformingNamespaces implements
if (!exports.hasNext()) {
return false;
}
- final Map.Entry<String, TransformVersion.Replacement> e =
exports.next();
- if (namespaceURI.equals(e.getValue().namespace)) {
+ final Map.Entry<String,String> e = exports.next();
+ if (namespaceURI.equals(e.getValue())) {
prefixes = context.getPrefixes(e.getKey());
}
}
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingReader.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingReader.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingReader.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingReader.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -76,7 +76,7 @@ final class TransformingReader extends T
*
* This map is initialized only once and should not be modified after that
point.
*/
- private static final Map<String, Map<String,String>> NAMESPACES =
load(FILENAME);
+ private static final Map<String, Map<String,String>> NAMESPACES =
load(FILENAME, 250);
/**
* Returns the namespace for the given ISO type, or {@code null} if
unknown.
@@ -270,6 +270,16 @@ final class TransformingReader extends T
}
/**
+ * Returns the new namespace for elements (types and properties) in the
given namespace.
+ * This method is used only for default relocations, i.e. the fallback to
apply when no
+ * explicit rule has been found.
+ */
+ @Override
+ final String relocate(final String namespace) {
+ return version.importNS(namespace);
+ }
+
+ /**
* Returns the prefix to use for a name in a new namespace. The prefix
should have been specified (indirectly)
* by a previous call to {@code importNS(Namespace, …)}, for example as a
result of a {@code NAMESPACE} event.
* If not, we compute it now using the same algorithm than in {@code
importNS}.
@@ -301,7 +311,7 @@ final class TransformingReader extends T
String uri = namespace.getNamespaceURI();
if (uri != null && !uri.isEmpty()) {
uri = removeTrailingSlash(uri);
- final String imported = uri.equals(oldURI) ? newURI :
version.importNS(uri);
+ final String imported = uri.equals(oldURI) ? newURI :
relocate(uri);
if (imported != uri) {
final String prefix = prefixReplacement(namespace.getPrefix(),
imported);
return new TransformedEvent.NS(namespace, prefix, imported);
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingWriter.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingWriter.java?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingWriter.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingWriter.java
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -81,7 +81,7 @@ final class TransformingWriter extends T
*
* This map is initialized only once and should not be modified after that
point.
*/
- private static final Map<String, Map<String,String>> NAMESPACES =
load(FILENAME);
+ private static final Map<String, Map<String,String>> NAMESPACES =
load(FILENAME, 60);
/**
* Elements that appear in different order in ISO 19139:2007 (or other
legacy standards) compared
@@ -178,20 +178,13 @@ final class TransformingWriter extends T
}
/**
- * Returns the name (prefix, namespace and local part) to write in the XML
document.
- * This method may replace the namespace, and in some case the name local
part too.
- * If there is no name change, then this method returns the given instance
as-is.
+ * Returns the old namespace for elements (types and properties) in the
given namespace.
+ * This method is used only for default relocations, i.e. the fallback to
apply when no
+ * explicit rule has been found.
*/
- private QName export(QName name) throws XMLStreamException {
- String uri = name.getNamespaceURI();
- if (uri != null && !uri.isEmpty()) { //
Optimization for a common case.
- final TransformVersion.Replacement r = version.export(uri);
- if (r != null) {
- uri = r.namespace;
- name = new QName(uri, r.exportProperty(name.getLocalPart()),
prefixReplacement(name.getPrefix(), uri));
- }
- }
- return name;
+ @Override
+ final String relocate(final String namespace) {
+ return version.exportNS(namespace);
}
/**
@@ -232,7 +225,7 @@ final class TransformingWriter extends T
*/
private Attribute export(Attribute attribute) throws XMLStreamException {
final QName originalName = attribute.getName();
- final QName name = export(originalName);
+ final QName name = convert(originalName);
if (name != originalName) {
attribute = new TransformedEvent.Attr(attribute, name);
}
@@ -250,7 +243,7 @@ final class TransformingWriter extends T
private Namespace exportIfNew(final Namespace namespace) {
String uri = namespace.getNamespaceURI();
if (uri != null && !uri.isEmpty()) {
- final String exported = version.exportNS(removeTrailingSlash(uri));
+ final String exported = relocate(removeTrailingSlash(uri));
if (exported != uri) {
return uniqueNamespaces.computeIfAbsent(exported, (k) -> {
return new TransformedEvent.NS(namespace,
Namespaces.getPreferredPrefix(k, namespace.getPrefix()), k);
@@ -321,7 +314,7 @@ final class TransformingWriter extends T
case END_ELEMENT: {
final EndElement e = event.asEndElement();
final QName originalName = e.getName();
- final QName name = export(originalName);
+ final QName name = convert(originalName);
final List<Namespace> namespaces = export(e.getNamespaces(),
name != originalName);
if (namespaces != null) {
event = new TransformedEvent.End(e, name, namespaces);
@@ -333,13 +326,15 @@ final class TransformingWriter extends T
writeDeferred(); // About to
exit the parent element containing deferred element.
}
}
+ close(originalName, NAMESPACES); // Must be
invoked only after 'convert(QName)'
break;
}
case START_ELEMENT: {
uniqueNamespaces.clear(); // Discard
entries created by NAMESPACE events.
final StartElement e = event.asStartElement();
final QName originalName = e.getName();
- final QName name = export(originalName);
+ open(originalName, NAMESPACES); // Must be
invoked before 'convert(QName)'.
+ final QName name = convert(originalName);
boolean changed = name != originalName;
for (final Iterator<Attribute> it = e.getAttributes();
it.hasNext();) {
final Attribute a = it.next();
@@ -434,7 +429,7 @@ final class TransformingWriter extends T
*/
@Override
public void setPrefix(final String prefix, final String uri) throws
XMLStreamException {
- out.setPrefix(prefix, version.exportNS(uri));
+ out.setPrefix(prefix, relocate(uri));
}
/**
@@ -446,7 +441,7 @@ final class TransformingWriter extends T
*/
@Override
public void setDefaultNamespace(final String uri) throws
XMLStreamException {
- out.setDefaultNamespace(version.exportNS(uri));
+ out.setDefaultNamespace(relocate(uri));
}
/**
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/ImageryExtensions.lst
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/ImageryExtensions.lst?rev=1824677&r1=1824676&r2=1824677&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/ImageryExtensions.lst
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/ImageryExtensions.lst
[UTF-8] Sun Feb 18 17:25:11 2018
@@ -1,9 +1,18 @@
#
-# Properties defined by ISO 19115-2 (extensions for imagery and gridded data).
+# Elements to rename during exports.
# Lines with zero-space indentation are namespace URIs.
# Lines with one-space indentation are XML types.
# Lines with two-spaces indentation are properties.
#
+http://www.isotc211.org/2005/gmd
+ MD_Georectified
+ centrePoint/centerPoint
+ DQ_QuantitativeResult
+ valueRecordType/valueType
+http://www.isotc211.org/2005/srv
+ SV_OperationMetadata
+ distributedComputingPlatform/DCP
+ parameter/parameters
http://standards.iso.org/iso/19115/-2/gmi/1.0
MI_Instrument
citation
@@ -67,7 +76,7 @@ http://standards.iso.org/iso/19115/-2/gm
extent
sensingInstrument
pass
- objectiveOccurance
+ objectiveOccurence/objectiveOccurance
MI_Plan
type
status