Skip to content

Commit

Permalink
find default ns
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Mar 17, 2018
1 parent 7a5a40c commit 124b424
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/SchemaReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,10 @@ private static function splitParts(DOMElement $node, string $typeName): array
list($prefix, $name) = explode(':', $typeName);
}

$namespace = $node->lookupNamespaceUri($prefix ?: '');
/**
* @psalm-suppress PossiblyNullArgument
*/
$namespace = $node->lookupNamespaceUri($prefix);

return array(
$name,
Expand Down
25 changes: 25 additions & 0 deletions tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,34 @@

use GoetasWebservices\XML\XSDReader\Schema\Element\ElementDef;
use GoetasWebservices\XML\XSDReader\Schema\Type\ComplexType;
use GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType;

class SchemaTest extends BaseTest
{
public function testWithXSDAsDefaultNamespace()
{
$xml = '
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ds="http://www.example.com"
targetNamespace="http://www.example.com"
elementFormDefault="qualified">
<simpleType name="CryptoBinary">
<restriction base="base64Binary"/>
</simpleType>
<simpleType name="LocalCryptoBinary">
<restriction base="ds:CryptoBinary"/>
</simpleType>
</schema>';
$schema = $this->reader->readString($xml);

$crypto = $schema->findType('CryptoBinary', 'http://www.example.com');
$this->assertInstanceOf(SimpleType::class, $crypto);

$localCrypto = $schema->findType('LocalCryptoBinary', 'http://www.example.com');
$this->assertInstanceOf(SimpleType::class, $localCrypto);
}

/**
* @expectedException \GoetasWebservices\XML\XSDReader\Exception\IOException
* @expectedExceptionMessage Can't load the schema
Expand Down

0 comments on commit 124b424

Please sign in to comment.