All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.webflow.engine.builder.xml.WebFlowEntityResolver Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
/*
 * Copyright 2002-2006 the original author or authors.
 *
 * Licensed 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 org.springframework.webflow.engine.builder.xml;

import java.io.IOException;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

/**
 * EntityResolver implementation for the Spring Web Flow 1.0 XML Schema. This
 * will load the XSD from the classpath. 
 * 

* The xmlns of the XSD expected to be resolved: * *

 *     <?xml version="1.0" encoding="UTF-8"?>
 *     <flow xmlns="http://www.springframework.org/schema/webflow"
 *           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 *           xsi:schemaLocation="http://www.springframework.org/schema/webflow
 *                               http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd">
 * 
* * @author Erwin Vervaet * @author Ben Hale */ public class WebFlowEntityResolver implements EntityResolver { private static final String WEBFLOW_ELEMENT = "spring-webflow-1.0"; public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if (systemId != null && systemId.indexOf(WEBFLOW_ELEMENT) > systemId.lastIndexOf("/")) { String filename = systemId.substring(systemId.indexOf(WEBFLOW_ELEMENT)); try { Resource resource = new ClassPathResource(filename, getClass()); InputSource source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); return source; } catch (IOException ex) { // fall through below } } // let the parser handle it return null; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy