mrglavas 2004/09/14 22:12:24 Modified: java/src/org/apache/xerces/impl/dv/xs HexBinaryDV.java ListDV.java DurationDV.java FloatDV.java Base64BinaryDV.java XSSimpleTypeDecl.java DoubleDV.java SchemaDVFactoryImpl.java java/src/org/apache/xerces/impl Constants.java java/src/org/apache/xerces/xs XSConstants.java Added: java/src/org/apache/xerces/impl/dv/xs DayTimeDurationDV.java YearMonthDurationDV.java java/src/org/apache/xerces/xs/datatypes XSDouble.java ObjectList.java ByteList.java XSFloat.java java/src/org/apache/xerces/impl/dv/util ByteListImpl.java Log: Initial support for XML Schema 1.1. Adding datatype validators
for the two new duration types as well as some interfaces for actual values: List, Double, Float, HexBinary, Base64. Thanks to Ankit Pasricha for this contribution. Revision Changes Path 1.6 +8 -11 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java Index: HexBinaryDV.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- HexBinaryDV.java 24 Feb 2004 22:44:24 -0000 1.5 +++ HexBinaryDV.java 15 Sep 2004 05:12:23 -0000 1.6 @@ -18,6 +18,7 @@ import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidationContext; +import org.apache.xerces.impl.dv.util.ByteListImpl; import org.apache.xerces.impl.dv.util.HexBin; /** @@ -44,16 +45,13 @@ // length of a binary type is the number of bytes public int getDataLength(Object value) { - return ((XHex)value).length(); + return ((XHex)value).getLength(); } - private static final class XHex { - // actually data stored in a byte array - final byte[] data; - // canonical representation of the data - private String canonical; + private static final class XHex extends ByteListImpl { + public XHex(byte[] data) { - this.data = data; + super(data); } public synchronized String toString() { if (canonical == null) { @@ -61,9 +59,7 @@ } return canonical; } - public int length() { - return data.length; - } + public boolean equals(Object obj) { if (!(obj instanceof XHex)) return false; @@ -77,5 +73,6 @@ } return true; } + } } 1.7 +20 -7 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/ListDV.java Index: ListDV.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/ListDV.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ListDV.java 24 Feb 2004 22:44:24 -0000 1.6 +++ ListDV.java 15 Sep 2004 05:12:23 -0000 1.7 @@ -18,6 +18,8 @@ import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidationContext; +import org.apache.xerces.xs.XSException; +import org.apache.xerces.xs.datatypes.ObjectList; /** * Represent the schema list types @@ -41,10 +43,10 @@ // length of a list type is the number of items in the list public int getDataLength(Object value) { - return ((ListData)value).length(); + return ((ListData)value).getLength(); } - final static class ListData { + final static class ListData implements ObjectList { final Object[] data; private String canonical; public ListData(Object[] data) { @@ -65,12 +67,9 @@ } return canonical; } - public int length() { + public int getLength() { return data.length; } - public Object item(int index) { - return data[index]; - } public boolean equals(Object obj) { if (!(obj instanceof ListData)) return false; @@ -87,6 +86,20 @@ //everything went fine. return true; + } + + public boolean contains(Object item) { + for(int i = 0;i < data.length; i++) { + if(item == data[i]) + return true; + } + return false; + } + + public Object item(int index) throws XSException { + if(index < 0 || index > data.length - 1) + throw new XSException(XSException.INDEX_SIZE_ERR, null); + return data[index]; } } } // class ListDV 1.11 +38 -16 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DurationDV.java Index: DurationDV.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DurationDV.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- DurationDV.java 26 Aug 2004 02:14:40 -0000 1.10 +++ DurationDV.java 15 Sep 2004 05:12:23 -0000 1.11 @@ -28,6 +28,9 @@ */ public class DurationDV extends AbstractDateTimeDV { + public static final int DURATION_TYPE = 0; + public static final int YEARMONTHDURATION_TYPE = 1; + public static final int DAYTIMEDURATION_TYPE = 2; // order-relation on duration is a partial order. The dates below are used to // for comparison of 2 durations, based on the fact that // duration x and y is x<=y iff s+x<=s+y @@ -42,7 +45,7 @@ public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{ try{ - return parse(content); + return parse(content, DURATION_TYPE); } catch (Exception ex) { throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "duration"}); } @@ -56,10 +59,10 @@ * @return normalized date representation * @exception SchemaDateTimeException Invalid lexical representation */ - protected DateTimeData parse(String str) throws SchemaDateTimeException{ + protected DateTimeData parse(String str, int durationType) throws SchemaDateTimeException{ int len = str.length(); DateTimeData date= new DateTimeData(this); - + int start = 0; char c=str.charAt(start++); if ( c!='P' && c!='-' ) { @@ -71,54 +74,73 @@ throw new SchemaDateTimeException(); } } - + int negate = 1; //negative duration if ( date.utc=='-' ) { negate = -1; - + } //at least one number and designator must be seen after P boolean designator = false; - + int endDate = indexOf (str, start, len, 'T'); if ( endDate == -1 ) { endDate = len; } + else if (durationType == YEARMONTHDURATION_TYPE) { + throw new SchemaDateTimeException(); + } + //find 'Y' int end = indexOf (str, start, endDate, 'Y'); if ( end!=-1 ) { + + if (durationType == DAYTIMEDURATION_TYPE) { + throw new SchemaDateTimeException(); + } + //scan year date.year=negate * parseInt(str,start,end); start = end+1; designator = true; } - + end = indexOf (str, start, endDate, 'M'); if ( end!=-1 ) { + + if (durationType == DAYTIMEDURATION_TYPE) { + throw new SchemaDateTimeException(); + } + //scan month date.month=negate * parseInt(str,start,end); start = end+1; designator = true; } - + end = indexOf (str, start, endDate, 'D'); if ( end!=-1 ) { + + if(durationType == YEARMONTHDURATION_TYPE) { + throw new SchemaDateTimeException(); + } + //scan day date.day=negate * parseInt(str,start,end); start = end+1; designator = true; } - + if ( len == endDate && start!=len ) { throw new SchemaDateTimeException(); } if ( len !=endDate ) { - + //scan hours, minutes, seconds //REVISIT: can any item include a decimal fraction or only seconds? // - + end = indexOf (str, ++start, len, 'H'); if ( end!=-1 ) { //scan hours @@ -126,7 +148,7 @@ start=end+1; designator = true; } - + end = indexOf (str, start, len, 'M'); if ( end!=-1 ) { //scan min @@ -134,7 +156,7 @@ start=end+1; designator = true; } - + end = indexOf (str, start, len, 'S'); if ( end!=-1 ) { //scan seconds @@ -148,11 +170,11 @@ throw new SchemaDateTimeException(); } } - + if ( !designator ) { throw new SchemaDateTimeException(); } - + return date; } 1.8 +8 -2 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/FloatDV.java Index: FloatDV.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/FloatDV.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- FloatDV.java 24 Feb 2004 22:44:24 -0000 1.7 +++ FloatDV.java 15 Sep 2004 05:12:23 -0000 1.8 @@ -18,6 +18,7 @@ import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidationContext; +import org.apache.xerces.xs.datatypes.XSFloat; /** * Represent the schema type "float" @@ -47,7 +48,8 @@ return ((XFloat)value1).compareTo((XFloat)value2); }//compare() - private static final class XFloat { + private static final class XFloat implements XSFloat { + private float value; public XFloat(String s) throws NumberFormatException { try { @@ -195,6 +197,10 @@ } } return canonical; + } + + public float getValue() { + return value; } } } // class FloatDV 1.6 +7 -11 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/Base64BinaryDV.java Index: Base64BinaryDV.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/Base64BinaryDV.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Base64BinaryDV.java 24 Feb 2004 22:44:24 -0000 1.5 +++ Base64BinaryDV.java 15 Sep 2004 05:12:23 -0000 1.6 @@ -19,6 +19,7 @@ import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidationContext; import org.apache.xerces.impl.dv.util.Base64; +import org.apache.xerces.impl.dv.util.ByteListImpl; /** * Represent the schema type "base64Binary" @@ -44,19 +45,16 @@ // length of a binary type is the number of bytes public int getDataLength(Object value) { - return ((XBase64)value).length(); + return ((XBase64)value).getLength(); } /** * represent base64 data */ - private static final class XBase64 { - // actually data stored in a byte array - final byte[] data; - // canonical representation of the data - private String canonical; + private static final class XBase64 extends ByteListImpl { + public XBase64(byte[] data) { - this.data = data; + super(data); } public synchronized String toString() { if (canonical == null) { @@ -64,9 +62,7 @@ } return canonical; } - public int length() { - return data.length; - } + public boolean equals(Object obj) { if (!(obj instanceof XBase64)) return false; 1.53 +11 -5 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java Index: XSSimpleTypeDecl.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- XSSimpleTypeDecl.java 19 May 2004 14:05:04 -0000 1.52 +++ XSSimpleTypeDecl.java 15 Sep 2004 05:12:23 -0000 1.53 @@ -77,6 +77,8 @@ static final short DV_INTEGER = DV_NOTATION + 4; static final short DV_LIST = DV_NOTATION + 5; static final short DV_UNION = DV_NOTATION + 6; + static final short DV_YEARMONTHDURATION = DV_NOTATION + 7; + static final short DV_DAYTIMEDURATION = DV_NOTATION + 8; static final TypeValidator[] fDVs = { new AnySimpleDV(), @@ -104,7 +106,9 @@ new EntityDV(), new IntegerDV(), new ListDV(), - new UnionDV() + new UnionDV(), + new YearMonthDurationDV(), // XML Schema 1.1 type + new DayTimeDurationDV() // XML Schema 1.1 type }; static final short NORMALIZE_NONE = 0; @@ -136,7 +140,9 @@ NORMALIZE_TRIM, //EntityDV(), NORMALIZE_TRIM, //IntegerDV(), NORMALIZE_FULL, //ListDV(), - NORMALIZE_NONE, //UnionDV() + NORMALIZE_NONE, //UnionDV(), + NORMALIZE_TRIM, //YearMonthDurationDV() (Schema 1.1) + NORMALIZE_TRIM, //DayTimeDurationDV() (Schema 1.1) }; static final short SPECIAL_PATTERN_NONE = 0; @@ -260,7 +266,7 @@ // default constructor public XSSimpleTypeDecl(){} - //Create a new built-in primitive types (and id/idref/entity/integer) + //Create a new built-in primitive types (and id/idref/entity/integer/yearMonthDuration) protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, short validateDV, short ordered, boolean bounded, boolean finite, boolean numeric, boolean isImmutable, short builtInKind) { @@ -1607,7 +1613,7 @@ } else if (fVariety == VARIETY_LIST) { ListDV.ListData values = (ListDV.ListData)ob; - int len = values.length(); + int len = values.getLength(); if (fItemType.fVariety == VARIETY_UNION) { XSSimpleTypeDecl[] memberTypes = (XSSimpleTypeDecl[])validatedInfo.memberTypes; XSSimpleType memberType = validatedInfo.memberType; 1.8 +6 -2 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DoubleDV.java Index: DoubleDV.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DoubleDV.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DoubleDV.java 24 Feb 2004 22:44:24 -0000 1.7 +++ DoubleDV.java 15 Sep 2004 05:12:23 -0000 1.8 @@ -18,6 +18,7 @@ import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidationContext; +import org.apache.xerces.xs.datatypes.XSDouble; /** * Represent the schema type "double" @@ -47,7 +48,7 @@ return ((XDouble)value1).compareTo((XDouble)value2); }//compare() - private static final class XDouble { + private static final class XDouble implements XSDouble { private double value; public XDouble(String s) throws NumberFormatException { try { @@ -195,6 +196,9 @@ } } return canonical; + } + public double getValue() { + return value; } } } // class DoubleDV 1.16 +15 -4 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java Index: SchemaDVFactoryImpl.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- SchemaDVFactoryImpl.java 24 Feb 2004 22:44:24 -0000 1.15 +++ SchemaDVFactoryImpl.java 15 Sep 2004 05:12:23 -0000 1.16 @@ -16,13 +16,14 @@ package org.apache.xerces.impl.dv.xs; +import org.apache.xerces.impl.Constants; import org.apache.xerces.impl.dv.SchemaDVFactory; -import org.apache.xerces.impl.dv.XSSimpleType; import org.apache.xerces.impl.dv.XSFacets; +import org.apache.xerces.impl.dv.XSSimpleType; import org.apache.xerces.impl.xs.XSDeclarationPool; +import org.apache.xerces.util.SymbolHash; import org.apache.xerces.xs.XSConstants; import org.apache.xerces.xs.XSObjectList; -import org.apache.xerces.util.SymbolHash; /** * the factory to create/return built-in schema DVs and create user-defined DVs @@ -183,6 +184,8 @@ final String UNSIGNEDSHORT = "unsignedShort"; final String YEAR = "gYear"; final String YEARMONTH = "gYearMonth"; + final String YEARMONTHDURATION = "yearMonthDuration"; + final String DAYTIMEDURATION = "dayTimeDuration"; final XSFacets facets = new XSFacets(); @@ -197,7 +200,15 @@ fBuiltInTypes.put(ANYURI, new XSSimpleTypeDecl(anySimpleType, ANYURI, XSSimpleTypeDecl.DV_ANYURI, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ANYURI_DT)); fBuiltInTypes.put(BASE64BINARY, new XSSimpleTypeDecl(anySimpleType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.BASE64BINARY_DT)); - fBuiltInTypes.put(DURATION, new XSSimpleTypeDecl(anySimpleType, DURATION, XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DURATION_DT)); + + XSSimpleTypeDecl durationDV = new XSSimpleTypeDecl(anySimpleType, DURATION, XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DURATION_DT); + fBuiltInTypes.put(DURATION, durationDV); + + if (Constants.SCHEMA_1_1_SUPPORT) { + fBuiltInTypes.put(YEARMONTHDURATION, new XSSimpleTypeDecl(durationDV, YEARMONTHDURATION, XSSimpleTypeDecl.DV_YEARMONTHDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.YEARMONTHDURATION_DT)); + fBuiltInTypes.put(DAYTIMEDURATION, new XSSimpleTypeDecl(durationDV, DAYTIMEDURATION, XSSimpleTypeDecl.DV_DAYTIMEDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DAYTIMEDURATION_DT)); + } + fBuiltInTypes.put(DATETIME, new XSSimpleTypeDecl(anySimpleType, DATETIME, XSSimpleTypeDecl.DV_DATETIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATETIME_DT)); fBuiltInTypes.put(TIME, new XSSimpleTypeDecl(anySimpleType, TIME, XSSimpleTypeDecl.DV_TIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.TIME_DT)); fBuiltInTypes.put(DATE, new XSSimpleTypeDecl(anySimpleType, DATE, XSSimpleTypeDecl.DV_DATE, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATE_DT)); 1.1 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DayTimeDurationDV.java Index: DayTimeDurationDV.java =================================================================== /* * Copyright 2001, 2002,2004 The Apache Software Foundation. * * Licensed 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.xerces.impl.dv.xs; import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidationContext; /** * Used to validate the <dayTimeDuration> type * * @author Ankit Pasricha, IBM */ public class DayTimeDurationDV extends DurationDV { public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException { try { return parse(content, DurationDV.DAYTIMEDURATION_TYPE); } catch (Exception ex) { throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "dayTimeDuration"}); } } } 1.1 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/YearMonthDurationDV.java Index: YearMonthDurationDV.java =================================================================== /* * Copyright 2001, 2002,2004 The Apache Software Foundation. * * Licensed 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.xerces.impl.dv.xs; import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidationContext; /** * Used to validate the <yearMonthDuration> type * * @author Ankit Pasricha, IBM */ public class YearMonthDurationDV extends DurationDV { public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException { try { return parse(content, DurationDV.YEARMONTHDURATION_TYPE); } catch (Exception ex) { throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "yearMonthDuration"}); } } } 1.1 xml-xerces/java/src/org/apache/xerces/xs/datatypes/XSDouble.java Index: XSDouble.java =================================================================== /* * Copyright 2001, 2002,2004 The Apache Software Foundation. * * Licensed 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.xerces.xs.datatypes; /** * EXPERIMENTAL: Interface to expose the value of the 'double' datatype. * * @author Ankit Pasricha, IBM */ public interface XSDouble { /** * @return value */ public double getValue(); } 1.1 xml-xerces/java/src/org/apache/xerces/xs/datatypes/ObjectList.java Index: ObjectList.java =================================================================== /* * Copyright 2001, 2002,2004 The Apache Software Foundation. * * Licensed 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.xerces.xs.datatypes; import org.apache.xerces.xs.XSException; /** * EXPERIMENTAL: The <code>ObjectList</code> is an immutable ordered collection of * <code>Object</code>. * * @author Ankit Pasricha, IBM */ public interface ObjectList { /** * The number of <code>Object</code>s in the list. The range of * valid child object indices is 0 to <code>length-1</code> inclusive. */ public int getLength(); /** * Checks if the <code>Object</code> <code>item</code> is a * member of this list. * @param item <code>Object</code> whose presence in this list * is to be tested. * @return True if this list contains the <code>Object</code> * <code>item</code>. */ public boolean contains(Object item); /** * Returns the <code>index</code>th item in the collection. The index * starts at 0. * @param index index into the collection. * @return The <code>Object</code> at the <code>index</code>th * position in the <code>ObjectList</code>. * @exception XSException * INDEX_SIZE_ERR: if <code>index</code> is greater than or equal to the * number of objects in the list. */ public Object item(int index) throws XSException; } 1.1 xml-xerces/java/src/org/apache/xerces/xs/datatypes/ByteList.java Index: ByteList.java =================================================================== /* * Copyright 2001, 2002,2004 The Apache Software Foundation. * * Licensed 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.xerces.xs.datatypes; import org.apache.xerces.xs.XSException; /** * EXPERIMENTAL: The <code>ByteList</code> is an immutable ordered collection of * <code>byte</code>. * * @author Ankit Pasricha, IBM */ public interface ByteList { /** * The number of <code>byte</code>s in the list. The range of * valid child object indices is 0 to <code>length-1</code> inclusive. */ public int getLength(); /** * Checks if the <code>byte</code> <code>item</code> is a * member of this list. * @param item <code>byte</code> whose presence in this list * is to be tested. * @return True if this list contains the <code>byte</code> * <code>item</code>. */ public boolean contains(byte item); /** * Returns the <code>index</code>th item in the collection. The index * starts at 0. * @param index index into the collection. * @return The <code>byte</code> at the <code>index</code>th * position in the <code>ByteList</code>. * @exception XSException * INDEX_SIZE_ERR: if <code>index</code> is greater than or equal to the * number of objects in the list. */ public byte item(int index) throws XSException; } 1.1 xml-xerces/java/src/org/apache/xerces/xs/datatypes/XSFloat.java Index: XSFloat.java =================================================================== /* * Copyright 2001, 2002,2004 The Apache Software Foundation. * * Licensed 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.xerces.xs.datatypes; /** * EXPERIMENTAL: Interface to expose value of the float datatype. * * @author Ankit Pasricha, IBM */ public interface XSFloat { /** * @return value */ public float getValue(); } 1.43 +4 -1 xml-xerces/java/src/org/apache/xerces/impl/Constants.java Index: Constants.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Constants.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- Constants.java 25 Apr 2004 02:08:53 -0000 1.42 +++ Constants.java 15 Sep 2004 05:12:24 -0000 1.43 @@ -379,6 +379,9 @@ // XML version constants public final static short XML_VERSION_1_0 = 1; public final static short XML_VERSION_1_1 = 2; + + // Constant to enable Schema 1.1 support + public final static boolean SCHEMA_1_1_SUPPORT = false; // private 1.5 +18 -2 xml-xerces/java/src/org/apache/xerces/xs/XSConstants.java Index: XSConstants.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/xs/XSConstants.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- XSConstants.java 24 Feb 2004 23:15:55 -0000 1.4 +++ XSConstants.java 15 Sep 2004 05:12:24 -0000 1.5 @@ -316,10 +316,26 @@ /** * The type represents a list type definition. */ - public static final short LIST_DT = 44; + public static final short LIST_DT = 44; + /** + * yearMonthDuration + * + * The type represents a type derived from duration to + * represent a restricted duration containing only year + * and month from the duration value space. + */ + public static final short YEARMONTHDURATION_DT = 45; + /** + * dayTimeDuration + * + * The type represents a type derived from duration to + * represent a restricted duration containing the day and + * time portion of the duration value space. + */ + public static final short DAYTIMEDURATION_DT = 46; /** * The built-in type category is not available. */ - public static final short UNAVAILABLE_DT = 45; + public static final short UNAVAILABLE_DT = 47; } 1.1 xml-xerces/java/src/org/apache/xerces/impl/dv/util/ByteListImpl.java Index: ByteListImpl.java =================================================================== /* * Copyright 2001, 2002,2004 The Apache Software Foundation. * * Licensed 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.xerces.impl.dv.util; import org.apache.xerces.xs.datatypes.ByteList; import org.apache.xerces.xs.XSException; /** * Implementation of <code>org.apache.xerces.xs.datatypes.ByteList</code>. * * @author Ankit Pasricha, IBM */ public class ByteListImpl implements ByteList { // actually data stored in a byte array protected final byte[] data; // canonical representation of the data protected String canonical; public ByteListImpl(byte[] data) { this.data = data; } /** * The number of <code>byte</code>s in the list. The range of * valid child object indices is 0 to <code>length-1</code> inclusive. */ public int getLength() { return data.length; } /** * Checks if the <code>byte</code> <code>item</code> is a * member of this list. * @param item <code>byte</code> whose presence in this list * is to be tested. * @return True if this list contains the <code>byte</code> * <code>item</code>. */ public boolean contains(byte item) { for(int i = 0;i < data.length; i++) if(data[i] == item) return true; return false; } /** * Returns the <code>index</code>th item in the collection. The index * starts at 0. * @param index index into the collection. * @return The <code>byte</code> at the <code>index</code>th * position in the <code>ByteList</code>. * @exception XSException * INDEX_SIZE_ERR: if <code>index</code> is greater than or equal to the * number of objects in the list. */ public byte item(int index) throws XSException { if(index < 0 || index > data.length - 1) { throw new XSException(XSException.INDEX_SIZE_ERR, null); } return data[index]; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]