1
|
|
|
<?php |
2
|
|
|
namespace AlgoWeb\xsdTypes; |
3
|
|
|
|
4
|
|
|
use AlgoWeb\xsdTypes\Facets\LengthTrait; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* The type xsd:string represents a character string that may contain any Unicode character allowed by XML. Certain |
8
|
|
|
* characters, namely the "less than" symbol (<) and the ampersand (&), must be escaped (using the entities |
9
|
|
|
* < and &, respectively) when used in strings in XML instances. |
10
|
|
|
* |
11
|
|
|
* The xsd:string type has a whiteSpace facet of preserve, which means that all whitespace characters |
12
|
|
|
* (spaces, tabs, carriage returns, and line feeds) are preserved by the processor. |
13
|
|
|
* This is in contrast to two types derived from it: normalizedString, and token. |
14
|
|
|
* |
15
|
|
|
* Valid values Comment |
16
|
|
|
* "This is a string!" |
17
|
|
|
* "Édition française." |
18
|
|
|
* "12.5 |
19
|
|
|
* :an empty string is valid |
20
|
|
|
* "PB&J" :when parsed, it will become "PB&J" |
21
|
|
|
* "This |
22
|
|
|
* is on two lines." |
23
|
|
|
* Invalid values Comment |
24
|
|
|
* "AT&T" ampersand must be escaped |
25
|
|
|
* "3 < 4" the "less than" symbol must be escaped |
26
|
|
|
* But most of that should be handled by JSM |
27
|
|
|
* |
28
|
|
|
* @package AlgoWeb\xsdTypes |
29
|
|
|
*/ |
30
|
|
View Code Duplication |
class xsString extends xsAnySimpleType |
31
|
|
|
{ |
32
|
|
|
use LengthTrait; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Construct. |
36
|
|
|
* |
37
|
|
|
* @param string $value |
38
|
|
|
*/ |
39
|
|
|
public function __construct($value) |
40
|
|
|
{ |
41
|
|
|
parent::__construct($value); |
42
|
|
|
$this->setWhiteSpaceFacet('preserve'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
protected function fixValue() |
46
|
|
|
{ |
47
|
|
|
parent::fixValue(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
protected function isOK() |
51
|
|
|
{ |
52
|
|
|
$this->checkLength($this->value); |
53
|
|
|
if (is_array($this->value) || is_object($this->value)) { |
54
|
|
|
throw new \InvalidArgumentException( |
55
|
|
|
'The provided value for ' . __CLASS__ . ' must not be an array or an object.' |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|