<xsd:schema [targetNamespace="$targetNamespace"]>
168646
public XSDocument startSchema(String targetNamespace) throws SAXException{
        xml.startElement(URI_XSD, "schema");
        if(targetNamespace!=null && !targetNamespace.isEmpty()){
            xml.declarePrefix(targetNamespace);
            xml.addAttribute("targetNamespace", targetNamespace);
        }
        return this;
    }
443839
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;
    }
705607
public function getImporterXsd(): string
    {
        $xsd = new \DOMDocument('1.0', 'utf-8');
        $xsd->loadXML('<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"/>');
        foreach ($this->schemas as $schema) {
            $node = $xsd->createElementNS('http://www.w3.org/2001/XMLSchema', 'import');
            $node->setAttribute('namespace', $schema->getNamespace());
            $node->setAttribute('schemaLocation', str_replace('\\', '/', $schema->getLocation()));
            $xsd->documentElement->appendChild($node);
        }
        return $xsd->saveXML();
    }
1161156
public function setSchema($v)
    {
        if ($v == $this->schema) {
            return;
        }
        $this->schema = $v;
        if ($v && !$this->pkg && $this->getBuildProperty('schemaAutoPackage')) {
            $this->pkg = $v;
            $this->pkgOverridden = true;
        }
        if ($v && !$this->namespace && $this->getBuildProperty('schemaAutoNamespace')) {
            $this->namespace = $v;
        }
    }
760493
public function namespaced(string $namespace, array $schema, array $config = []): array
    {
        $document = $this->getContent();
        $namespaces = $this->getAvailableNamespaces();

        if (! \is_null($namespace) && isset($namespaces[$namespace])) {
            $document = $document->children($namespaces[$namespace]);
        }

        $this->content = $document;

        return $this->parse($schema, $config);
    }
523045
protected void validateNamespace(final SqlValidatorNamespace namespace,
		RelDataType targetRowType) {
		namespace.validate(targetRowType);
		if (namespace.getNode() != null) {
			setValidatedNodeType(namespace.getNode(), namespace.getType());
		}
	}
704350
public static void loosenXmlAnyOtherNamespaceToXmlAnyAnyNamespace(final Node node)
	{
		if (node instanceof Element)
		{
			final Element element = (Element) node;

			if (XML_SCHEMA_NAMESPACE.equals(node.getNamespaceURI()) && XML_SCHEMA_ANY_ELEMENT_NAME.equals(node.getLocalName()))
			{
				if ("##other".equals(element.getAttribute("namespace")))
				{
					element.setAttribute("namespace", "##any");
				}
			}
			else
			{
				final NodeList nodes = node.getChildNodes();

				for (int i = 0; i < nodes.getLength(); i++)
				{
					loosenXmlAnyOtherNamespaceToXmlAnyAnyNamespace(nodes.item(i));
				}
			}
		}
	}
1137231
private static void applyElement(Annotated member, Schema property) {
        final XmlElementWrapper wrapper = member.getAnnotation(XmlElementWrapper.class);
        if (wrapper != null) {
            final XML xml = getXml(property);
            xml.setWrapped(true);
            // No need to set the xml name if the name provided by xmlelementwrapper annotation is ##default or equal to the property name | https://github.com/swagger-api/swagger-core/pull/2050
            if (!"##default".equals(wrapper.name()) && !wrapper.name().isEmpty() && !wrapper.name().equals(((SchemaImpl) property).getName())) {
                xml.setName(wrapper.name());
            }
        } else {
            final XmlElement element = member.getAnnotation(XmlElement.class);
            if (element != null) {
                setName(element.namespace(), element.name(), property);
            }
        }
    }
898482
public static String validateXMLAgainstSchema(final String xml) {
		// Validate XML against schema
		if (xml != null && !xml.equals("")) {
			// Wrap XML with a root element (if required)
			String testXML = wrapXMLInRootElement(xml);
			try {
				// Create SAX Parser Factory
				SAXParserFactory spf = SAXParserFactory.newInstance();
				spf.setNamespaceAware(true);
				spf.setValidating(true);

				// Create SAX Parser
				SAXParser parser = spf.newSAXParser();
				parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
						XMLConstants.W3C_XML_SCHEMA_NS_URI);

				// Set schema location
				Object schema = DebugValidateXML.class.getResource(getSchemaPath()).toString();
				parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schema);

				// Setup the handler to throw an exception when an error occurs
				DefaultHandler handler = new DefaultHandler() {
					@Override
					public void warning(final SAXParseException e) throws SAXException {
						LOG.warn("XML Schema warning: " + e.getMessage(), e);
						super.warning(e);
					}

					@Override
					public void fatalError(final SAXParseException e) throws SAXException {
						throw e;
					}

					@Override
					public void error(final SAXParseException e) throws SAXException {
						throw e;
					}
				};

				// Validate the XML
				InputSource xmlSource = new InputSource(new StringReader(testXML));
				parser.parse(xmlSource, handler);

			} catch (SAXParseException e) {
				return "At line " + e.getLineNumber() + ", column: " + e.getColumnNumber()
						+ " ==> " + e.getMessage();
			} catch (Exception e) {
				return e.getMessage();
			}
		}

		return null;
	}
1243924
private void registerXmlSchemaRepository(Element element, ParserContext parserContext) {
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(XsdSchemaRepository.class);
        BeanDefinitionParserUtils.setPropertyReference(builder, element.getAttribute("schema-mapping-strategy"), "schemaMappingStrategy");
        addLocationsToBuilder(element, builder);
        parseSchemasElement(element, builder, parserContext);
        parserContext.getRegistry().registerBeanDefinition(element.getAttribute(ID), builder.getBeanDefinition());
    }
204762
public void ensureNamespace(String schema)
    {
        try {
            // If the table schema is not "default" and the namespace does not exist, create it
            if (!schema.equals(DEFAULT) && !connector.namespaceOperations().exists(schema)) {
                connector.namespaceOperations().create(schema);
            }
        }
        catch (AccumuloException | AccumuloSecurityException e) {
            throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to check for existence or create Accumulo namespace", e);
        }
        catch (NamespaceExistsException e) {
            // Suppress race condition between test for existence and creation
            LOG.warn("NamespaceExistsException suppressed when creating " + schema);
        }
    }
848799
private void initNamespaces()
    {
        // The initial prefix mappings will never be deleted because they are at element depth -1
        // (a kludge)

        // Define the default namespace (initially maps to "" uri)
        Stack stack;
        MappingRecord nn;
        nn = new MappingRecord(EMPTYSTRING, EMPTYSTRING, -1);
        stack = createPrefixStack(EMPTYSTRING);
        stack.push(nn);

        // define "xml" namespace
        nn = new MappingRecord(XML_PREFIX, "http://www.w3.org/XML/1998/namespace", -1);
        stack = createPrefixStack(XML_PREFIX);
        stack.push(nn);
    }
912386
public function setSchema($schema)
    {
        $schema = array($schema);
        if (func_num_args() > 0) {
            $schema = func_get_args();
        }
        
        $error = Argument::i();
        foreach ($schema as $i => $name) {
            $error->test($i + 1, 'string');
        }
        
        $schema = implode(',', $schema);
        
        $query = $this->utility()->setSchema($schema);
        $this->query($query);
        
        return $this;
    }
468036
@Override
    public Namespace createNamespace(Namespace namespace) {
        requireNotDisposed();
        requireArgument(namespace != null, "null namespace cannot be created.");
        
        if (!_validateQualifier(namespace.getQualifier())) {
            throw new SystemException(new IllegalArgumentException(
                    "Illegal characters found while generating namespace. Cannot generate a namespace with this qualifier."));
        }
        
        if (Namespace.findByQualifier(emf.get(), namespace.getQualifier()) != null) {
            throw new SystemException(new IllegalArgumentException("Namespace already exists. Please try a different namespace."));
        }
        
        namespace = updateNamespace(namespace);
        _logger.debug("Generated namespace {}.", namespace);
        return namespace;
    }
166443
@Override
    protected XMLValidationSchema loadSchema(InputSource src, Object sysRef)
        throws XMLStreamException
    {
        /* 26-Oct-2007, TSa: Are sax parser factories safe to share?
         *   If not, should just create new instances for each
         *   parsed schema.
         */
        SAXParserFactory saxFactory = getSaxFactory();

        MyGrammarController ctrl = new MyGrammarController();
        XMLSchemaGrammar grammar = XMLSchemaReader.parse(src, saxFactory, ctrl);
        if (grammar == null) {
            String msg = "Failed to load W3C Schema from '"+sysRef+"'";
            String emsg = ctrl.mErrorMsg;
            if (emsg != null) {
                msg = msg + ": "+emsg;
            }
            throw new XMLStreamException(msg);
        }
        return new W3CSchema(grammar);
    }
1012537
private Schema getXmlSchema10() throws SAXException {
        final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        // Use local copies of schemas rather than resolving from the net. It's faster, and less prone to errors.
        final Source[] schemaFiles = {
                new StreamSource(this.getClass().getClassLoader().getResourceAsStream("spdx.xsd")),
                new StreamSource(this.getClass().getClassLoader().getResourceAsStream("bom-1.0.xsd"))
        };
        return schemaFactory.newSchema(schemaFiles);
    }
1162842
def fill_schema_from_xsd_file(filename, schema):
    
    ifmap_statements = _parse_xsd_file(filename)
    properties_all = []

    for v in ifmap_statements.values():
        if (isinstance(v[0], IDLParser.Link)):
            src_name = v[1]
            target_name = v[2]
            src = schema._get_or_add_resource(src_name)
            target = schema._get_or_add_resource(target_name)
            if "has" in v[3]:
                src.children.append(target_name)
                target.parent = src_name
            if "ref" in v[3]:
                src.refs.append(target_name)
                target.back_refs.append(src_name)
        elif isinstance(v[0], IDLParser.Property):
            target_name = v[1][0]
            prop = ResourceProperty(v[0].name, is_list=v[0].is_list, is_map=v[0].is_map)
            if target_name != 'all':
                target = schema._get_or_add_resource(target_name)
                target.properties.append(prop)
            else:
                properties_all.append(prop)

    for r in schema.all_resources():
        schema.resource(r).properties += properties_all