sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1551459 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/ sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/ sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/ sis-me...
Date Tue, 17 Dec 2013 05:05:28 GMT
Author: desruisseaux
Date: Tue Dec 17 05:05:28 2013
New Revision: 1551459

URL: http://svn.apache.org/r1551459
Log:
Added tests and more consistent references to http://schemas.opengis.net/iso/19139/20070417/resources/

Added:
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/PT_LocaleTest.java
  (with props)
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/URIParser.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -126,6 +126,9 @@ public final class PT_Locale extends Xml
         /**
          * Invoked by JAXB {@link javax.xml.bind.Marshaller} before this object is marshalled
to XML.
          * This method sets the {@link #characterEncoding} to the XML encoding.
+         *
+         * {@note This is totally redundant with the encoding declared in the XML header.
Unfortunately,
+         *        the <code>gmd:characterEncoding</code> element is mandatory
according OGC/ISO schemas.}
          */
         public void beforeMarshal(final Marshaller marshaller) {
             final String encoding;

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -27,6 +27,7 @@ import org.opengis.metadata.citation.Cit
 import org.opengis.metadata.citation.ResponsibleParty;
 import org.opengis.metadata.identification.TopicCategory;
 import org.apache.sis.metadata.iso.identification.DefaultDataIdentification;
+import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.xml.XML;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.MarshallerPool;
@@ -57,7 +58,7 @@ public final strictfp class CodeListMars
     private static String getResponsiblePartyXML(final String baseURL) {
         return "<gmd:CI_ResponsibleParty xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
                "  <gmd:role>\n" +
-               "    <gmd:CI_RoleCode codeList=\"" + baseURL + "resources/Codelist/gmxCodelists.xml#CI_RoleCode\""
+
+               "    <gmd:CI_RoleCode codeList=\"" + baseURL + Schemas.CODELISTS_PATH +
"#CI_RoleCode\"" +
                     " codeListValue=\"principalInvestigator\">" + "Principal investigator</gmd:CI_RoleCode>\n"
+
                "  </gmd:role>\n" +
                "</gmd:CI_ResponsibleParty>";
@@ -71,7 +72,7 @@ public final strictfp class CodeListMars
     private static String getCitationXML(final String baseURL, final String language, final
String value) {
         return "<gmd:CI_Date xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
                "  <gmd:dateType>\n" +
-               "    <gmd:CI_DateTypeCode codeList=\"" + baseURL + "resources/Codelist/gmxCodelists.xml#CI_DateTypeCode\""
+
+               "    <gmd:CI_DateTypeCode codeList=\"" + baseURL + Schemas.CODELISTS_PATH
+ "#CI_DateTypeCode\"" +
                     " codeListValue=\"creation\" codeSpace=\"" + language + "\">" + value
+ "</gmd:CI_DateTypeCode>\n" +
                "  </gmd:dateType>\n" +
                "</gmd:CI_Date>";
@@ -84,7 +85,7 @@ public final strictfp class CodeListMars
      */
     @Test
     public void testDefaultURL() throws JAXBException {
-        final String expected = getResponsiblePartyXML("http://schemas.opengis.net/iso/19139/20070417/");
+        final String expected = getResponsiblePartyXML(Schemas.METADATA_ROOT);
         final ResponsibleParty rp = (ResponsibleParty) XML.unmarshal(expected);
         assertEquals(Role.PRINCIPAL_INVESTIGATOR, rp.getRole());
         /*
@@ -102,7 +103,7 @@ public final strictfp class CodeListMars
      */
     @Test
     public void testISO_URL() throws JAXBException {
-        final String expected = getResponsiblePartyXML("http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/");
+        final String expected = getResponsiblePartyXML(Schemas.ISO_19139_ROOT);
         final ResponsibleParty rp = (ResponsibleParty) XML.unmarshal(expected);
         assertEquals(Role.PRINCIPAL_INVESTIGATOR, rp.getRole());
 
@@ -128,16 +129,16 @@ public final strictfp class CodeListMars
          * First, test using the French locale.
          */
         marshaller.setProperty(XML.LOCALE, Locale.FRENCH);
-        String expected = getCitationXML("http://schemas.opengis.net/iso/19139/20070417/",
"fra", "Création");
+        String expected = getCitationXML(Schemas.METADATA_ROOT, "fra", "Création");
         CitationDate ci = (CitationDate) XML.unmarshal(expected);
         assertEquals(DateType.CREATION, ci.getDateType());
         String actual = marshal(marshaller, ci);
         assertXmlEquals(expected, actual, "xmlns:*");
         /*
-         * Tests again using the Englisg locale.
+         * Tests again using the English locale.
          */
         marshaller.setProperty(XML.LOCALE, Locale.ENGLISH);
-        expected = getCitationXML("http://schemas.opengis.net/iso/19139/20070417/", "eng",
"Creation");
+        expected = getCitationXML(Schemas.METADATA_ROOT, "eng", "Creation");
         ci = (CitationDate) XML.unmarshal(expected);
         assertEquals(DateType.CREATION, ci.getDateType());
         actual = marshal(marshaller, ci);

Added: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/PT_LocaleTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/PT_LocaleTest.java?rev=1551459&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/PT_LocaleTest.java
(added)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/PT_LocaleTest.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jaxb.code;
+
+import java.util.Arrays;
+import java.util.Locale;
+import javax.xml.bind.JAXBException;
+import org.apache.sis.metadata.iso.DefaultMetadata;
+import org.apache.sis.internal.jaxb.Schemas;
+import org.apache.sis.xml.Namespaces;
+import org.apache.sis.test.XMLTestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.Assert.*;
+
+
+/**
+ * Tests the XML marshaling of {@link PT_Locale}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public final strictfp class PT_LocaleTest extends XMLTestCase {
+    /**
+     * The path to the {@code gmxCodelists.xml} path.
+     */
+    private static final String CODELISTS_PATH = Schemas.METADATA_ROOT + Schemas.CODELISTS_PATH;
+
+    /**
+     * The {@code <gmd:characterEncoding>} element to be repeated for every locale.
This element is not
+     * of interest for this test. In current Apache SIS implementation, it is totally redundant
with the
+     * encoding declared in the XML header. Unfortunately those elements are mandatory according
OGC/ISO
+     * schemas, so we have to carry their weight.
+     */
+    private static final String ENCODING =
+            "      <gmd:characterEncoding>\n" +
+            "        <gmd:MD_CharacterSetCode codeList=\"" + CODELISTS_PATH + "#MD_CharacterSetCode\"
codeListValue=\"utf8\">UTF-8</gmd:MD_CharacterSetCode>\n" +
+            "      </gmd:characterEncoding>\n";
+
+    /**
+     * The locales to use for the tests. For better test coverage we need at least:
+     *
+     * <ul>
+     *   <li>One locale which is a language without specifying the country</li>
+     *   <li>At least two different countries for the same language.</li>
+     * </ul>
+     */
+    private static final Locale[] LOCALES = {
+            Locale.JAPANESE, Locale.CANADA, Locale.FRANCE, Locale.CANADA_FRENCH
+    };
+
+    /**
+     * XML representation of the {@link #LOCALES} list.
+     */
+    private static final String XML =
+            "<gmd:MD_Metadata xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
+            "  <gmd:locale>\n" +
+            "    <gmd:PT_Locale>\n" +
+            "      <gmd:languageCode>\n" +
+            "        <gmd:LanguageCode codeList=\"" + CODELISTS_PATH + "#LanguageCode\"
codeListValue=\"jpn\" codeSpace=\"eng\">Japanese</gmd:LanguageCode>\n" +
+            "      </gmd:languageCode>\n" + ENCODING +
+            "    </gmd:PT_Locale>\n" +
+            "  </gmd:locale>\n" +
+            "  <gmd:locale>\n" +
+            "    <gmd:PT_Locale>\n" +
+            "      <gmd:languageCode>\n" +
+            "        <gmd:LanguageCode codeList=\"" + CODELISTS_PATH + "#LanguageCode\"
codeListValue=\"eng\" codeSpace=\"eng\">English</gmd:LanguageCode>\n" +
+            "      </gmd:languageCode>\n" +
+            "      <gmd:country>\n" +
+            "        <gmd:Country codeList=\"" + CODELISTS_PATH + "#Country\" codeListValue=\"CA\"
codeSpace=\"eng\">Canada</gmd:Country>\n" +
+            "      </gmd:country>\n" + ENCODING +
+            "    </gmd:PT_Locale>\n" +
+            "  </gmd:locale>\n" +
+            "  <gmd:locale>\n" +
+            "    <gmd:PT_Locale>\n" +
+            "      <gmd:languageCode>\n" +
+            "        <gmd:LanguageCode codeList=\"" + CODELISTS_PATH + "#LanguageCode\"
codeListValue=\"fra\" codeSpace=\"eng\">French</gmd:LanguageCode>\n" +
+            "      </gmd:languageCode>\n" +
+            "      <gmd:country>\n" +
+            "        <gmd:Country codeList=\"" + CODELISTS_PATH + "#Country\" codeListValue=\"FR\"
codeSpace=\"eng\">France</gmd:Country>\n" +
+            "      </gmd:country>\n" + ENCODING +
+            "    </gmd:PT_Locale>\n" +
+            "  </gmd:locale>\n" +
+            "  <gmd:locale>\n" +
+            "    <gmd:PT_Locale>\n" +
+            "      <gmd:languageCode>\n" +
+            "        <gmd:LanguageCode codeList=\"" + CODELISTS_PATH + "#LanguageCode\"
codeListValue=\"fra\" codeSpace=\"eng\">French</gmd:LanguageCode>\n" +
+            "      </gmd:languageCode>\n" +
+            "      <gmd:country>\n" +
+            "        <gmd:Country codeList=\"" + CODELISTS_PATH + "#Country\" codeListValue=\"CA\"
codeSpace=\"eng\">Canada</gmd:Country>\n" +
+            "      </gmd:country>\n" + ENCODING +
+            "    </gmd:PT_Locale>\n" +
+            "  </gmd:locale>\n" +
+            "</gmd:MD_Metadata>";
+
+    /**
+     * Tests marshalling of a few locales.
+     *
+     * @throws JAXBException Should never happen.
+     */
+    @Test
+    public void testMarshalling() throws JAXBException {
+        final DefaultMetadata metadata = new DefaultMetadata();
+        metadata.setLocales(Arrays.asList(LOCALES));
+        assertXmlEquals(XML, marshal(metadata), "xlmns:*");
+    }
+
+    /**
+     * Tests unmarshalling of a few locales.
+     *
+     * @throws JAXBException Should never happen.
+     */
+    @Test
+    public void testUnmarshalling() throws JAXBException {
+        final DefaultMetadata metadata = unmarshal(DefaultMetadata.class, XML);
+        assertArrayEquals(LOCALES, metadata.getLocales().toArray());
+    }
+}

Propchange: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/PT_LocaleTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/PT_LocaleTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -20,6 +20,7 @@ import javax.xml.bind.JAXBException;
 import org.apache.sis.xml.XML;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.metadata.iso.LoggingWatcher;
+import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Rule;
@@ -135,7 +136,7 @@ public final strictfp class DefaultResol
                 "<gmd:MD_Resolution xmlns:gmd=\"" + Namespaces.GMD + '"' +
                                   " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
                 "  <gmd:distance>\n" +
-                "    <gco:Distance uom=\"http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance>\n"
+
+                "    <gco:Distance uom=\"" + Schemas.METADATA_ROOT + Schemas.UOM_PATH
+ "#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance>\n" +
                 "  </gmd:distance>\n" +
                 "</gmd:MD_Resolution>", xml, "xmlns:*");
         /*

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -50,6 +50,7 @@ import org.junit.BeforeClass;
 
     // XML marshalling.
     org.apache.sis.internal.jaxb.code.CodeListMarshallingTest.class,
+    org.apache.sis.internal.jaxb.code.PT_LocaleTest.class,
     org.apache.sis.internal.jaxb.gmd.LanguageCodeTest.class,
     org.apache.sis.internal.jaxb.gml.TimePeriodTest.class,
     org.apache.sis.xml.FreeTextMarshallingTest.class,

Added: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java?rev=1551459&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
(added)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jaxb;
+
+
+/**
+ * Constants for URL to schema directories or definition files.
+ * Constants in this class are organized in two groups:
+ *
+ * <ul>
+ *   <li>Constants with the {@code _ROOT} suffix are {@code "http://"} URL to a root
directory.</li>
+ *   <li>Constants with the {@code _PATH} suffix are relative paths to concatenate
to a {@code _ROOT}
+ *       constant in order to get the full path to a file.</li>
+ * </ul>
+ *
+ * {@section Note on multi-lingual files}
+ * Some files are available in two variants: with and without {@code "ML_"} prefix, which
stands for "Multi Lingual".
+ * Some examples are {@code "[ML_]gmxCodelists.xml"} and {@code "[ML_]gmxUom.xml"}. The following
assumptions hold:
+ *
+ * <ul>
+ *   <li>All code lists defined in a {@code ML_foo.xml} file exist also in {@code foo.xml}.</li>
+ *   <li>The converse of above point is not necessarily true:
+ *       the {@code ML_foo.xml} file may contain only a subset of {@code foo.xml}.</li>
+ *   <li>All English descriptions in {@code ML_foo.xml} file are strictly identical
to the ones in {@code foo.xml}.</li>
+ *   <li>Descriptions in other languages than English exist only in {@code ML_foo.xml}.</li>
+ * </ul>
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public final class Schemas {
+    /**
+     * The root directory of OGC metadata schemas.
+     * This is the schema used by default in Apache SIS.
+     */
+    public static final String METADATA_ROOT = "http://schemas.opengis.net/iso/19139/20070417/";
+
+    /**
+     * The root directory of ISO metadata schemas.
+     * This is sometime used as an alternative to {@link #METADATA_ROOT}.
+     */
+    public static final String ISO_19139_ROOT = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/";
+
+    /**
+     * The string to append to {@link #METADATA_ROOT} or {@link #ISO_19139_ROOT} for obtaining
the path
+     * to the definitions of code lists.
+     *
+     * <p>A localized version of this file exists also with the {@code "ML_gmxCodelists.xml"}
filename
+     * instead of {@code "gmxCodelists.xml"}</p>
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-154">SIS-154</a>
+     */
+    public static final String CODELISTS_PATH = "resources/Codelist/gmxCodelists.xml";
+
+    /**
+     * The string to append to {@link #METADATA_ROOT} or {@link #ISO_19139_ROOT} for obtaining
the path
+     * to the definitions of units of measurement.
+     *
+     * <p>A localized version of this file exists also with the {@code "ML_gmxUom.xml"}
filename
+     * instead of {@code "gmxUom.xml"}</p>
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-154">SIS-154</a>
+     */
+    public static final String UOM_PATH = "resources/uom/gmxUom.xml";
+
+    /**
+     * Do not allow instantiation of this class.
+     */
+    private Schemas() {
+    }
+}

Propchange: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -22,8 +22,8 @@ import javax.measure.unit.NonSI;
 import javax.measure.quantity.Quantity;
 import javax.xml.bind.annotation.XmlValue;
 import javax.xml.bind.annotation.XmlAttribute;
-import org.apache.sis.internal.jaxb.gmd.CodeListProxy;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.measure.Units;
 
@@ -119,10 +119,6 @@ public final class Measure {
      *
      * @return The string representation of the unit of measure.
      *
-     * @todo The file on schemas.opengis.net is <code>gmxUom.xml</code>, but
the file on standards.iso.org
-     *       and eden.ign.fr is <code>ML_gmxUom.xml</code>. Is there some rule
allowing us to know which
-     *       filename to use?
-     *
      * @todo Strictly speaking, the above URL should be used only for "m", "deg" and "rad"
units because they
      *       are the only ones defined in the <code>gmxUom.xml</code> file. What
should we do for other units?
      */
@@ -141,8 +137,8 @@ public final class Measure {
                 return "urn:ogc:def:uom:EPSG::" + code;
             }
         }
-        return Context.schema(Context.current(), "gmd", CodeListProxy.DEFAULT_SCHEMA)
-                .append("resources/uom/gmxUom.xml#xpointer(//*[@gml:id='").append(unit).append("'])").toString();
+        return Context.schema(Context.current(), "gmd", Schemas.METADATA_ROOT).append(Schemas.UOM_PATH)
+                .append("#xpointer(//*[@gml:id='").append(unit).append("'])").toString();
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlValu
 import org.opengis.util.CodeList;
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.Schemas;
 
 
 /**
@@ -44,29 +45,24 @@ import org.apache.sis.internal.jaxb.Cont
 @XmlType(name = "CodeList", propOrder = { "codeList", "codeListValue", "codeSpace" })
 public final class CodeListProxy {
     /**
-     * The default schema to be given to {@link Context#schema(Context, String, String)}
(last argument).
-     */
-    public static final String DEFAULT_SCHEMA = "http://schemas.opengis.net/iso/19139/20070417/";
-
-    /**
      * Returns the URL to a given code list in the given XML file.
-     * This method concatenates the base schema URL with the given file and identifier.
+     * This method concatenates the base schema URL with the given identifier.
      * Some examples of strings returned by this method are:
      *
      * <ul>
-     *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/ML_gmxCodelists.xml#LanguageCode"}</li>
+     *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#LanguageCode"}</li>
      *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode"}</li>
      *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_OnLineFunctionCode"}</li>
      * </ul>
      *
      * @param  context    The current (un)marshalling context, or {@code null} if none.
-     * @param  file       The XML file, either {@code "gmxCodelists.xml"} or {@code "ML_gmxCodelists.xml"}.
      * @param  identifier The UML identifier of the code list.
      * @return The URL to the given code list in the given schema.
      */
-    private static String schema(final Context context, final String file, final String identifier)
{
-        return Context.schema(context, "gmd", DEFAULT_SCHEMA).append("resources/Codelist/")
-                .append(file).append('#').append(identifier).toString();
+    private static String schema(final Context context, final String identifier) {
+        return Context.schema(context, "gmd", Schemas.METADATA_ROOT)
+                .append(Schemas.CODELISTS_PATH) // Future SIS version may switch between
localized/unlocalized file.
+                .append('#').append(identifier).toString();
     }
 
     /**
@@ -124,16 +120,15 @@ public final class CodeListProxy {
      * Builds a value for {@link LanguageCode} and {@link Country} elements.
      *
      * @param context       The current (un)marshalling context, or {@code null} if none.
-     * @param catalog       The file which defines the code list (for example {@code "ML_gmxCodelists.xml"}),
without its path.
-     * @param codeList      The {@code codeList} attribute, to be concatenated after the
catalog name and the {@code "#"} symbol.
+     * @param codeList      The {@code codeList} attribute, to be concatenated after the
{@code "#"} symbol.
      * @param codeListValue The {@code codeListValue} attribute, to be declared in the attribute.
      * @param codeSpace     The 3-letters language code of the {@code value} attribute, or
{@code null} if none.
      * @param value         The value in the language specified by the {@code codeSpace}
attribute, or {@code null} if none.
      */
-    CodeListProxy(final Context context, final String catalog,
-            final String codeList, final String codeListValue, final String codeSpace, final
String value)
+    CodeListProxy(final Context context, final String codeList, final String codeListValue,
+            final String codeSpace, final String value)
     {
-        this.codeList      = schema(context, catalog, codeList);
+        this.codeList      = schema(context, codeList);
         this.codeListValue = codeListValue;
         this.codeSpace     = codeSpace;
         this.value         = value;
@@ -149,7 +144,7 @@ public final class CodeListProxy {
     CodeListProxy(final Context context, final CodeList<?> code) {
         final String classID = Types.getListName(code);
         final String fieldID = Types.getCodeName(code);
-        codeList = schema(context, "gmxCodelists.xml", classID);
+        codeList = schema(context, classID);
         /*
          * Get the localized name of the field identifier, if possible.
          * This code partially duplicates Types.getCodeTitle(CodeList).

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -71,7 +71,7 @@ public final class Country extends GO_Ch
 
     /**
      * Builds a {@code <Country>} element.
-     * For private use by {@link #create(Context, Locale, CharSequenceAdapter)} only.
+     * For private use by {@link #create(Context, Locale)} only.
      *
      * @param context       The current (un)marshalling context, or {@code null} if none.
      * @param codeListValue The {@code codeListValue} attribute in the XML element.
@@ -79,7 +79,7 @@ public final class Country extends GO_Ch
      * @param value         The value in the language specified by the {@code codeSpace}
attribute, or {@code null} if none.
      */
     private Country(final Context context, final String codeListValue, final String codeSpace,
final String value) {
-        proxy = new CodeListProxy(context, "ML_gmxCodelists.xml", "Country", codeListValue,
codeSpace, value);
+        proxy = new CodeListProxy(context, "Country", codeListValue, codeSpace, value);
     }
 
     /**
@@ -91,8 +91,8 @@ public final class Country extends GO_Ch
      *         or if its {@link Locale#getCountry()} attribute is the empty string.
      */
     public static Country create(final Context context, final Locale locale) {
-        if (locale != null) {
-            final String codeListValue = Context.converter(context).toCountryCode(context,
locale);
+        final String codeListValue = Context.converter(context).toCountryCode(context, locale);
+        if (codeListValue != null) {
             if (!codeListValue.isEmpty() && Context.isFlagSet(context, Context.SUBSTITUTE_COUNTRY))
{
                 /*
                  * Marshal the locale as a <gco:CharacterString> instead than <Country>,

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -77,7 +77,7 @@ public final class LanguageCode extends 
      * @param value         The value in the language specified by the {@code codeSpace}
attribute, or {@code null} if none.
      */
     private LanguageCode(final Context context, final String codeListValue, final String
codeSpace, final String value) {
-        proxy = new CodeListProxy(context, "ML_gmxCodelists.xml", "LanguageCode", codeListValue,
codeSpace, value);
+        proxy = new CodeListProxy(context, "LanguageCode", codeListValue, codeSpace, value);
     }
 
     /**
@@ -89,8 +89,8 @@ public final class LanguageCode extends 
      *         or if its {@link Locale#getLanguage()} attribute is the empty string.
      */
     public static LanguageCode create(final Context context, final Locale locale) {
-        if (locale != null) {
-            final String codeListValue = Context.converter(context).toLanguageCode(context,
locale);
+        final String codeListValue = Context.converter(context).toLanguageCode(context, locale);
+        if (codeListValue != null) {
             if (!codeListValue.isEmpty() && Context.isFlagSet(context, Context.SUBSTITUTE_LANGUAGE))
{
                 /*
                  * Marshal the locale as a <gco:CharacterString> instead than <LanguageCode>,

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/URIParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/URIParser.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/URIParser.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/URIParser.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -453,9 +453,7 @@ public final class URIParser {
                  * relative instead than absolute.
                  */
                 int i = url.lastIndexOf('/', f-1) + 1;
-                if (regionMatches(   "gmxUom.xml", url, i, f) ||  // Name used on http://schemas.opengis.net
-                    regionMatches("ML_gmxUom.xml", url, i, f))    // Name used on http://standards.iso.org
-                {
+                if (regionMatches("gmxUom.xml", url, i, f) || regionMatches("ML_gmxUom.xml",
url, i, f)) {
                     /*
                      * The fragment should typically be of the form "xpointer(//*[@gml:id='m'])".
                      * However sometime we found no "xpointer", but directly the unit instead.

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java [UTF-8] Tue
Dec 17 05:05:28 2013
@@ -245,19 +245,18 @@ public final class XML extends Static {
      * </ul>
      *
      * {@section Example}
-     * INSPIRE compliant language code shall be formatted like below (formatting may vary):
+     * INSPIRE compliant language code shall be formatted like below (details may vary):
      *
      * {@preformat xml
      *   <gmd:language>
      *     <gmd:LanguageCode
-     *         codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/ML_gmxCodelists.xml#LanguageCode"
+     *         codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#LanguageCode"
      *         codeListValue="fra">French</gmd:LanguageCode>
      *   </gmd:language>
      * }
      *
-     * However if this property contains the "{@code language}" value, then the marshaller
will
-     * format the language code like below (which is legal according OGC schemas, but is
not
-     * INSPIRE compliant):
+     * However if this property contains the "{@code language}" value, then the marshaller
will format
+     * the language code like below (which is legal according OGC schemas, but is not INSPIRE
compliant):
      *
      * {@preformat xml
      *   <gmd:language>

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -19,6 +19,7 @@ package org.apache.sis.internal.jaxb.gco
 import java.net.URISyntaxException;
 import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
+import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -46,7 +47,7 @@ public final strictfp class MeasureTest 
         assertEquals(SI.METRE, measure.unit);
         assertEquals("urn:ogc:def:uom:EPSG::9001", measure.getUOM());
         measure.asXPointer = true;
-        assertEquals("http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])",
measure.getUOM());
+        assertEquals(Schemas.METADATA_ROOT + Schemas.UOM_PATH + "#xpointer(//*[@gml:id='m'])",
measure.getUOM());
 
         measure.unit = null;
         measure.asXPointer = false;
@@ -54,12 +55,12 @@ public final strictfp class MeasureTest 
         assertEquals(NonSI.DEGREE_ANGLE, measure.unit);
         assertEquals("urn:ogc:def:uom:EPSG::9102", measure.getUOM());
         measure.asXPointer = true;
-        assertEquals("http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='deg'])",
measure.getUOM());
+        assertEquals(Schemas.METADATA_ROOT + Schemas.UOM_PATH + "#xpointer(//*[@gml:id='deg'])",
measure.getUOM());
 
         measure.unit = null;
         measure.asXPointer = true;
         measure.setUOM("gmxUom.xml#kg"); // Not really an existing unit in 'gmxUom'.
         assertEquals(SI.KILOGRAM, measure.unit);
-        assertEquals("http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='kg'])",
measure.getUOM());
+        assertEquals(Schemas.METADATA_ROOT + Schemas.UOM_PATH + "#xpointer(//*[@gml:id='kg'])",
measure.getUOM());
     }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -27,6 +27,7 @@ import org.opengis.metadata.Metadata;
 import org.apache.sis.xml.XML;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.MarshallerPool;
+import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.test.XMLTestCase;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.mock.MetadataMock;
@@ -60,7 +61,7 @@ public final strictfp class LanguageCode
      * XML fragment using the {@code <gmd:LanguageCode>} construct with attributes.
      */
     private static final String LANGUAGE_CODE = "<gmd:LanguageCode" +
-            " codeList=\"http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/ML_gmxCodelists.xml#LanguageCode\""
+
+            " codeList=\"" + Schemas.METADATA_ROOT + Schemas.CODELISTS_PATH + "#LanguageCode\""
+
             " codeListValue=\"jpn\">Japanese</gmd:LanguageCode>";
 
     /**
@@ -140,7 +141,7 @@ public final strictfp class LanguageCode
      * {@preformat xml
      *   <gmd:MD_Metadata>
      *     <gmd:language>
-     *       <gmd:LanguageCode codeList="(snip)/ML_gmxCodelists.xml#LanguageCode" codeListValue="jpn">Japanese</gmd:LanguageCode>
+     *       <gmd:LanguageCode codeList="(snip)/gmxCodelists.xml#LanguageCode" codeListValue="jpn">Japanese</gmd:LanguageCode>
      *     </gmd:language>
      *   </gmd:MD_Metadata>
      * }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java?rev=1551459&r1=1551458&r2=1551459&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
[UTF-8] Tue Dec 17 05:05:28 2013
@@ -58,6 +58,8 @@ public abstract strictfp class XMLTestCa
      * an error of one or two hours if a code fails to take timezone offset in account.
      *
      * <p>This field is initially {@code null} and created when first needed.</p>
+     *
+     * @see #getMarshallerPool()
      */
     private static MarshallerPool defaultPool;
 



Mime
View raw message