Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
21fccd9
tmp
tvdijen Jun 3, 2025
85f9262
Add xsd:minLength
tvdijen Jun 11, 2025
75a4337
xsd:minInclusive typo
tvdijen Jun 11, 2025
bca3f9b
feature-branch was merged
tvdijen Jun 12, 2025
f76dcf1
Rebase
tvdijen Jun 12, 2025
54c6b18
Refactor MaxOccurs
tvdijen Jun 12, 2025
01424d5
Integer > NonNegativeInteger for NumFacet
tvdijen Jun 12, 2025
03f2def
Add xsd:length
tvdijen Jun 12, 2025
374798a
Add xsd:maxLength
tvdijen Jun 12, 2025
300ad15
Add xsd:fractionDigits
tvdijen Jun 12, 2025
0ced688
Add xs:totalDigits element
tvdijen Jun 13, 2025
f37e203
Add FormChoiceValue type
tvdijen Jun 14, 2025
ac87aa1
Add UseValue type and UseEnum
tvdijen Jun 14, 2025
da3841a
Add xs:public type
tvdijen Jun 14, 2025
4bbe773
Add xs:notation element
tvdijen Jun 14, 2025
8bf4478
Enable new elements in element registry
tvdijen Jun 14, 2025
6cdf4aa
Add xs:selector element
tvdijen Jun 14, 2025
6f2543d
Add xs:field element
tvdijen Jun 14, 2025
6b8a3ea
Add xs:import element
tvdijen Jun 14, 2025
1c3066e
Add xs:include element
tvdijen Jun 14, 2025
87ff1ea
Enable new elements in element registry
tvdijen Jun 14, 2025
eaf8e8a
Add xs:derivationControl type
tvdijen Jun 14, 2025
486e4b1
Add xs:simpleDerivationSet type
tvdijen Jun 14, 2025
e3c1eda
Fix NamespaceListValue
tvdijen Jun 14, 2025
2c75836
Add xs:simpleDerivarion trait
tvdijen Jun 15, 2025
37fd67e
Raise coverage
tvdijen Jun 15, 2025
435575e
Add xs:simpleType element
tvdijen Jun 15, 2025
692483e
Implement FacetInterface
tvdijen Jun 15, 2025
fb741aa
Implement FacetsTrait representing xs:facets
tvdijen Jun 15, 2025
c3c96d0
Implement SimpleRestrictionModelTrait representing xs:simpleRestricti…
tvdijen Jun 15, 2025
a2743ea
Add xs:restriction element
tvdijen Jun 15, 2025
1cd7a2a
Remove incorrect AbstractWildcard from coverage
tvdijen Jun 15, 2025
ece1b1b
Add xs:list element
tvdijen Jun 15, 2025
cd41dca
Add xs:union element
tvdijen Jun 16, 2025
947f0be
Add xs:anyType and fix inheritance structure
tvdijen Jun 16, 2025
7b0e4d7
Add xs:blockSet type
tvdijen Jun 16, 2025
2f8cf24
Fix union-element and add AbstractAttributeGroup
tvdijen Jun 16, 2025
2bc5f25
Add xs:key element
tvdijen Jun 17, 2025
ced0980
Add xs:unique element
tvdijen Jun 17, 2025
c80b78b
Add xs:keyref element
tvdijen Jun 17, 2025
6dd435a
Implement xs:identityConstraint interface
tvdijen Jun 18, 2025
448a6c7
Add xs:typeDerivationControl-type
tvdijen Jun 18, 2025
3961baf
Refactor SimpleDerivationSetValue
tvdijen Jun 18, 2025
b537884
Add xs:fullDerivationSet-type
tvdijen Jun 18, 2025
840c4a6
Add xs:reducedDerivationControl-type
tvdijen Jun 18, 2025
6a61204
Add xs:derivationSet-type
tvdijen Jun 18, 2025
4d96f5a
Refactor AbstractLocalSimpleType
tvdijen Jun 18, 2025
bbb4438
Add xs:attribute element
tvdijen Jun 20, 2025
df82d6c
Add xs:attributeGroup element
tvdijen Jun 21, 2025
a53c321
Add interface for elements that are part of the xs:simpleDerivation g…
tvdijen Jun 21, 2025
64e017d
Add interface for elements that are part of the xs:redefinable group
tvdijen Jun 21, 2025
e2900ff
Add interface for elements that are part of the xs:schemaTop group
tvdijen Jun 21, 2025
a442679
Add interface for elements that are part of the xs:particle group
tvdijen Jun 21, 2025
90b3052
Add interface for elements that are part of the xs:nestedParticle group
tvdijen Jun 21, 2025
bc09c68
Add classes and implementation of a referenced xs:group
tvdijen Jun 21, 2025
6005d98
Implement xs:group for named groups
tvdijen Jun 21, 2025
3f98b07
Fix several phpstan-issues in the unit tests
tvdijen Jun 21, 2025
e3b4c59
Add xs:choice element
tvdijen Jun 21, 2025
c2d32f4
add xs:sequence element
tvdijen Jun 21, 2025
d9e4896
Add xs:all element
tvdijen Jun 21, 2025
8832c21
Add interface for elements that are part of the xs:typeDefParticle group
tvdijen Jun 21, 2025
9b90523
Refactor RestrictionType
tvdijen Jun 22, 2025
14cb236
Implement xs:complexRestrictionType
tvdijen Jun 22, 2025
3406a69
Implement xs:extensionType
tvdijen Jun 22, 2025
f0b6837
Implement xs:simpleExtensionType
tvdijen Jun 22, 2025
91e50a3
Implement xs:simpleRestrictionType
tvdijen Jun 22, 2025
4635d87
Add xs:simpleContent element
tvdijen Jun 22, 2025
35dddc3
Add xs:complexRestrictionType implementation
tvdijen Jun 22, 2025
d1a61a4
Add xs:extensionType implementation
tvdijen Jun 23, 2025
890aa42
Add xs:complexContent element
tvdijen Jun 23, 2025
a913ed8
Refactor into traits
tvdijen Jun 23, 2025
c491bc0
Add xs:complexType element
tvdijen Jun 23, 2025
3fef5de
Add xs:complexType element
tvdijen Jun 23, 2025
0a4064c
Add xs:element element
tvdijen Jun 24, 2025
c0e90cf
Add narrowMaxMin element
tvdijen Jun 24, 2025
e523aa0
Fix use of NarrowMaxMinElement
tvdijen Jun 25, 2025
c61a449
WIP: Add xs:schema element
tvdijen Jun 26, 2025
b9104c8
Add RedefinableInterface
tvdijen Jun 26, 2025
0d5d3cc
Add RedefinableTrait
tvdijen Jun 26, 2025
a87d069
Add redefine element
tvdijen Jun 26, 2025
bc3838c
Finalize schema-element
tvdijen Jun 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"ext-spl": "*",

"simplesamlphp/assert": "~1.8.1",
"simplesamlphp/xml-common": "dev-feature/xsd-types"
"simplesamlphp/xml-common": "dev-master"
},
"require-dev": {
"simplesamlphp/simplesamlphp-test-framework": "~1.9.2"
Expand Down
14 changes: 14 additions & 0 deletions src/Exception/ProtocolViolationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XSD\Exception;

/**
* This exception may be raised when a violation of the XML Schema specification is detected
*
* @package simplesamlphp/xml-xsd
*/
class ProtocolViolationException extends RuntimeException
{
}
14 changes: 14 additions & 0 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XSD\Exception;

use RuntimeException as BuiltinRuntimeException;

/**
* Named exception
*/
class RuntimeException extends BuiltinRuntimeException
{
}
30 changes: 30 additions & 0 deletions src/Type/AbstractAllNNIValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XSD\Type;

use SimpleSAML\XML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Type\NonNegativeIntegerValue;

/**
* @package simplesaml/xml-xsd
*/
abstract class AbstractAllNNIValue extends NonNegativeIntegerValue
{
/**
* Validate the value.
*
* @param string $value The value
* @throws \Exception on failure
* @return void
*/
protected function validateValue(string $value): void
{
$sanitized = $this->sanitizeValue($value);
if ($sanitized !== 'unbounded') {
Assert::validNonNegativeInteger($sanitized, SchemaViolationException::class);
}
}
}
52 changes: 52 additions & 0 deletions src/Type/BlockSetValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XSD\Type;

use SimpleSAML\XML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Type\NMTokenValue;
// use SimpleSAML\XSD\XML\xsd\NameSpaceEnum;
use SimpleSAML\XSD\XML\xsd\DerivationControlEnum;

use function explode;

/**
* @package simplesaml/xml-xsd
*/
class BlockSetValue extends NMTokenValue
{
/** @var string */
public const SCHEMA_TYPE = 'blockSet';


/**
* Validate the value.
*
* @param string $value The value
* @throws \Exception on failure
* @return void
*/
protected function validateValue(string $value): void
{
$sanitized = $this->sanitizeValue($value);

if ($sanitized !== '#all' && $sanitized !== '') {
// if ($sanitized !== NamespaceEnum::Any && $sanitized !== '') {
$list = explode(' ', $sanitized, C::UNBOUNDED_LIMIT);

// After filtering the allowed values, there should be nothing left
$filtered = array_diff(
$list,
[
DerivationControlEnum::Extension->value,
DerivationControlEnum::Restriction->value,
DerivationControlEnum::Substitution->value,
],
);
Assert::isEmpty($filtered, SchemaViolationException::class);
}
}
}
53 changes: 53 additions & 0 deletions src/Type/DerivationControlValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XSD\Type;

use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Type\NMTokenValue;
use SimpleSAML\XSD\XML\xsd\DerivationControlEnum;

use function array_column;

/**
* @package simplesaml/xml-xsd
*/
class DerivationControlValue extends NMTokenValue
{
/**
* Validate the value.
*
* @param string $value The value
* @throws \Exception on failure
* @return void
*/
protected function validateValue(string $value): void
{
Assert::oneOf(
$this->sanitizeValue($value),
array_column(DerivationControlEnum::cases(), 'value'),
SchemaViolationException::class,
);
}


/**
* @param \SimpleSAML\XSD\XML\xsd\DerivationControlEnum $value
* @return static
*/
public static function fromEnum(DerivationControlEnum $value): static
{
return new static($value->value);
}


/**
* @return \SimpleSAML\XSD\XML\xsd\DerivationControlEnum $value
*/
public function toEnum(): DerivationControlEnum
{
return DerivationControlEnum::from($this->getValue());
}
}
48 changes: 48 additions & 0 deletions src/Type/DerivationSetValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XSD\Type;

use SimpleSAML\XML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XSD\XML\xsd\DerivationControlEnum;

use function array_column;
use function explode;

/**
* @package simplesaml/xml-xsd
*/
class DerivationSetValue extends DerivationControlValue
{
/** @var string */
public const SCHEMA_TYPE = 'derivationSet';


/**
* Validate the value.
*
* @param string $value The value
* @throws \Exception on failure
* @return void
*/
protected function validateValue(string $value): void
{
$sanitized = $this->sanitizeValue($value);

if ($sanitized !== '#all' && $sanitized !== '') {
Assert::allOneOf(
explode(' ', $sanitized),
array_column(
[
DerivationControlEnum::Extension,
DerivationControlEnum::Restriction,
],
'value',
),
SchemaViolationException::class,
);
}
}
}
53 changes: 53 additions & 0 deletions src/Type/FormChoiceValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XSD\Type;

use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Type\NMTokenValue;
use SimpleSAML\XSD\XML\xsd\FormChoiceEnum;

use function array_column;

/**
* @package simplesaml/xml-xsd
*/
class FormChoiceValue extends NMTokenValue
{
/**
* Validate the value.
*
* @param string $value The value
* @throws \Exception on failure
* @return void
*/
protected function validateValue(string $value): void
{
Assert::oneOf(
$this->sanitizeValue($value),
array_column(FormChoiceEnum::cases(), 'value'),
SchemaViolationException::class,
);
}


/**
* @param \SimpleSAML\XSD\XML\xsd\FormChoiceEnum $value
* @return static
*/
public static function fromEnum(FormChoiceEnum $value): static
{
return new static($value->value);
}


/**
* @return \SimpleSAML\XSD\XML\xsd\FormChoiceEnum $value
*/
public function toEnum(): FormChoiceEnum
{
return FormChoiceEnum::from($this->getValue());
}
}
50 changes: 50 additions & 0 deletions src/Type/FullDerivationSetValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XSD\Type;

use SimpleSAML\XML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XSD\XML\xsd\DerivationControlEnum;

use function array_column;
use function explode;

/**
* @package simplesaml/xml-xsd
*/
class FullDerivationSetValue extends DerivationControlValue
{
/** @var string */
public const SCHEMA_TYPE = 'fullDerivationSet';


/**
* Validate the value.
*
* @param string $value The value
* @throws \Exception on failure
* @return void
*/
protected function validateValue(string $value): void
{
$sanitized = $this->sanitizeValue($value);

if ($sanitized !== '#all' && $sanitized !== '') {
Assert::allOneOf(
explode(' ', $sanitized),
array_column(
[
DerivationControlEnum::Extension,
DerivationControlEnum::List,
DerivationControlEnum::Restriction,
DerivationControlEnum::Union,
],
'value',
),
SchemaViolationException::class,
);
}
}
}
22 changes: 1 addition & 21 deletions src/Type/MaxOccursValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,11 @@

namespace SimpleSAML\XSD\Type;

use SimpleSAML\XML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Type\NonNegativeIntegerValue;

/**
* @package simplesaml/xml-xsd
*/
class MaxOccursValue extends NonNegativeIntegerValue
class MaxOccursValue extends AbstractAllNNIValue
{
/** @var string */
public const SCHEMA_TYPE = 'maxOccurs';


/**
* Validate the value.
*
* @param string $value The value
* @throws \Exception on failure
* @return void
*/
protected function validateValue(string $value): void
{
$sanitized = $this->sanitizeValue($value);
if ($sanitized !== 'unbounded') {
Assert::validNonNegativeInteger($sanitized, SchemaViolationException::class);
}
}
}
Loading