Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the University Corporation for Advanced Internet Development,
* Inc. (UCAID) under one or more contributor license agreements. See the
* NOTICE file distributed with this work for additional information regarding
* copyright ownership. The UCAID licenses this file to You under the Apache
* License, Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.shibboleth.utilities.java.support.xml;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
import javax.xml.XMLConstants;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import net.shibboleth.utilities.java.support.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.ls.LSResourceResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
/**
* A class for building a {@link Schema} from a set of inputs, allowing for
* manipulation of the underlying factory.
*/
@NotThreadSafe
public class SchemaBuilder {
/** Language of the schema files. */
public static enum SchemaLanguage {
/** W3 XML Schema. */
XML(XMLConstants.W3C_XML_SCHEMA_NS_URI),
/** OASIS RELAX NG Schema. */
RELAX(XMLConstants.RELAXNG_NS_URI);
/** Constant for use with {@link SchemaFactory#newInstance(String)}. */
@Nonnull private String schemaFactoryURI;
/**
* Constructor.
*
* @param uri schema factory identifier
*/
private SchemaLanguage(@Nonnull @NotEmpty final String uri) {
schemaFactoryURI = Constraint.isNotNull(StringSupport.trimOrNull(uri), "URI cannot be null or empty");
}
/**
* Get a {@link SchemaFactory} instance for a schema language.
*
* @return a factory instance
*/
@Nonnull public SchemaFactory getSchemaFactory() {
return SchemaFactory.newInstance(schemaFactoryURI);
}
};
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(SchemaBuilder.class);
/** Language of schemas. */
@Nonnull private SchemaLanguage schemaLang;
/** Sources of schema material compatible with JAXP. */
@Nonnull @NonnullElements private List