org.milyn.xml.EclipseFragmentXMLValidator Maven / Gradle / Ivy
/*
* Milyn - Copyright (C) 2006 - 2010
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License (version 2.1) as published by the Free Software
* Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU Lesser General Public License for more details:
* http://www.gnu.org/licenses/lgpl.txt
*/
package org.milyn.xml;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.milyn.cdr.SmooksConfigurationException;
import org.milyn.io.StreamUtils;
import org.milyn.util.ClassUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.ls.LSInput;
import org.w3c.dom.ls.LSResourceResolver;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.SchemaFactory;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Eclipse XML Validator.
*
* Uses the Eclipse based /fragment.xml schema resource files available on the classpath
* to lookup the schema resources for given namespaces.
*
*
* @author zubairov
* @author [email protected]
*/
public class EclipseFragmentXMLValidator extends XsdValidator {
private static final Log logger = LogFactory.getLog(EclipseFragmentXMLValidator.class);
public EclipseFragmentXMLValidator() throws IOException, SAXException {
super.setSchemaSourceResolver(new SchemaResolver());
}
public EclipseFragmentXMLValidator(SchemaFactory schemaFactory) throws IOException, SAXException {
super.setSchemaFactory(schemaFactory);
super.setSchemaSourceResolver(new SchemaResolver());
}
@Override
public void setSchemaSourceResolver(LSResourceResolver schemaSourceResolver) throws SAXException {
throw new UnsupportedOperationException("Illegal call to set SchemaSourceResolver.");
}
@Override
public void setXSDSources(Collection