|
9 | 9 |
|
10 | 10 | import java.math.BigDecimal; |
11 | 11 | import java.math.BigInteger; |
| 12 | +import java.net.URISyntaxException; |
12 | 13 | import java.util.StringTokenizer; |
13 | 14 |
|
14 | 15 | import javax.xml.datatype.DatatypeConfigurationException; |
|
18 | 19 | import javax.xml.datatype.XMLGregorianCalendar; |
19 | 20 | import javax.xml.namespace.QName; |
20 | 21 |
|
| 22 | +import org.eclipse.rdf4j.common.net.ParsedIRI; |
21 | 23 | import org.eclipse.rdf4j.common.text.ASCIIUtil; |
22 | 24 | import org.eclipse.rdf4j.model.IRI; |
23 | 25 | import org.eclipse.rdf4j.model.vocabulary.XMLSchema; |
@@ -269,6 +271,9 @@ else if (datatype.equals(XMLSchema.YEARMONTHDURATION)) { |
269 | 271 | else if (datatype.equals(XMLSchema.QNAME)) { |
270 | 272 | result = isValidQName(value); |
271 | 273 | } |
| 274 | + else if (datatype.equals(XMLSchema.ANYURI)) { |
| 275 | + result = isValidAnyURI(value); |
| 276 | + } |
272 | 277 |
|
273 | 278 | return result; |
274 | 279 | } |
@@ -652,6 +657,25 @@ public static boolean isValidQName(String value) { |
652 | 657 | return true; |
653 | 658 | } |
654 | 659 |
|
| 660 | + /** |
| 661 | + * Determines if the supplied value is an Internationalized Resource Identifier Reference (IRI). An anyURI |
| 662 | + * value can be absolute or relative, and may have an optional fragment identifier (i.e., it may be an IRI |
| 663 | + * Reference). This type should be used when the value fulfills the role of an IRI, as defined in |
| 664 | + * [RFC 3987] or its successor(s) in the IETF Standards Track. |
| 665 | + * |
| 666 | + * @param value |
| 667 | + * @return <tt>true</tt> if a valid IRI, <tt>false</tt> otherwise |
| 668 | + */ |
| 669 | + public static boolean isValidAnyURI(String value) { |
| 670 | + try { |
| 671 | + new ParsedIRI(value.trim()); |
| 672 | + return true; |
| 673 | + } |
| 674 | + catch (URISyntaxException e) { |
| 675 | + return false; |
| 676 | + } |
| 677 | + } |
| 678 | + |
655 | 679 | private static boolean isPrefixStartChar(int c) { |
656 | 680 | return ASCIIUtil.isLetter(c) || c >= 0x00C0 && c <= 0x00D6 || c >= 0x00D8 && c <= 0x00F6 |
657 | 681 | || c >= 0x00F8 && c <= 0x02FF || c >= 0x0370 && c <= 0x037D || c >= 0x037F && c <= 0x1FFF |
@@ -758,6 +782,9 @@ else if (datatype.equals(XMLSchema.BOOLEAN)) { |
758 | 782 | else if (datatype.equals(XMLSchema.DATETIME)) { |
759 | 783 | result = normalizeDateTime(value); |
760 | 784 | } |
| 785 | + else if (datatype.equals(XMLSchema.ANYURI)) { |
| 786 | + result = collapseWhiteSpace(value); |
| 787 | + } |
761 | 788 |
|
762 | 789 | return result; |
763 | 790 | } |
|
0 commit comments