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