You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2009/07/08 03:03:45 UTC
svn commit: r792009 - in /xmlbeans/trunk: build.xml
src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java
src/xmlpublic/org/apache/xmlbeans/GDate.java
Author: cezar
Date: Wed Jul 8 01:03:45 2009
New Revision: 792009
URL: http://svn.apache.org/viewvc?rev=792009&view=rev
Log:
- Updated dist-src jar file name to sources instead of source.
- Uncomment year check in GDate parsing.
- Added lexical validation of URI in XsTypeConverter, to be used externaly if necesary.
Modified:
xmlbeans/trunk/build.xml
xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java
xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDate.java
Modified: xmlbeans/trunk/build.xml
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/build.xml?rev=792009&r1=792008&r2=792009&view=diff
==============================================================================
--- xmlbeans/trunk/build.xml (original)
+++ xmlbeans/trunk/build.xml Wed Jul 8 01:03:45 2009
@@ -425,7 +425,7 @@
<exclude name="bin/*.cmd"/>
</tarfileset>
</tar>
- <jar jarfile="build/private/xmlbeans-${version.base}-source.jar" index="false">
+ <jar jarfile="build/private/xmlbeans-${version.base}-sources.jar" index="false">
<fileset dir="src/common" includes="**/*.java"/>
<fileset dir="src/configschema" includes="**/*.java"/>
<fileset dir="src/jamsupport" includes="**/*.java"/>
Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java?rev=792009&r1=792008&r2=792009&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java Wed Jul 8 01:03:45 2009
@@ -30,6 +30,7 @@
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
+import java.net.URI;
public final class XsTypeConverter
{
@@ -729,4 +730,111 @@
return sign * result;
}
-}
+ // ======================== anyURI ========================
+ public static CharSequence printAnyURI(CharSequence val)
+ {
+ return val;
+ }
+
+ /**
+ * Checkes the regular expression of URI, defined by RFC2369 http://www.ietf.org/rfc/rfc2396.txt Appendix B.
+ * Note: The whitespace normalization rule collapse must be applied priot to calling this method.
+ * @param lexical_value the lexical value
+ * @return same input value if input value is in the lexical space
+ * @throws InvalidLexicalValueException
+ */
+ public static CharSequence lexAnyURI(CharSequence lexical_value)
+ {
+ /* // Reg exp from RFC2396, but it's too forgiving for XQTS
+ Pattern p = Pattern.compile("^([^:/?#]+:)?(//[^/?#]*)?([^?#]*)(\\?[^#]*)?(#.*)?");
+ Matcher m = p.matcher(lexical_value);
+ if ( !m.matches() )
+ throw new InvalidLexicalValueException("invalid anyURI value");
+ else
+ {
+ for ( int i = 0; i<= m.groupCount(); i++ )
+ {
+ System.out.print(" " + i + ": " + m.group(i));
+ }
+ System.out.println("");
+ return lexical_value;
+ } */
+
+ // Per XMLSchema spec allow spaces inside URIs
+ String s = lexical_value.toString().replace(" ", "%20");
+
+ try
+ {
+ URI.create(s);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new InvalidLexicalValueException("invalid anyURI value: " + lexical_value, e);
+ }
+
+ return lexical_value;
+ }
+
+// public static void main(String[] args)
+// {
+// lexAnyURI("http://www.ics.uci.edu/pub/ietf/uri/#Related");
+// lexAnyURI("http://www.ics.uci.edu/pub/ietf/uri/?query=abc#Related");
+// lexAnyURI("http://a/b/c/d;p?q");
+// lexAnyURI("g:h");
+// lexAnyURI("./g");
+// lexAnyURI("g/");
+// lexAnyURI("/g");
+// lexAnyURI("//g");
+// lexAnyURI("?y");
+// lexAnyURI("g?y");
+// lexAnyURI("#s");
+// lexAnyURI("g#s");
+// lexAnyURI("g?y#s");
+// lexAnyURI(";x");
+// lexAnyURI("g;x");
+// lexAnyURI("g;x?y#s");
+// lexAnyURI(".");
+// lexAnyURI("./");
+// lexAnyURI("..");
+// lexAnyURI("../");
+// lexAnyURI("../g");
+// lexAnyURI("../..");
+// lexAnyURI("../../");
+// lexAnyURI("../../g");
+//
+// lexAnyURI("http:// www .ics.uci.edu /pub/ietf/uri /#Related");
+// lexAnyURI("http:// www .ics.uci.edu /pub/iet%20%20f/uri /#Related");
+//
+//
+// // From XQTS cvshead June 2009
+// String[] invalidURIs = {"http:\\\\invalid>URI\\someURI", // K2-SeqExprCast-207: Construct an xs:anyURI from an invalid string. However, in F&O 17.1.1, it is said that "For xs:anyURI, the extent to which an implementation validates the lexical form of xs:anyURI is implementation dependent.".
+// "http://www.example.com/file%GF.html", // K2-SeqExprCast-210: '%' is not a disallowed character and therefore it's not encoded before being considered for RFC 2396 validness.
+// "foo://", // K2-SeqExprCast-421: Pass an invalid anyURI.
+// "foo:", // K2-SeqExprCast-421-2: Pass an invalid anyURI.
+// "%gg", // K2-SeqExprCast-422: Pass an invalid anyURI(#2).
+// ":/cut.jpg", // K2-SeqExprCast-423: no scheme
+// ":/images/cut.png", // K2-SeqExprCast-424: An URI without scheme, combined with a relative directory.
+// ":/", // K2-SeqExprCast-505: ':/' is an invalid URI, no scheme.
+// "http:%%", // fn-resolve-uri-4: Evaluation of resolve-uri function with an invalid URI value for second argument.
+// ":", // fn-resolve-uri-3: Evaluation of resolve-uri function with an invalid URI value for first argument.
+// "###Rel",
+// "##",
+// "????###",
+// "###????"
+// };
+//
+// for ( int i = 0; i < invalidURIs.length ; i++ )
+// {
+// try
+// {
+// lexAnyURI(invalidURIs[i]);
+// throw new IllegalStateException("URI should be invalid: " + invalidURIs[i]);
+// }
+// catch (InvalidLexicalValueException e)
+// {
+// System.out.println("URI invalid: " + invalidURIs[i] + " " + e.getCause().getCause().getMessage());
+// assert true;
+// }
+// }
+// }
+}
\ No newline at end of file
Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDate.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDate.java?rev=792009&r1=792008&r2=792009&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDate.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDate.java Wed Jul 8 01:03:45 2009
@@ -159,12 +159,12 @@
else if (digits > 0)
throw new IllegalArgumentException("year must be four digits (may pad with zeroes, e.g., 0560)");
- /*if ( _CY > MAX_YEAR )
- throw new IllegalArgumentException("year must be less than " + MAX_YEAR);
+ if ( _CY > MAX_YEAR )
+ throw new IllegalArgumentException("year value not supported: too big, must be less than " + MAX_YEAR);
if ( _CY < MIN_YEAR )
- throw new IllegalArgumentException("year must be bigger than " + MIN_YEAR);
- */
+ throw new IllegalArgumentException("year values not supported: too small, must be bigger than " + MIN_YEAR);
+
// hyphen introduces a month
if (ch != '-')
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org