public function buildSchemas(): Schemas
    {
        $schemas = new Schemas();
        $xpath = new DOMXPath($this->document);

        // get the http://www.w3.org/2001/XMLSchema-instance namespace (it could not be 'xsi')
        $xsi = $this->document->lookupPrefix('http://www.w3.org/2001/XMLSchema-instance');

        // the namespace is not registered, no need to continue
        if (! $xsi) {
            return $schemas;
        }

        // get all the xsi:schemaLocation attributes in the document
        /** @var \DOMNodeList|false $schemasList */
        $schemasList = $xpath->query("//@$xsi:schemaLocation");

        // schemaLocation attribute not found, no need to continue
        if (false === $schemasList || 0 === $schemasList->length) {
            return $schemas;
        }

        // process every schemaLocation for even parts
        foreach ($schemasList as $node) {
            // get the node content
            $content = $node->nodeValue;
            // get parts without inner spaces
            $parts = array_values(array_filter(explode(' ', $content)));
            $partsCount = count($parts);
            // check that the list count is an even number
            if (0 !== $partsCount % 2) {
                throw new SchemaValidatorException(
                    "The schemaLocation value '" . $content . "' must have even number of URIs"
                );
            }
            // insert the uris pairs into the schemas
            for ($k = 0; $k < $partsCount; $k = $k + 2) {
                $schemas->create($parts[$k], $parts[$k + 1]);
            }
        }

        return $schemas;
    }
public function buildSchemas(): Schemas
    {
        $schemas = new Schemas();
        $xpath = new DOMXPath($this->document);

        // get the http://www.w3.org/2001/XMLSchema-instance namespace (it could not be 'xsi')
        $xsi = $this->document->lookupPrefix('http://www.w3.org/2001/XMLSchema-instance');

        // the namespace is not registered, no need to continue
        if (! $xsi) {
            return $schemas;
        }

        // get all the xsi:schemaLocation attributes in the document
        /** @var \DOMNodeList|false $schemasList */
        $schemasList = $xpath->query("//@$xsi:schemaLocation");

        // schemaLocation attribute not found, no need to continue
        if (false === $schemasList || 0 === $schemasList->length) {
            return $schemas;
        }

        // process every schemaLocation for even parts
        foreach ($schemasList as $node) {
            // get the node content
            $content = $node->nodeValue;
            // get parts without inner spaces
            $parts = array_values(array_filter(explode(' ', $content)));
            $partsCount = count($parts);
            // check that the list count is an even number
            if (0 !== $partsCount % 2) {
                throw new SchemaValidatorException(
                    "The schemaLocation value '" . $content . "' must have even number of URIs"
                );
            }
            // insert the uris pairs into the schemas
            for ($k = 0; $k < $partsCount; $k = $k + 2) {
                $schemas->create($parts[$k], $parts[$k + 1]);
            }
        }

        return $schemas;
    }
public function buildSchemas ( ) : Schemas { $ schemas = new Schemas ( ) ; $ xpath = new DOMXPath ( $ this -> document ) ; // get the http://www.w3.org/2001/XMLSchema-instance namespace (it could not be 'xsi') $ xsi = $ this -> document -> lookupPrefix ( 'http://www.w3.org/2001/XMLSchema-instance' ) ; // the namespace is not registered, no need to continue if ( ! $ xsi ) { return $ schemas ; } // get all the xsi:schemaLocation attributes in the document /** @var \DOMNodeList|false $schemasList */ $ schemasList = $ xpath -> query ( "//@$xsi:schemaLocation" ) ; // schemaLocation attribute not found, no need to continue if ( false === $ schemasList || 0 === $ schemasList -> length ) { return $ schemas ; } // process every schemaLocation for even parts foreach ( $ schemasList as $ node ) { // get the node content $ content = $ node -> nodeValue ; // get parts without inner spaces $ parts = array_values ( array_filter ( explode ( ' ' , $ content ) ) ) ; $ partsCount = count ( $ parts ) ; // check that the list count is an even number if ( 0 !== $ partsCount % 2 ) { throw new SchemaValidatorException ( "The schemaLocation value '" . $ content . "' must have even number of URIs" ) ; } // insert the uris pairs into the schemas for ( $ k = 0 ; $ k < $ partsCount ; $ k = $ k + 2 ) { $ schemas -> create ( $ parts [ $ k ] , $ parts [ $ k + 1 ] ) ; } } return $ schemas ; }
Retrieve a list of namespaces based on the schemaLocation attributes

@throws SchemaValidatorException if the content of schemaLocation is not an even number of uris
@return Schemas|Schema[]
Retrieve a list of namespaces based on the schemaLocation attributes