1 16 package org.apache.cocoon.components.validation.jing; 17 18 import java.io.IOException ; 19 import java.util.Stack ; 20 21 import org.apache.cocoon.components.validation.impl.ValidationResolver; 22 import org.apache.excalibur.source.SourceResolver; 23 import org.xml.sax.EntityResolver ; 24 import org.xml.sax.InputSource ; 25 import org.xml.sax.SAXException ; 26 import org.xml.sax.XMLReader ; 27 28 import com.thaiopensource.xml.sax.XMLReaderCreator; 29 30 39 public class JingResolver extends ValidationResolver implements XMLReaderCreator { 40 41 42 private final Stack parsedSourceStack = new Stack (); 43 44 47 public JingResolver(SourceResolver sourceResolver, 48 EntityResolver entityResolver) { 49 super(sourceResolver, entityResolver); 50 this.parsedSourceStack.push(null); 51 } 52 53 57 public void pushInputSource(InputSource inputSource) { 58 this.parsedSourceStack.push(inputSource); 59 } 60 61 65 public InputSource popInputSource() { 66 if (this.parsedSourceStack.empty()) return null; 67 return (InputSource ) this.parsedSourceStack.pop(); 68 } 69 70 74 78 79 80 81 82 112 public InputSource resolveEntity(String publicId, String systemId) 113 throws SAXException , IOException { 114 InputSource source = (InputSource ) this.parsedSourceStack.peek(); 115 if (source == null) { 116 return super.resolveEntity(publicId, systemId); 117 } else { 118 return super.resolveEntity(source.getSystemId(), publicId, systemId); 119 } 120 } 121 122 123 124 125 126 127 140 public XMLReader createXMLReader() 141 throws SAXException { 142 return new JingReader(this); 143 } 144 } 145 | Popular Tags |