Implements a Url map that allows a simple xsd name to map to a path that can be found in the cache
@param string $schemaNamespace
@param string $schemaFile
@throws Exception
773732
protected function setUrlMap( $schemaNamespace = null, $schemaFile = null )
	{
		if ( $schemaNamespace && ! $schemaFile || $schemaFile && ! $schemaNamespace )
		{
			throw  new Exception('setUrlMap: If a schema file or schema namespace is provided to the setUrlMapo function then both MUST be provided.');
		}

		if ( ! $schemaFile )
		{
			$schemaFile = $this->schemaFile;
		}
		if ( ! $schemaNamespace )
		{
			$schemaNamespace = $this->schemaNamespace;
		}

		if ( ! $schemaNamespace ) return;

		global $mapUrl;  // This is a function assigned below.  Effectively a change of url maps is created.
		$previousMap = $mapUrl;
		// $schemaFile = $this->schemaFile;

		$mapUrl = function( $url ) use( &$previousMap, $schemaFile )
		{
			if ( $url == basename( $schemaFile ) )
			{
				$url = $schemaFile;
			}
			else if ( $previousMap )
			{
				$url = $previousMap( $url );
			}

			return $url;
		};

	}
879571
public function loadXML(string $XMLfile): void
    {
        $file = new FileManager();
        $this->xmlData = $file->loadLittleFile($XMLfile);
    }
124614
private function getUrlPattern(Router $router, $routeNameFromMappingFile, $baseUrl)
    {
        if (!empty($routeNameFromMappingFile)) {
            try {
                $route = $router->getRouteCollection()->get($routeNameFromMappingFile);
                if (empty($route)) {
                    throw new Exception();
                }
            } catch (Exception $e) {
                throw new RuntimeException(
                   \sprintf('Route \'%s\' has not been defined as a Symfony route.', $routeNameFromMappingFile)
               );
            }

            \preg_match_all('/{(.*?)}/', $route->getPath(), $matches);

            $pattern = [];
            if (!empty($matches)) {
                $pattern = \array_combine($matches[1], $matches[0]);
            }

            return $baseUrl.\urldecode($router->generate($routeNameFromMappingFile, $pattern, true));
        }

        return (string) $routeNameFromMappingFile;
    }
1277410
public function addPath($path, $namespace = null)
    {
        if (! is_dir($path)) {
            throw new Exception\InvalidPathException("Template path '$path' does not exist");
        }

        if (null !== $namespace && ! is_string($namespace)) {
            throw new Exception\InvalidNamespaceException('Namespace must be a string');
        }

        $namespace = $namespace ?: self::DEFAULT_NAMESPACE;
        $path = rtrim((string) $path, '/\\');
        $this->getPath($namespace)->push($path);

        return $this;
    }
1342192
public static void validateXml(Node doc, File schemaFile)
 throws AlipayApiException {
        validateXml(doc, getInputStream(schemaFile));
    }
1360370
public static void validateAgainstSchema(final String sbeSchemaFilename, final String xsdFilename)
        throws Exception
    {
        final ParserOptions.Builder optionsBuilder = ParserOptions.builder()
            .xsdFilename(System.getProperty(VALIDATION_XSD))
            .xIncludeAware(Boolean.parseBoolean(System.getProperty(XINCLUDE_AWARE)))
            .stopOnError(Boolean.parseBoolean(System.getProperty(VALIDATION_STOP_ON_ERROR)))
            .warningsFatal(Boolean.parseBoolean(System.getProperty(VALIDATION_WARNINGS_FATAL)))
            .suppressOutput(Boolean.parseBoolean(System.getProperty(VALIDATION_SUPPRESS_OUTPUT)));

        final Path path = Paths.get(sbeSchemaFilename);
        try (InputStream in = new BufferedInputStream(Files.newInputStream(path)))
        {
            final InputSource inputSource = new InputSource(in);
            if (path.toAbsolutePath().getParent() != null)
            {
                inputSource.setSystemId(path.toUri().toString());
            }

            XmlSchemaParser.validate(xsdFilename, inputSource, optionsBuilder.build());
        }
    }
305027
public static void infoOnGeneratedFile(Class<BindDataSource> annotation, File schemaCreateFile) {
		String msg = String.format("file '%s' in directory '%s' is generated by '@%s' annotation processor", schemaCreateFile.getName(), schemaCreateFile.getParentFile(), annotation.getSimpleName());
		
		printMessage(msg);		
	}
1184940
public void writeXsd(File outFile) {

    File folder = outFile.getParentFile();
    if (!folder.isDirectory()) {
      boolean success = folder.mkdirs();
      if (!success) {
        throw new IllegalStateException("Failed to create folder " + folder);
      }
    }
    try (FileOutputStream fos = new FileOutputStream(outFile)) {
      writeXsd(fos);
    } catch (Exception e) {
      throw new IllegalStateException("Failed to generate and write the XSD schema to " + outFile + "!", e);
    }
  }
260984
public function load(string $schemaFilename): array
    {
        try {
            $json = \file_get_contents($schemaFilename);

            return \json_decode($json, true);
        } catch (\Throwable $e) {
            throw new SchemaLoaderException(\sprintf(
                'Error loading schema file: "%s"',
                $schemaFilename
            ));
        }
    }
342899
public function loadXml(string $xmlFile)
    {
        $xmlFile = realpath($xmlFile);
        $xml = simplexml_load_file($xmlFile);
        if ($xml === false) {
            throw new \RuntimeException('Configuration file ' . $xmlFile . ' can\'t be loaded');
        }
        $this->load(json_decode(json_encode($xml), true));
    }
1292540
public static void setNamespace(Element element, String namespace,
            String schemaLocation) {
        element.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
                XMLConstants.XMLNS_ATTRIBUTE, namespace);
        element.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLNS_XSI,
                XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
        element.setAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,
                XSI_SCHEMA_LOCATION, schemaLocation);
    }
431774
private Path getOrGenerateSchemaFile(Schema schema) throws IOException {

    Preconditions.checkNotNull(schema, "Avro Schema should not be null");

    String hashedSchema = Hashing.sha256().hashString(schema.toString(), StandardCharsets.UTF_8).toString();

    if (!this.schemaPaths.containsKey(hashedSchema)) {

      Path schemaFilePath = new Path(this.schemaDir, String.valueOf(System.currentTimeMillis() + ".avsc"));
      AvroUtils.writeSchemaToFile(schema, schemaFilePath, fs, true);

      this.schemaPaths.put(hashedSchema, schemaFilePath);
    }

    return this.schemaPaths.get(hashedSchema);
  }
686333
public function setSchema($schema)
    {
        if ($schema === $this->schema) {
            return;
        }

        $this->schema = $schema;
        if ($schema && !$this->package && $this->getBuildProperty('schemaAutoPackage')) {
            $this->package = $schema;
            $this->packageOverridden = true;
        }

        if ($schema && !$this->namespace && $this->getBuildProperty('generator.schema.autoNamespace')) {
            $this->namespace = $schema;
        }
    }
645026
private function addNamespaceAttributes(ClassMetadata $metadata, \DOMElement $element): void
    {
        foreach ($metadata->xmlNamespaces as $prefix => $uri) {
            $attribute = 'xmlns';
            if ('' !== $prefix) {
                $attribute .= ':' . $prefix;
            } elseif ($element->namespaceURI === $uri) {
                continue;
            }
            $element->setAttributeNS('http://www.w3.org/2000/xmlns/', $attribute, $uri);
        }
    }
1117949
private function addSchema(Schema $schema)
    {
        if (array_key_exists($schema->getName(), $this->schemas)) {
            throw new \Exception(sprintf('Schema "%s" is allready registered.', $schema->getName()));
        }

        $this->schemas[$schema->getName()] = $schema;

        return $this;
    }
1215767
public void validateWithXmlSchema(String filename, String xmlSchemaPath) throws IOException {
    try (InputStream xmlStream = this.getClass().getResourceAsStream(filename)) {
      if (xmlStream == null) {
        throw new IOException("File not found in classpath: " + filename);
      }
      URL schemaUrl = this.getClass().getResource(xmlSchemaPath);
      if (schemaUrl == null) {
        throw new IOException("XML schema not found in classpath: " + xmlSchemaPath);
      }
      validateInternal(new StreamSource(xmlStream), schemaUrl);
    } catch (Exception e) {
      throw new IOException("Cannot load or parse '" + filename + "'", e);
    }
  }
1148928
public function map(string $schema, Table $table, string $name, FieldDefinition $definition)
    {
        if (!$definition instanceof AssociationFieldDefinition) {
            throw DoctrineStorageException::invalidDefinition(AssociationFieldDefinition::class, $definition);
        }

        $table->addColumn(
            $name,
            'guid',
            [
                'notnull' => !$definition->isNullable(),
                'default' => $definition->defaultValue(),
                'length' => $definition->options()['length'] ?? null,
                'unique' => $definition->options()['unique'] ?? false,
            ]
        );

        $table->addForeignKeyConstraint(
            $this->tableName($schema, $definition->typeSchema()->name()),
            [$name],
            ['id']
        );
    }