1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\xsdTypes; |
4
|
|
|
|
5
|
|
|
//TODO: we really need a better check if valid url here |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* The type xsd:anyURI represents a Uniform Resource Identifier (URI) reference. URIs are used to identify resources, |
9
|
|
|
* and they may be absolute or relative. Absolute URIs provide the entire context for locating the resources, such |
10
|
|
|
* as http://datypic.com/prod.html. Relative URIs are specified as the difference from a base URI, such as |
11
|
|
|
* ../prod.html. It is also possible to specify a fragment identifier, using the # character, such as |
12
|
|
|
* ../prod.html#shirt. |
13
|
|
|
* |
14
|
|
|
* The three previous examples happen to be HTTP URLs (Uniform Resource Locators), but URIs also encompass URLs of |
15
|
|
|
* other schemes (e.g., FTP, gopher, telnet), as well as URNs (Uniform Resource Names). URIs are not required to be |
16
|
|
|
* dereferencable; that is, it is not necessary for there to be a web page at http://datypic.com/prod.html in |
17
|
|
|
* order for this to be a valid URI. |
18
|
|
|
* |
19
|
|
|
* URIs require that some characters be escaped with their hexadecimal Unicode code point preceded by the % character. |
20
|
|
|
* This includes non-ASCII characters and some ASCII characters, namely control characters, spaces, and the following |
21
|
|
|
* characters (unless they are used as deliimiters in the URI): <>#%{}|\^`. For example, ../édition.html must be |
22
|
|
|
* represented instead as ../%C3%A9dition.html, with the é escaped as %C3%A9. However, the anyURI type will accept |
23
|
|
|
* these characters either escaped or unescaped. With the exception of the characters % and #, it will assume that |
24
|
|
|
* unescaped characters are intended to be escaped when used in an actual URI, although the schema processor will do |
25
|
|
|
* nothing to alter them. It is valid for an anyURI value to contain a space, but this practice is strongly discouraged. |
26
|
|
|
* Spaces should instead be escaped using %20. |
27
|
|
|
* |
28
|
|
|
* The schema processor is not required to parse the contents of an xsd:anyURI value to determine whether it is valid |
29
|
|
|
* according to any particular URI scheme. Since the bare minimum rules for valid URI references are fairly generic, |
30
|
|
|
* the schema processor will accept most character strings, including an empty value. The only values that are not |
31
|
|
|
* accepted are ones that make inappropriate use of reserved characters, such as ones that contain multiple # |
32
|
|
|
* characters or have % characters that are not followed by two hexadecimal digits. |
33
|
|
|
* |
34
|
|
|
* Note that when relative URI references such as "../prod" are used as values of xsd:anyURI, no attempt is made to |
35
|
|
|
* determine or keep track of the base URI to which they may be applied. For more information on URIs, see RFC 2396, |
36
|
|
|
* Uniform Resource Identifiers (URI): Generic Syntax. |
37
|
|
|
* @package AlgoWeb\xsdTypes |
38
|
|
|
*/ |
39
|
|
|
class xsAnyURI extends xsAnySimpleType |
40
|
|
|
{ |
41
|
|
|
use LengthTrait; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Construct |
45
|
|
|
* |
46
|
|
|
* @param string $value |
47
|
|
|
*/ |
48
|
|
|
public function __construct($value) |
49
|
|
|
{ |
50
|
|
|
parent::__construct($value); |
51
|
|
|
$this->setWhiteSpaceFacet("collapse"); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
protected function isOK() |
55
|
|
|
{ |
56
|
|
|
$this->checkMaxLength($this->__value); |
57
|
|
|
$this->checkMinLength($this->__value); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|