Hi,
Please find attached patch for relative URL problem.
Cheers,
Rahul.
Sun Microsystems, Inc.
Index: XMLEntityManager.java
===================================================================
RCS file:
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java,v
retrieving revision 1.10
diff -u -w -r1.10 XMLEntityManager.java
--- XMLEntityManager.java 2001/10/23 08:01:51 1.10
+++ XMLEntityManager.java 2001/11/22 15:31:26
@@ -283,6 +283,9 @@
/** Shared declared entities. */
protected Hashtable fDeclaredEntities;
+ // holds the expanded location of the first entity scanned
+ String fFirstLocation = null;
+
//
// Constructors
//
@@ -503,9 +506,17 @@
// if no base systemId given, assume that it's relative
// to the systemId of the current scanned entity
+ //if (baseSystemId == null) {
+ // baseSystemId = fCurrentEntity.systemId;
+ //}
+
+ // If no baseSystemId is given, consider fFirstLocation.
+ // fFirstLocation will either be null or will hold the location
+ // of the first entity scanned. - RS
if (baseSystemId == null) {
- baseSystemId = fCurrentEntity.systemId;
+ baseSystemId = fFirstLocation;
}
+ String expandedSystemId = expandSystemId(systemId,baseSystemId);
// give the entity resolver a chance
XMLInputSource xmlInputSource = null;
@@ -522,7 +533,10 @@
// REVISIT: when systemId is null, I think we should return null.
// is this the right solution? -SG
//if (systemId != null)
- xmlInputSource = new XMLInputSource(publicId, systemId, baseSystemId);
+ //xmlInputSource = new XMLInputSource(publicId, systemId, baseSystemId);
+
+ // use the expandedSystemId - RS
+ xmlInputSource = new XMLInputSource(publicId, expandedSystemId,
+baseSystemId);
}
if (DEBUG_RESOLVER) {
@@ -713,6 +727,9 @@
stream = xmlInputSource.getByteStream();
if (stream == null) {
String expandedSystemId = expandSystemId(systemId, baseSystemId);
+ if (fFirstLocation == null) {
+ fFirstLocation = expandedSystemId;
+ }
if (baseSystemId == null) {
baseSystemId = expandedSystemId;
}
@@ -781,6 +798,9 @@
// create entity
String expandedSystemId = expandSystemId(systemId, baseSystemId);
+ if (fFirstLocation == null) {
+ fFirstLocation = expandedSystemId;
+ }
fCurrentEntity = new ScannedEntity(name, publicId, systemId,
expandedSystemId, stream, reader,
encoding, literal);
Index: XSDHandler.java
===================================================================
RCS file:
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java,v
retrieving revision 1.3
diff -u -w -r1.3 XSDHandler.java
--- XSDHandler.java 2001/11/13 22:30:12 1.3
+++ XSDHandler.java 2001/11/22 15:31:46
@@ -255,6 +255,9 @@
private XSElementDecl [] fKeyrefElems;
private String [][] fKeyrefNamespaceContext;
+ String fCurrentSystemId = null;
+ Stack fCurrentSystemIdStack = new Stack();
+
// Constructors
// it should be possible to use the same XSDHandler to parse
@@ -425,6 +428,7 @@
}
else {
newSchemaInfo = constructTrees(newSchemaRoot, schemaNamespace);
+ fCurrentSystemId = (String)fCurrentSystemIdStack.pop();
}
if (localName.equals(SchemaSymbols.ELT_REDEFINE) &&
newSchemaInfo != null) {
@@ -963,7 +967,8 @@
XMLInputSource schemaSource=null;
Document schemaDoc = null;
try {
- schemaSource = fEntityResolver.resolveEntity(schemaNamespace, schemaHint,
null);
+ //schemaSource = fEntityResolver.resolveEntity(schemaNamespace,
+schemaHint, null);
+ schemaSource = fEntityResolver.resolveEntity(schemaNamespace, schemaHint,
+fCurrentSystemId);
// REVISIT: when the system id of the input source is null, it's
// impossible to find the schema document. so we skip in
// this case. otherwise we'll receive some NPE or
@@ -973,6 +978,9 @@
// default entity resolver). but it's not clear to me
// whether the same applies for DTD.
if (schemaSource != null && schemaSource.getSystemId() != null) {
+ if (fCurrentSystemId != null)
+ fCurrentSystemIdStack.push(fCurrentSystemId);
+ fCurrentSystemId = schemaSource.getSystemId();
StringBuffer schemaIdBuf = new StringBuffer();
if (schemaSource.getPublicId() != null)
schemaIdBuf.append(schemaSource.getPublicId());
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]