You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2004/06/22 06:08:45 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/traversers XSDHandler.java
mrglavas 2004/06/21 21:08:45
Modified: java/src/org/apache/xerces/impl/xs/opti SchemaDOMParser.java
DefaultDocument.java
java/src/org/apache/xerces/impl/xs/traversers
XSDHandler.java
Log:
Schema location hints specified as relative URIs should be relative
to the actual URI of the schema document rather than the specified
URI. When available use the actual document URI as the base URI
for resolving imports and includes.
This is consistent with what the XML 1.0 3E says: "... it (the base URI)
is the URI of the resource retrieved after all redirection has occurred." [1]
[1] http://www.w3.org/TR/2004/REC-xml-20040204/#sec-external-ent
Revision Changes Path
1.9 +2 -1 xml-xerces/java/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java
Index: SchemaDOMParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SchemaDOMParser.java 30 Apr 2004 02:42:43 -0000 1.8
+++ SchemaDOMParser.java 22 Jun 2004 04:08:45 -0000 1.9
@@ -94,6 +94,7 @@
fDepth = -1;
fLocator = locator;
fNamespaceContext = namespaceContext;
+ schemaDOM.setDocumentURI(locator.getExpandedSystemId());
} // startDocument(XMLLocator,String,NamespaceContext, Augmentations)
/**
1.7 +8 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/opti/DefaultDocument.java
Index: DefaultDocument.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/opti/DefaultDocument.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultDocument.java 24 Feb 2004 22:59:11 -0000 1.6
+++ DefaultDocument.java 22 Jun 2004 04:08:45 -0000 1.7
@@ -42,6 +42,8 @@
public class DefaultDocument extends NodeImpl
implements Document {
+ private String fDocumentURI = null;
+
// default constructor
public DefaultDocument() {
}
@@ -235,9 +237,10 @@
* over this attribute.
* @since DOM Level 3
*/
- public String getDocumentURI(){
- return null;
+ public String getDocumentURI() {
+ return fDocumentURI;
}
+
/**
* The location of the document or <code>null</code> if undefined.
* <br>Beware that when the <code>Document</code> supports the feature
@@ -245,8 +248,8 @@
* over this attribute.
* @since DOM Level 3
*/
- public void setDocumentURI(String documentURI){
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
+ public void setDocumentURI(String documentURI) {
+ fDocumentURI = documentURI;
}
/** DOM Level 3*/
1.78 +13 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
Index: XSDHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- XSDHandler.java 29 Mar 2004 22:55:54 -0000 1.77
+++ XSDHandler.java 22 Jun 2004 04:08:45 -0000 1.78
@@ -188,6 +188,16 @@
private String emptyString2Null(String ns) {
return ns == XMLSymbols.EMPTY_STRING ? null : ns;
}
+ private String doc2SystemId(Document doc) {
+ String documentURI = null;
+ /**
+ * REVISIT: Casting until DOM Level 3 interfaces are available. -- mrglavas
+ */
+ if (doc instanceof org.apache.xerces.impl.xs.opti.SchemaDOM) {
+ documentURI = ((org.apache.xerces.impl.xs.opti.SchemaDOM) doc).getDocumentURI();
+ }
+ return documentURI != null ? documentURI : (String) fDoc2SystemId.get(doc);
+ }
// This vector stores strings which are combinations of the
// publicId and systemId of the inputSource corresponding to a
@@ -670,7 +680,7 @@
fSchemaGrammarDescription.reset();
fSchemaGrammarDescription.setContextType(XSDDescription.CONTEXT_IMPORT);
- fSchemaGrammarDescription.setBaseSystemId((String)fDoc2SystemId.get(schemaRoot));
+ fSchemaGrammarDescription.setBaseSystemId(doc2SystemId(schemaRoot));
fSchemaGrammarDescription.setLocationHints(new String[]{schemaHint});
fSchemaGrammarDescription.setTargetNamespace(schemaNamespace);
@@ -740,7 +750,7 @@
}
fSchemaGrammarDescription.reset();
fSchemaGrammarDescription.setContextType(refType);
- fSchemaGrammarDescription.setBaseSystemId((String)fDoc2SystemId.get(schemaRoot));
+ fSchemaGrammarDescription.setBaseSystemId(doc2SystemId(schemaRoot));
fSchemaGrammarDescription.setLocationHints(new String[]{schemaHint});
fSchemaGrammarDescription.setTargetNamespace(callerTNS);
newSchemaRoot = resolveSchema(fSchemaGrammarDescription, mustResolve, child);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org