You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2018/05/04 09:03:19 UTC

[18/24] jena git commit: JENA-1537: Remove dependency on Xerces. Import needed code

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDDV.java
new file mode 100644
index 0000000..d76d8c3
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDDV.java
@@ -0,0 +1,56 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+import org.apache.jena.ext.xerces.util.XMLChar;
+
+/**
+ * Represent the schema type "ID"
+ *
+ * @xerces.internal 
+ *
+ * @author Neeraj Bajaj, Sun Microsystems, inc.
+ * @author Sandy Gao, IBM
+ *
+ * @version $Id: IDDV.java 699892 2008-09-28 21:08:27Z mrglavas $
+ */
+public class IDDV extends TypeValidator{
+
+    @Override
+    public short getAllowedFacets(){
+        return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
+    }
+
+    @Override
+    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
+        if (!XMLChar.isValidNCName(content)) {
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "NCName"});
+        }
+        return content;
+    }
+
+    @Override
+    public void checkExtraRules(Object value, ValidationContext context) throws InvalidDatatypeValueException {
+        String content = (String)value;
+        if (context.isIdDeclared(content))
+            throw new InvalidDatatypeValueException("cvc-id.2", new Object[]{content});
+        context.addId(content);
+    }
+} // class IDDV

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDREFDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDREFDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDREFDV.java
new file mode 100644
index 0000000..369a347
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDREFDV.java
@@ -0,0 +1,55 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+import org.apache.jena.ext.xerces.util.XMLChar;
+
+/**
+ * Represent the schema type "IDREF"
+ *
+ * @xerces.internal 
+ *
+ * @author Neeraj Bajaj, Sun Microsystems, inc.
+ * @author Sandy Gao, IBM
+ *
+ * @version $Id: IDREFDV.java 446745 2006-09-15 21:43:58Z mrglavas $
+ */
+public class IDREFDV extends TypeValidator{
+
+    @Override
+    public short getAllowedFacets(){
+        return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
+    }
+
+    @Override
+    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
+        if (!XMLChar.isValidNCName(content)) {
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "NCName"});
+        }
+        return content;
+    }
+
+    @Override
+    public void checkExtraRules(Object value, ValidationContext context) throws InvalidDatatypeValueException {
+        context.addIdRef((String)value);
+    }
+
+}//IDREF class
+

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IntegerDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IntegerDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IntegerDV.java
new file mode 100644
index 0000000..69a6405
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IntegerDV.java
@@ -0,0 +1,43 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * Represent the schema type "integer"
+ *
+ * @xerces.internal 
+ *
+ * @author Sandy Gao, IBM
+ *
+ * @version $Id: IntegerDV.java 446745 2006-09-15 21:43:58Z mrglavas $
+ */
+public class IntegerDV extends DecimalDV {
+
+    @Override
+    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
+        try {
+            return new XDecimal(content, true);
+        } catch (NumberFormatException nfe) {
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "integer"});
+        }
+    }
+    
+} // class EntityDV

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/ListDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/ListDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/ListDV.java
new file mode 100644
index 0000000..b07202a
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/ListDV.java
@@ -0,0 +1,146 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import java.util.AbstractList;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+import org.apache.jena.ext.xerces.xs.datatypes.ObjectList;
+
+/**
+ * Represent the schema list types
+ *
+ * @xerces.internal 
+ *
+ * @author Neeraj Bajaj, Sun Microsystems, inc.
+ * @author Sandy Gao, IBM
+ *
+ * @version $Id: ListDV.java 725840 2008-12-11 22:19:06Z mrglavas $
+ */
+public class ListDV extends TypeValidator{
+
+    @Override
+    public short getAllowedFacets(){
+          return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
+    }
+
+    // this method should never be called: XSSimpleTypeDecl is responsible for
+    // calling the item type for the convertion
+    @Override
+    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
+        return content;
+    }
+
+    // length of a list type is the number of items in the list
+    @Override
+    public int getDataLength(Object value) {
+        return ((ListData)value).getLength();
+    }
+
+    final static class ListData extends AbstractList<Object> implements ObjectList {
+        final Object[] data;
+        private String canonical;
+        public ListData(Object[] data) {
+            this.data = data;
+        }
+        @Override
+        public synchronized String toString() {
+            if (canonical == null) {
+                int len = data.length;
+                StringBuffer buf = new StringBuffer();
+                if (len > 0) {
+                    buf.append(data[0].toString());
+                }
+                for (int i = 1; i < len; i++) {
+                    buf.append(' ');
+                    buf.append(data[i].toString());
+                }
+                canonical = buf.toString();
+            }
+            return canonical;
+        }
+        @Override
+        public int getLength() {
+            return data.length;
+        }
+        @Override
+        public boolean equals(Object obj) {
+            if (!(obj instanceof ListData))
+                return false;
+            Object[] odata = ((ListData)obj).data;
+    
+            int count = data.length;
+            if (count != odata.length)
+                return false;
+    
+            for (int i = 0 ; i < count ; i++) {
+                if (!data[i].equals(odata[i]))
+                    return false;
+            }//end of loop
+    
+            //everything went fine.
+            return true;
+        }
+        
+        @Override
+        public int hashCode() {
+            int hash = 0;
+            for (int i = 0; i < data.length; ++i) {
+                hash ^= data[i].hashCode();
+            }
+            return hash;
+        }
+        
+        @Override
+        public boolean contains(Object item) {
+            for (int i = 0;i < data.length; i++) {
+                if (item == data[i]) {
+                    return true;
+                }
+            }
+            return false;
+        }
+        
+        @Override
+        public Object item(int index) {
+            if (index < 0 || index >= data.length) {
+                return null;
+            }
+            return data[index];
+        }
+        
+        /*
+         * List methods
+         */
+        
+        @Override
+        public Object get(int index) {
+            if (index >= 0 && index < data.length) {
+                return data[index];
+            }
+            throw new IndexOutOfBoundsException("Index: " + index);
+        }
+        
+        @Override
+        public int size() {
+            return getLength();
+        }
+    }
+} // class ListDV
+

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/MonthDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/MonthDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/MonthDV.java
new file mode 100644
index 0000000..1e83f51
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/MonthDV.java
@@ -0,0 +1,168 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * Validator for &lt;gMonth&gt; datatype (W3C Schema Datatypes)
+ *
+ * @xerces.internal 
+ *
+ * @author Elena Litani
+ * @author Gopal Sharma, SUN Microsystem Inc.
+ *
+ * @version $Id: MonthDV.java 937741 2010-04-25 04:25:46Z mrglavas $
+ */
+
+public class MonthDV extends AbstractDateTimeDV {
+
+    /**
+     * Convert a string to a compiled form
+     *
+     * @param  content The lexical representation of gMonth
+     * @return a valid and normalized gMonth object
+     */
+    @Override
+    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
+        try{
+            return parse(content);
+        } catch(Exception ex){
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gMonth"});
+        }
+    }
+
+    /**
+     * Parses, validates and computes normalized version of gMonth object
+     *
+     * @param str    The lexical representation of gMonth object --MM
+     *               with possible time zone Z or (-),(+)hh:mm
+     * @return normalized date representation
+     * @exception SchemaDateTimeException Invalid lexical representation
+     */
+    protected DateTimeData parse(String str) throws SchemaDateTimeException{
+        DateTimeData date = new DateTimeData(str, this);
+        int len = str.length();
+
+        //set constants
+        date.year=YEAR;
+        date.day=DAY;
+        if (str.charAt(0)!='-' || str.charAt(1)!='-') {
+            throw new SchemaDateTimeException("Invalid format for gMonth: "+str);
+        }
+        int stop = 4;
+        date.month=parseInt(str,2,stop);
+
+        // REVISIT: allow both --MM and --MM-- now.
+        // need to remove the following 4 lines to disallow --MM--
+        // when the errata is offically in the rec.
+        if (str.length() >= stop+2 &&
+            str.charAt(stop) == '-' && str.charAt(stop+1) == '-') {
+            stop += 2;
+        }
+        if (stop < len) {
+            if (!isNextCharUTCSign(str, stop, len)) {
+                throw new SchemaDateTimeException ("Error in month parsing: "+str);
+            }
+            else {
+                getTimeZone(str, date, stop, len);
+            }
+        }
+        //validate and normalize
+        validateDateTime(date);
+
+        //save unnormalized values
+        saveUnnormalized(date);
+        
+        if ( date.utc!=0 && date.utc!='Z' ) {
+            normalize(date);
+        }
+        date.position = 1;
+        return date;
+    }
+
+    /**
+     * Overwrite compare algorithm to optimize month comparison
+     *
+     * REVISIT: this one is lack of the third parameter: boolean strict, so it
+     *          doesn't override the method in the base. But maybe this method
+     *          is not correctly implemented, and I did encounter errors when
+     *          trying to add the extra parameter. I'm leaving it as is. -SG
+     *
+     * @param date1
+     * @param date2
+     * @return less, greater, equal, indeterminate
+     */
+    /*protected  short compareDates(DateTimeData date1, DateTimeData date2) {
+
+        if ( date1.utc==date2.utc ) {
+            return (short)((date1.month>=date2.month)?(date1.month>date2.month)?1:0:-1);
+        }
+
+        if ( date1.utc=='Z' || date2.utc=='Z' ) {
+
+            if ( date1.month==date2.month ) {
+                //--05--Z and --05--
+                return INDETERMINATE;
+            }
+            if ( (date1.month+1 == date2.month || date1.month-1 == date2.month) ) {
+                //--05--Z and (--04-- or --05--)
+                //REVISIT: should this case be less than or equal?
+                //         maxExclusive should fail but what about maxInclusive
+                //
+                return INDETERMINATE;
+            }
+        }
+
+        if ( date1.month<date2.month ) {
+            return -1;
+        }
+        else {
+            return 1;
+        }
+
+    }*/
+
+    /**
+     * Converts month object representation to String
+     *
+     * @param date   month object
+     * @return lexical representation of month: --MM with an optional time zone sign
+     */
+    @Override
+    protected String dateToString(DateTimeData date) {
+        StringBuffer message = new StringBuffer(5);
+        message.append('-');
+        message.append('-');
+        append(message, date.month, 2);
+        append(message, (char)date.utc, 0);
+        return message.toString();
+    }
+    
+    @Override
+    protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
+        return datatypeFactory.newXMLGregorianCalendar(DatatypeConstants.FIELD_UNDEFINED, date.unNormMonth, 
+                DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, 
+                DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, 
+                date.hasTimeZone() ? date.timezoneHr * 60 + date.timezoneMin : DatatypeConstants.FIELD_UNDEFINED);
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/MonthDayDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/MonthDayDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/MonthDayDV.java
new file mode 100644
index 0000000..db5af38
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/MonthDayDV.java
@@ -0,0 +1,132 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * Validator for &lt;gMonthDay&gt; datatype (W3C Schema Datatypes)
+ *
+ * @xerces.internal 
+ *
+ * @author Elena Litani
+ * @author Gopal Sharma, SUN Microsystem Inc.
+ *
+ * @version $Id: MonthDayDV.java 937741 2010-04-25 04:25:46Z mrglavas $
+ */
+
+public class MonthDayDV extends AbstractDateTimeDV {
+
+    //size without time zone: --MM-DD
+    private final static int MONTHDAY_SIZE = 7;
+
+    /**
+     * Convert a string to a compiled form
+     *
+     * @param  content The lexical representation of gMonthDay
+     * @return a valid and normalized gMonthDay object
+     */
+    @Override
+    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
+        try{
+            return parse(content);
+        } catch(Exception ex){
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gMonthDay"});
+        }
+    }
+
+    /**
+     * Parses, validates and computes normalized version of gMonthDay object
+     *
+     * @param str    The lexical representation of gMonthDay object --MM-DD
+     *               with possible time zone Z or (-),(+)hh:mm
+     * @return normalized date representation
+     * @exception SchemaDateTimeException Invalid lexical representation
+     */
+    protected DateTimeData parse(String str) throws SchemaDateTimeException{
+        DateTimeData date = new DateTimeData(str, this);
+        int len = str.length();
+
+        //initialize
+        date.year=YEAR;
+
+        if (str.charAt(0)!='-' || str.charAt(1)!='-') {
+            throw new SchemaDateTimeException("Invalid format for gMonthDay: "+str);
+        }
+        date.month=parseInt(str, 2, 4);
+        int start=4;
+
+        if (str.charAt(start++)!='-') {
+            throw new SchemaDateTimeException("Invalid format for gMonthDay: " + str);
+        }
+
+        date.day=parseInt(str, start, start+2);
+
+        if ( MONTHDAY_SIZE<len ) {
+            if (!isNextCharUTCSign(str, MONTHDAY_SIZE, len)) {
+                throw new SchemaDateTimeException ("Error in month parsing:" +str);
+            }
+            else {
+                getTimeZone(str, date, MONTHDAY_SIZE, len);
+            }
+        }
+        //validate and normalize
+
+        validateDateTime(date);
+        
+        //save unnormalized values
+        saveUnnormalized(date);
+        
+        if ( date.utc!=0 && date.utc!='Z' ) {
+            normalize(date);
+        }
+        date.position = 1;
+        return date;
+    }
+
+    /**
+     * Converts gMonthDay object representation to String
+     *
+     * @param date   gmonthDay object
+     * @return lexical representation of month: --MM-DD with an optional time zone sign
+     */
+    @Override
+    protected String dateToString(DateTimeData date) {
+        StringBuffer message = new StringBuffer(8);
+        message.append('-');
+        message.append('-');
+        append(message, date.month, 2);
+        message.append('-');
+        append(message, date.day, 2);
+        append(message, (char)date.utc, 0);
+        return message.toString();
+    }
+    
+    @Override
+    protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
+        return datatypeFactory.newXMLGregorianCalendar(DatatypeConstants.FIELD_UNDEFINED, date.unNormMonth, date.unNormDay, 
+                DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, 
+                DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, 
+                date.hasTimeZone() ? date.timezoneHr * 60 + date.timezoneMin : DatatypeConstants.FIELD_UNDEFINED);
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/PrecisionDecimalDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/PrecisionDecimalDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/PrecisionDecimalDV.java
new file mode 100644
index 0000000..e2bd4c3
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/PrecisionDecimalDV.java
@@ -0,0 +1,369 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * Validator for <precisionDecimal> datatype (W3C Schema 1.1)
+ * 
+ * @xerces.experimental
+ * 
+ * @author Ankit Pasricha, IBM
+ * 
+ * @version $Id: PrecisionDecimalDV.java 446745 2006-09-15 21:43:58Z mrglavas $
+ */
+@SuppressWarnings("all")
+class PrecisionDecimalDV extends TypeValidator {
+    
+    static class XPrecisionDecimal {
+        
+        // sign: 0 for absent; 1 for positive values; -1 for negative values (except in case of INF, -INF)
+        int sign = 1;
+        // total digits. >= 1
+        int totalDigits = 0;
+        // integer digits when sign != 0
+        int intDigits = 0;
+        // fraction digits when sign != 0
+        int fracDigits = 0;
+        //precision
+        //int precision = 0;
+        // the string representing the integer part
+        String ivalue = "";
+        // the string representing the fraction part
+        String fvalue = "";
+        
+        int pvalue = 0;
+        
+        
+        XPrecisionDecimal(String content) throws NumberFormatException {
+            if(content.equals("NaN")) {
+                ivalue = content;
+                sign = 0;
+            }
+            if(content.equals("+INF") || content.equals("INF") || content.equals("-INF")) {
+                ivalue = content.charAt(0) == '+' ? content.substring(1) : content;
+                return;
+            }
+            initD(content);
+        }
+        
+        void initD(String content) throws NumberFormatException {
+            int len = content.length();
+            if (len == 0)
+                throw new NumberFormatException();
+            
+            // these 4 variables are used to indicate where the integre/fraction
+            // parts start/end.
+            int intStart = 0, intEnd = 0, fracStart = 0, fracEnd = 0;
+            
+            // Deal with leading sign symbol if present
+            if (content.charAt(0) == '+') {
+                // skip '+', so intStart should be 1
+                intStart = 1;
+            }
+            else if (content.charAt(0) == '-') {
+                intStart = 1;
+                sign = -1;
+            }
+            
+            // skip leading zeroes in integer part
+            int actualIntStart = intStart;
+            while (actualIntStart < len && content.charAt(actualIntStart) == '0') {
+                actualIntStart++;
+            }
+            
+            // Find the ending position of the integer part
+            for (intEnd = actualIntStart; intEnd < len && TypeValidator.isDigit(content.charAt(intEnd)); intEnd++);
+            
+            // Not reached the end yet
+            if (intEnd < len) {
+                // the remaining part is not ".DDD" or "EDDD" or "eDDD", error
+                if (content.charAt(intEnd) != '.' && content.charAt(intEnd) != 'E' && content.charAt(intEnd) != 'e')
+                    throw new NumberFormatException();
+                
+                if(content.charAt(intEnd) == '.') {
+                    // fraction part starts after '.', and ends at the end of the input
+                    fracStart = intEnd + 1;
+                    
+                    // find location of E or e (if present)
+                    // Find the ending position of the fracion part
+                    for (fracEnd = fracStart;
+                    fracEnd < len && TypeValidator.isDigit(content.charAt(fracEnd));
+                    fracEnd++);
+                }
+                else {
+                    pvalue = Integer.parseInt(content.substring(intEnd + 1, len));
+                }
+            }
+            
+            // no integer part, no fraction part, error.
+            if (intStart == intEnd && fracStart == fracEnd)
+                throw new NumberFormatException();
+            
+            // ignore trailing zeroes in fraction part
+            /*while (fracEnd > fracStart && content.charAt(fracEnd-1) == '0') {
+             fracEnd--;
+             }*/
+            
+            // check whether there is non-digit characters in the fraction part
+            for (int fracPos = fracStart; fracPos < fracEnd; fracPos++) {
+                if (!TypeValidator.isDigit(content.charAt(fracPos)))
+                    throw new NumberFormatException();
+            }
+            
+            intDigits = intEnd - actualIntStart;
+            fracDigits = fracEnd - fracStart;
+            
+            if (intDigits > 0) {
+                ivalue = content.substring(actualIntStart, intEnd);
+            }
+            
+            if (fracDigits > 0) {
+                fvalue = content.substring(fracStart, fracEnd);
+                if(fracEnd < len) {
+                    pvalue = Integer.parseInt(content.substring(fracEnd + 1, len));
+                }
+            }
+            totalDigits = intDigits + fracDigits;
+        }
+        
+        
+        @Override
+        public boolean equals(Object val) {
+            if (val == this)
+                return true;
+            
+            if (!(val instanceof XPrecisionDecimal))
+                return false;
+            XPrecisionDecimal oval = (XPrecisionDecimal)val;
+            
+            return this.compareTo(oval) == EQUAL;
+        }
+        
+        /**
+         * @return
+         */
+        private int compareFractionalPart(XPrecisionDecimal oval) {
+            if(fvalue.equals(oval.fvalue))
+                return EQUAL;
+            
+            StringBuffer temp1 = new StringBuffer(fvalue);
+            StringBuffer temp2 = new StringBuffer(oval.fvalue);
+            
+            truncateTrailingZeros(temp1, temp2);
+            return temp1.toString().compareTo(temp2.toString());
+        }
+        
+        private void truncateTrailingZeros(StringBuffer fValue, StringBuffer otherFValue) {
+            for(int i = fValue.length() - 1;i >= 0; i--)
+                if(fValue.charAt(i) == '0')
+                    fValue.deleteCharAt(i);
+                else
+                    break;
+            
+            for(int i = otherFValue.length() - 1;i >= 0; i--)
+                if(otherFValue.charAt(i) == '0')
+                    otherFValue.deleteCharAt(i);
+                else
+                    break;
+        }
+        
+        public int compareTo(XPrecisionDecimal val) {
+            
+            // seen NaN
+            if(sign == 0)
+                return INDETERMINATE;
+            
+            //INF is greater than everything and equal to itself
+            if(ivalue.equals("INF") || val.ivalue.equals("INF")) {
+                if(ivalue.equals(val.ivalue))
+                    return EQUAL;
+                else if(ivalue.equals("INF"))
+                    return GREATER_THAN;
+                return LESS_THAN;
+            }
+            
+            //-INF is smaller than everything and equal itself
+            if(ivalue.equals("-INF") || val.ivalue.equals("-INF")) {
+                if(ivalue.equals(val.ivalue))
+                    return EQUAL;
+                else if(ivalue.equals("-INF"))
+                    return LESS_THAN;
+                return GREATER_THAN;
+            }
+            
+            if (sign != val.sign)
+                return sign > val.sign ? GREATER_THAN : LESS_THAN;
+            
+            return sign * compare(val);
+        }
+        
+        // To enable comparison - the exponent part of the decimal will be limited
+        // to the max value of int.
+        private int compare(XPrecisionDecimal val) {     	
+            
+            if(pvalue != 0 || val.pvalue != 0) {
+                if(pvalue == val.pvalue)
+                    return intComp(val);
+                else {
+                    
+                    if(intDigits + pvalue != val.intDigits + val.pvalue)
+                        return intDigits + pvalue > val.intDigits + val.pvalue ? GREATER_THAN : LESS_THAN;
+                    
+                    //otherwise the 2 combined values are the same
+                    if(pvalue > val.pvalue) {
+                        int expDiff = pvalue - val.pvalue;
+                        StringBuffer buffer = new StringBuffer(ivalue);
+                        StringBuffer fbuffer = new StringBuffer(fvalue);
+                        for(int i = 0;i < expDiff; i++) {
+                            if(i < fracDigits) {
+                                buffer.append(fvalue.charAt(i));
+                                fbuffer.deleteCharAt(i);
+                            }
+                            else
+                                buffer.append('0');
+                        }       				
+                        return compareDecimal(buffer.toString(), val.ivalue, fbuffer.toString(), val.fvalue);
+                    }
+                    else {
+                        int expDiff = val.pvalue - pvalue;
+                        StringBuffer buffer = new StringBuffer(val.ivalue);
+                        StringBuffer fbuffer = new StringBuffer(val.fvalue);
+                        for(int i = 0;i < expDiff; i++) {
+                            if(i < val.fracDigits) {
+                                buffer.append(val.fvalue.charAt(i));
+                                fbuffer.deleteCharAt(i);
+                            }
+                            else
+                                buffer.append('0');
+                        }       				
+                        return compareDecimal(ivalue, buffer.toString(), fvalue, fbuffer.toString());
+                    }
+                }
+            }
+            else {
+                return intComp(val);
+            }
+        }
+        
+        /**
+         * @param val
+         * @return
+         */
+        private int intComp(XPrecisionDecimal val) {
+            if (intDigits != val.intDigits)
+                return intDigits > val.intDigits ? GREATER_THAN : LESS_THAN;
+            
+            return compareDecimal(ivalue, val.ivalue, fvalue, val.fvalue);
+        }
+        
+        /**
+         * @param val
+         * @return
+         */
+        private int compareDecimal(String iValue, String fValue, String otherIValue, String otherFValue) {
+            int ret = iValue.compareTo(otherIValue);
+            if (ret != 0)
+                return ret > 0 ? GREATER_THAN : LESS_THAN;
+            
+            if(fValue.equals(otherFValue))
+                return EQUAL;
+            
+            StringBuffer temp1=new StringBuffer(fValue);
+            StringBuffer temp2=new StringBuffer(otherFValue);
+            
+            truncateTrailingZeros(temp1, temp2);
+            ret = temp1.toString().compareTo(temp2.toString());
+            return ret == 0 ? EQUAL : (ret > 0 ? GREATER_THAN : LESS_THAN);
+        }
+        
+        private String canonical;
+        
+        @Override
+        public synchronized String toString() {
+            if (canonical == null) {
+                makeCanonical();
+            }
+            return canonical;
+        }
+        
+        private void makeCanonical() {
+            // REVISIT: to be determined by working group
+            canonical = "TBD by Working Group";
+        }
+        
+        /**
+         * @param decimal
+         * @return
+         */
+        public boolean isIdentical(XPrecisionDecimal decimal) {
+            if(ivalue.equals(decimal.ivalue) && (ivalue.equals("INF") || ivalue.equals("-INF") || ivalue.equals("NaN")))
+                return true;
+            
+            if(sign == decimal.sign && intDigits == decimal.intDigits && fracDigits == decimal.fracDigits && pvalue == decimal.pvalue 
+                    && ivalue.equals(decimal.ivalue) && fvalue.equals(decimal.fvalue))
+                return true;
+            return false;
+        }
+        
+    }
+    /* (non-Javadoc)
+     * @see org.apache.xerces.impl.dv.xs.TypeValidator#getAllowedFacets()
+     */
+    @Override
+    public short getAllowedFacets() {
+        return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE  | XSSimpleTypeDecl.FACET_MINEXCLUSIVE | XSSimpleTypeDecl.FACET_TOTALDIGITS | XSSimpleTypeDecl.FACET_FRACTIONDIGITS);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.xerces.impl.dv.xs.TypeValidator#getActualValue(java.lang.String, org.apache.xerces.impl.dv.ValidationContext)
+     */
+    @Override
+    public Object getActualValue(String content, ValidationContext context)
+    throws InvalidDatatypeValueException {
+        try {
+            return new XPrecisionDecimal(content);
+        } catch (NumberFormatException nfe) {
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "precisionDecimal"});
+        }
+    }
+    
+    @Override
+    public int compare(Object value1, Object value2) {
+        return ((XPrecisionDecimal)value1).compareTo((XPrecisionDecimal)value2);
+    }
+    
+    @Override
+    public int getFractionDigits(Object value) {
+        return ((XPrecisionDecimal)value).fracDigits;
+    }
+    
+    @Override
+    public int getTotalDigits(Object value) {
+        return ((XPrecisionDecimal)value).totalDigits;
+    }
+    
+    @Override
+    public boolean isIdentical(Object value1, Object value2) {
+        if(!(value2 instanceof XPrecisionDecimal) || !(value1 instanceof XPrecisionDecimal))
+            return false;
+        return ((XPrecisionDecimal)value1).isIdentical((XPrecisionDecimal)value2);	
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/QNameDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/QNameDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/QNameDV.java
new file mode 100644
index 0000000..f0ac0ed
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/QNameDV.java
@@ -0,0 +1,112 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+// UNUSED
+public class QNameDV {}
+//
+//import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
+//import org.apache.xerces.impl.dv.ValidationContext;
+//import org.apache.xerces.util.XMLChar;
+//import org.apache.xerces.xni.QName;
+//import org.apache.xerces.xs.datatypes.XSQName;
+//
+///**
+// * Represent the schema type "QName" and "NOTATION"
+// *
+// * @xerces.internal 
+// *
+// * @author Neeraj Bajaj, Sun Microsystems, inc.
+// * @author Sandy Gao, IBM
+// *
+// * @version $Id: QNameDV.java 701915 2008-10-06 02:39:42Z mrglavas $
+// */
+//public class QNameDV extends TypeValidator {
+//
+//    private static final String EMPTY_STRING = "".intern();
+//
+//    public short getAllowedFacets() {
+//        return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE);
+//    }
+//
+//    public Object getActualValue(String content, ValidationContext context)
+//        throws InvalidDatatypeValueException {
+//
+//        // "prefix:localpart" or "localpart"
+//        // get prefix and local part out of content
+//        String prefix, localpart;
+//        int colonptr = content.indexOf(":");
+//        if (colonptr > 0) {
+//            prefix = context.getSymbol(content.substring(0,colonptr));
+//            localpart = content.substring(colonptr+1);
+//        } else {
+//            prefix = EMPTY_STRING;
+//            localpart = content;
+//        }
+//
+//        // both prefix (if any) a nd localpart must be valid NCName
+//        if (prefix.length() > 0 && !XMLChar.isValidNCName(prefix))
+//            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "QName"});
+//
+//        if(!XMLChar.isValidNCName(localpart))
+//            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "QName"});
+//
+//        // resove prefix to a uri, report an error if failed
+//        String uri = context.getURI(prefix);
+//        if (prefix.length() > 0 && uri == null)
+//            throw new InvalidDatatypeValueException("UndeclaredPrefix", new Object[]{content, prefix});
+//
+//        return new XQName(prefix, context.getSymbol(localpart), context.getSymbol(content), uri);
+//
+//    }
+//
+//    // REVISIT: qname and notation shouldn't support length facets.
+//    //          now we just return the length of the rawname
+//    public int getDataLength(Object value) {
+//        return ((XQName)value).rawname.length();
+//    }
+//
+//    /**
+//     * represent QName data
+//     */
+//    private static final class XQName extends QName implements XSQName {
+//        /** Constructs a QName with the specified values. */
+//        public XQName(String prefix, String localpart, String rawname, String uri) {
+//            setValues(prefix, localpart, rawname, uri);
+//        } // <init>(String,String,String,String)
+//
+//        /** Returns true if the two objects are equal. */
+//        public boolean equals(Object object) {
+//            if (object instanceof QName) {
+//                QName qname = (QName)object;
+//                return uri == qname.uri && localpart == qname.localpart;
+//            }
+//            return false;
+//        } // equals(Object):boolean
+//
+//        public String toString() {
+//            return rawname;
+//        }
+//        public javax.xml.namespace.QName getJAXPQName() {
+//            return new javax.xml.namespace.QName(uri, localpart, prefix);
+//        }
+//        public QName getXNIQName() {
+//            return this;
+//        }
+//    }
+//} // class QNameDVDV

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/SchemaDVFactoryImpl.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
new file mode 100644
index 0000000..54520e4
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
@@ -0,0 +1,76 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import org.apache.jena.ext.xerces.impl.dv.XSSimpleType;
+import org.apache.jena.ext.xerces.util.SymbolHash;
+
+/**
+ * the factory to create/return built-in schema 1.0 DVs and create user-defined DVs
+ * 
+ * @xerces.internal 
+ *
+ * @author Neeraj Bajaj, Sun Microsystems, inc.
+ * @author Sandy Gao, IBM
+ * @author Khaled Noaman, IBM
+ *
+ * @version $Id: SchemaDVFactoryImpl.java 710089 2008-11-03 16:01:16Z knoaman $
+ */
+public class SchemaDVFactoryImpl extends BaseSchemaDVFactory {
+
+    static final SymbolHash fBuiltInTypes = new SymbolHash();
+    
+    static {
+        createBuiltInTypes();
+    }
+
+    // create all built-in types
+    static void createBuiltInTypes() {
+    	createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnySimpleType);
+    	
+        // TODO: move specific 1.0 DV implementation from base
+    } //createBuiltInTypes()
+
+    /**
+     * Get a built-in simple type of the given name
+     * REVISIT: its still not decided within the Schema WG how to define the
+     *          ur-types and if all simple types should be derived from a
+     *          complex type, so as of now we ignore the fact that anySimpleType
+     *          is derived from anyType, and pass 'null' as the base of
+     *          anySimpleType. It needs to be changed as per the decision taken.
+     *
+     * @param name  the name of the datatype
+     * @return      the datatype validator of the given name
+     */
+    @Override
+    public XSSimpleType getBuiltInType(String name) {
+        return (XSSimpleType)fBuiltInTypes.get(name);
+    }
+
+    /**
+     * get all built-in simple types, which are stored in a hashtable keyed by
+     * the name
+     *
+     * @return      a hashtable which contains all built-in simple types
+     */
+    @Override
+    public SymbolHash getBuiltInTypes() {
+        return fBuiltInTypes.makeClone();
+    }
+
+}//SchemaDVFactoryImpl

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/SchemaDateTimeException.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/SchemaDateTimeException.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/SchemaDateTimeException.java
new file mode 100644
index 0000000..265b33a
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/SchemaDateTimeException.java
@@ -0,0 +1,37 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+/**
+ * @xerces.internal 
+ *  
+ * @version $Id: SchemaDateTimeException.java 446745 2006-09-15 21:43:58Z mrglavas $
+ */
+public class SchemaDateTimeException extends RuntimeException {
+    
+    /** Serialization version. */
+    static final long serialVersionUID = -8520832235337769040L;
+    
+    public SchemaDateTimeException () {
+        super();
+    }
+
+    public SchemaDateTimeException (String s) {
+        super (s);
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/StringDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/StringDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/StringDV.java
new file mode 100644
index 0000000..aa75e41
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/StringDV.java
@@ -0,0 +1,46 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * Represent the schema type "string"
+ * 
+ * @xerces.internal 
+ *
+ * @author Neeraj Bajaj, Sun Microsystems, inc.
+ * @author Sandy Gao, IBM
+ *
+ * @version $Id: StringDV.java 446745 2006-09-15 21:43:58Z mrglavas $
+ */
+public class StringDV extends TypeValidator {
+
+    @Override
+    public short getAllowedFacets(){
+        return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
+    }
+
+    @Override
+    public Object getActualValue(String content, ValidationContext context)
+        throws InvalidDatatypeValueException {
+        return content;
+    }
+
+} // class StringDV

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/TimeDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/TimeDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/TimeDV.java
new file mode 100644
index 0000000..e5342b4
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/TimeDV.java
@@ -0,0 +1,114 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * Validator for &lt;time&gt; datatype (W3C Schema Datatypes)
+ * 
+ * @xerces.internal 
+ *
+ * @author Elena Litani
+ * @author Gopal Sharma, SUN Microsystem Inc.
+ *
+ * @version $Id: TimeDV.java 937741 2010-04-25 04:25:46Z mrglavas $
+ */
+public class TimeDV extends AbstractDateTimeDV {
+
+    /**
+     * Convert a string to a compiled form
+     *
+     * @param  content The lexical representation of time
+     * @return a valid and normalized time object
+     */
+    @Override
+    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
+        try{
+            return parse(content);
+        } catch(Exception ex){
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "time"});
+        }
+    }
+
+    /**
+     * Parses, validates and computes normalized version of time object
+     *
+     * @param str    The lexical representation of time object hh:mm:ss.sss
+     *               with possible time zone Z or (-),(+)hh:mm
+     *               Pattern: "(\\d\\d):(\\d\\d):(\\d\\d)(\\.(\\d)*)?(Z|(([-+])(\\d\\d)(:(\\d\\d))?))?")
+     * @return normalized time representation
+     * @exception SchemaDateTimeException Invalid lexical representation
+     */
+    protected DateTimeData parse(String str) throws SchemaDateTimeException{
+        DateTimeData date = new DateTimeData(str, this);
+        int len = str.length();
+
+        // time
+        // initialize to default values
+        date.year=YEAR;
+        date.month=MONTH;
+        date.day=15;
+        getTime(str, 0, len, date);
+
+        //validate and normalize
+
+        validateDateTime(date);
+
+        //save unnormalized values
+        saveUnnormalized(date);
+        
+        if ( date.utc!=0 && date.utc != 'Z') {
+            normalize(date);
+            date.day = 15;
+        }
+        date.position = 2;
+        return date;
+    }
+
+    /**
+     * Converts time object representation to String
+     *
+     * @param date   time object
+     * @return lexical representation of time: hh:mm:ss.sss with an optional time zone sign
+     */
+    @Override
+    protected String dateToString(DateTimeData date) {
+        StringBuffer message = new StringBuffer(16);
+        append(message, date.hour, 2);
+        message.append(':');
+        append(message, date.minute, 2);
+        message.append(':');
+        append(message, date.second);
+
+        append(message, (char)date.utc, 0);
+        return message.toString();
+    }
+    
+    @Override
+    protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
+        return datatypeFactory.newXMLGregorianCalendar(null, DatatypeConstants.FIELD_UNDEFINED, 
+                DatatypeConstants.FIELD_UNDEFINED, date.unNormHour, date.unNormMinute, 
+                (int)date.unNormSecond, date.unNormSecond != 0 ? getFractionalSecondsAsBigDecimal(date) : null,
+                date.hasTimeZone() ? (date.timezoneHr * 60 + date.timezoneMin) : DatatypeConstants.FIELD_UNDEFINED);
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/TypeValidator.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/TypeValidator.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/TypeValidator.java
new file mode 100644
index 0000000..8149c95
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/TypeValidator.java
@@ -0,0 +1,108 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * All primitive types plus ID/IDREF/ENTITY/INTEGER are derived from this abstract
+ * class. It provides extra information XSSimpleTypeDecl requires from each
+ * type: allowed facets, converting String to actual value, check equality,
+ * comparison, etc.
+ * 
+ * @xerces.internal 
+ *
+ * @author Neeraj Bajaj, Sun Microsystems, inc.
+ * @author Sandy Gao, IBM
+ *
+ * @version $Id: TypeValidator.java 446745 2006-09-15 21:43:58Z mrglavas $
+ */
+public abstract class TypeValidator {
+
+    // which facets are allowed for this type
+    public abstract short getAllowedFacets();
+
+    // convert a string to an actual value. for example,
+    // for number types (decimal, double, float, and types derived from them),
+    // get the BigDecimal, Double, Flout object.
+    // for some types (string and derived), they just return the string itself
+    public abstract Object getActualValue(String content, ValidationContext context)
+        throws InvalidDatatypeValueException;
+
+    // for ID/IDREF/ENTITY types, do some extra checking after the value is
+    // checked to be valid with respect to both lexical representation and
+    // facets
+    public void checkExtraRules(Object value, ValidationContext context) throws InvalidDatatypeValueException {
+    }
+
+    // the following methods might not be supported by every DV.
+    // but XSSimpleTypeDecl should know which type supports which methods,
+    // and it's an *internal* error if a method is called on a DV that
+    // doesn't support it.
+
+    //order constants
+    public static final short LESS_THAN     = -1;
+    public static final short EQUAL         = 0;
+    public static final short GREATER_THAN  = 1;
+    public static final short INDETERMINATE = 2;
+    
+    // where there is distinction between identity and equality, this method
+    // will be overwritten
+    // checks whether the two values are identical; for ex, this distinguishes 
+    // -0.0 from 0.0 
+    public boolean isIdentical (Object value1, Object value2) {
+        return value1.equals(value2);
+    }
+
+    // check the order relation between the two values
+    // the parameters are in compiled form (from getActualValue)
+    public int compare(Object value1, Object value2) {
+        return -1;
+    }
+
+    // get the length of the value
+    // the parameters are in compiled form (from getActualValue)
+    public int getDataLength(Object value) {
+        return (value instanceof String) ? ((String)value).length() : -1;
+    }
+
+    // get the number of digits of the value
+    // the parameters are in compiled form (from getActualValue)
+    public int getTotalDigits(Object value) {
+        return -1;
+    }
+
+    // get the number of fraction digits of the value
+    // the parameters are in compiled form (from getActualValue)
+    public int getFractionDigits(Object value) {
+        return -1;
+    }
+
+    // check whether the character is in the range 0x30 ~ 0x39
+    public static final boolean isDigit(char ch) {
+        return ch >= '0' && ch <= '9';
+    }
+    
+    // if the character is in the range 0x30 ~ 0x39, return its int value (0~9),
+    // otherwise, return -1
+    public static final int getDigit(char ch) {
+        return isDigit(ch) ? ch - '0' : -1;
+    }
+    
+} // interface TypeValidator

http://git-wip-us.apache.org/repos/asf/jena/blob/c9a7e646/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/UnionDV.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/UnionDV.java b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/UnionDV.java
new file mode 100644
index 0000000..0421f3e
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/UnionDV.java
@@ -0,0 +1,47 @@
+/*
+ * 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.jena.ext.xerces.impl.dv.xs;
+
+import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
+
+/**
+ * Represent the schema union types
+ * 
+ * @xerces.internal 
+ *
+ * @author Neeraj Bajaj, Sun Microsystems, inc.
+ * @author Sandy Gao, IBM
+ *
+ * @version $Id: UnionDV.java 446745 2006-09-15 21:43:58Z mrglavas $
+ */
+public class UnionDV extends TypeValidator{
+
+    @Override
+    public short getAllowedFacets(){
+          return (XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION );
+    }
+
+    // this method should never be called: XSSimpleTypeDecl is responsible for
+    // calling the member types for the convertion
+    @Override
+    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
+        return content;
+    }
+
+} // class UnionDV