From: <di...@us...> - 2007-07-27 19:18:23
|
Revision: 6300 http://exist.svn.sourceforge.net/exist/?rev=6300&view=rev Author: dizzzz Date: 2007-07-27 12:18:20 -0700 (Fri, 27 Jul 2007) Log Message: ----------- applied [1754435] Fix for validation against Schemas using a namespace Thnx adam! Modified Paths: -------------- trunk/eXist/src/org/exist/cluster/ClusterCollection.java trunk/eXist/src/org/exist/collections/Collection.java trunk/eXist/src/org/exist/collections/IndexInfo.java trunk/eXist/src/org/exist/validation/resolver/eXistXMLCatalogResolver.java Modified: trunk/eXist/src/org/exist/cluster/ClusterCollection.java =================================================================== --- trunk/eXist/src/org/exist/cluster/ClusterCollection.java 2007-07-27 18:15:28 UTC (rev 6299) +++ trunk/eXist/src/org/exist/cluster/ClusterCollection.java 2007-07-27 19:18:20 UTC (rev 6300) @@ -398,10 +398,10 @@ collection.setReader(reader); } - public InputSource resolveEntity(String publicId, String systemId) + /*public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { return collection.resolveEntity(publicId, systemId); - } + }*/ /* (non-Javadoc) * @see java.util.Observable#addObserver(java.util.Observer) Modified: trunk/eXist/src/org/exist/collections/Collection.java =================================================================== --- trunk/eXist/src/org/exist/collections/Collection.java 2007-07-27 18:15:28 UTC (rev 6299) +++ trunk/eXist/src/org/exist/collections/Collection.java 2007-07-27 19:18:20 UTC (rev 6300) @@ -22,12 +22,11 @@ package org.exist.collections; import java.io.ByteArrayInputStream; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.io.StringReader; -import java.net.URL; + import java.util.ArrayList; import java.util.Date; import java.util.Iterator; @@ -78,7 +77,6 @@ import org.exist.xmldb.XmldbURI; import org.exist.xquery.Constants; import org.w3c.dom.Node; -import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; @@ -93,10 +91,8 @@ * * @author wolf */ -public class Collection extends Observable - - implements Comparable, EntityResolver, Cacheable { - +public class Collection extends Observable implements Comparable, Cacheable +{ public static int LENGTH_COLLECTION_ID = 2; //sizeof short public Collection(){ @@ -873,7 +869,8 @@ LOG.debug("could not reset input source", e); } XMLReader reader = getReader(broker); - info.setReader(reader, Collection.this); + //info.setReader(reader, Collection.this); + info.setReader(reader, null); try { reader.parse(source); } catch (IOException e) { @@ -903,7 +900,8 @@ storeXMLInternal(transaction, broker, info, privileged, new StoreBlock() { public void run() throws SAXException, EXistException { XMLReader reader = getReader(broker); - info.setReader(reader, Collection.this); + //info.setReader(reader, Collection.this); + info.setReader(reader, null); try { reader.parse(new InputSource(new StringReader(data))); } catch (IOException e) { @@ -1043,7 +1041,8 @@ return validateXMLResourceInternal(transaction, broker, docUri, new ValidateBlock() { public void run(IndexInfo info) throws SAXException, EXistException { XMLReader reader = getReader(broker); - info.setReader(reader, Collection.this); + //info.setReader(reader, Collection.this); + info.setReader(reader, null); try { reader.parse(source); } catch (IOException e) { @@ -1560,44 +1559,6 @@ broker.getBrokerPool().getParserPool().returnXMLReader(reader); } - /** - * Try to resolve external entities. - * - * This method forwards the request to the resolver. If that fails, - * the method replaces absolute file names with relative ones - * and retries to resolve. This makes it possible to use relative - * file names in the catalog. - * - * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String) - */ - public InputSource resolveEntity(String publicId, String systemId) - throws SAXException, IOException { - - // TODO dizzzz remove later on - LOG.debug("Resolve publicId='"+publicId+"', systemId='"+systemId+"'."); - InputSource is = resolver.resolveEntity(publicId, systemId); - - // if resolution failed and publicId == null, - // try to make absolute file names relative and retry - if (is == null) { - LOG.debug("Resolve failed, fallback scenario"); - if (publicId != null) - return null; - - URL url = new URL(systemId); - if (url.getProtocol().equals("file")) { - String path = url.getPath(); - File f = new File(path); - if (!f.canRead()) - return resolver.resolveEntity(null, f.getName()); - else - return new InputSource(f.getAbsolutePath()); - } else - return new InputSource(url.openStream()); - } - return is; - } - /* (non-Javadoc) * @see java.util.Observable#addObserver(java.util.Observer) */ Modified: trunk/eXist/src/org/exist/collections/IndexInfo.java =================================================================== --- trunk/eXist/src/org/exist/collections/IndexInfo.java 2007-07-27 18:15:28 UTC (rev 6299) +++ trunk/eXist/src/org/exist/collections/IndexInfo.java 2007-07-27 19:18:20 UTC (rev 6300) @@ -63,7 +63,8 @@ } void setReader(XMLReader reader, EntityResolver entityResolver) throws SAXException { - reader.setEntityResolver(entityResolver); + if(entityResolver != null) + reader.setEntityResolver(entityResolver); LexicalHandler lexicalHandler = trigger == null ? indexer : trigger.getLexicalInputHandler(); ContentHandler contentHandler = trigger == null ? indexer : trigger.getInputHandler(); reader.setProperty(Namespaces.SAX_LEXICAL_HANDLER, lexicalHandler); Modified: trunk/eXist/src/org/exist/validation/resolver/eXistXMLCatalogResolver.java =================================================================== --- trunk/eXist/src/org/exist/validation/resolver/eXistXMLCatalogResolver.java 2007-07-27 18:15:28 UTC (rev 6299) +++ trunk/eXist/src/org/exist/validation/resolver/eXistXMLCatalogResolver.java 2007-07-27 19:18:20 UTC (rev 6300) @@ -22,7 +22,9 @@ package org.exist.validation.resolver; +import java.io.File; import java.io.IOException; +import java.net.URL; import java.util.Iterator; import java.util.List; @@ -83,14 +85,18 @@ } } - - /** * @see org.apache.xerces.util.XMLCatalogResolver#resolveEntity(String, String) */ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { LOG.debug("Resolving publicId='"+publicId+"', systemId='"+systemId+"'"); InputSource retValue = super.resolveEntity(publicId, systemId); + + if(retValue == null) + { + retValue = resolveEntityFallback(publicId, systemId); + } + LOG.debug("Resolved " + (retValue!=null)); if(retValue!=null){ LOG.debug("PublicId='" + retValue.getPublicId() + "' SystemId=" + retValue.getSystemId()); @@ -98,6 +104,37 @@ return retValue; } + /** moved from Collection.resolveEntity() revision 6144 */ + private InputSource resolveEntityFallback(String publicId, String systemId) throws SAXException, IOException + { + //if resolution failed and publicId == null, + // try to make absolute file names relative and retry + LOG.debug("Resolve failed, fallback scenario"); + if(publicId != null) + { + return null; + } + + URL url = new URL(systemId); + if(url.getProtocol().equals("file")) + { + String path = url.getPath(); + File f = new File(path); + if(!f.canRead()) + { + return resolveEntity(null, f.getName()); + } + else + { + return new InputSource(f.getAbsolutePath()); + } + } + else + { + return new InputSource(url.openStream()); + } + } + /** * @see org.apache.xerces.util.XMLCatalogResolver#resolveResource(String, String, String, String, String) */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |