1 4 5 package com.sun.j2ee.blueprints.stringposervice; 6 7 import java.io.*; 8 9 import org.xml.sax.*; 10 11 public class POEntityResolver implements EntityResolver { 12 13 private static String RESOURCE_LOCATION = "/resources/"; 14 private static String BLUEPRINTS_NS = "http://java.sun.com/blueprints/schemas/"; 15 16 public InputSource resolveEntity(String publicId, String systemId) { 17 if (systemId.equals(BLUEPRINTS_NS + "PurchaseOrder.xsd")) { 18 return getClassPathSource("PurchaseOrder.xsd"); 19 } else{ 20 return null; 21 } 22 } 23 24 private InputSource getClassPathSource(String name) { 25 InputStream is = null; 26 try { 27 is = getClass().getResourceAsStream(RESOURCE_LOCATION + name); 28 return new InputSource(is); 29 } catch (Exception exe) { 30 System.err.println("POEntityResolver error resolving: " + name); 31 exe.printStackTrace(); 32 } 33 return null; 34 } 35 } 36 37 | Popular Tags |