Author: vmassol
Date: 2007-09-06 14:22:39 +0200 (Thu, 06 Sep 2007)
New Revision: 4740
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/XWikiURIResolver.java
Log:
XWIKI-1715: PDF export fails when offline on some pages
* Added fallback for when the resolved receives relative systemId instead of
URLs. I'm still unsure when that happens and I was not able to reproduce it but
it happened for Brandon and this fixed it.
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/XWikiURIResolver.java
===================================================================
---
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/XWikiURIResolver.java
2007-09-06 12:02:23 UTC (rev 4739)
+++
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/XWikiURIResolver.java
2007-09-06 12:22:39 UTC (rev 4740)
@@ -88,8 +88,22 @@
+ "] locally. Will try to get it online at [" +
systemId + "]");
}
} else {
- LOG.warn("Unknown URI scheme [" + uri.getScheme() + "] for
entity ["
- + systemId + "].");
+ // As there's no scheme we'll assume that it's an already
resolved systemId that is
+ // passed. This happens when a DTD file uses a relative
systemId for dependent
+ // entity files. For example the default xhtml1-strict.dtd and
+ // xhtml1-transitional.dtd files reference xhtml-lat1.ent,
xhtml-special.ent and
+ // xhtml1-symbol.ent relatively. Normally these relative
declarations generate a
+ // URL with a "file" scheme but apparently there are some
cases when the raw
+ // entity file names is passed to this resolveEntity method...
+ LOG.debug("Unknown URI scheme [" + uri.getScheme() + "] for
entity ["
+ + systemId + "]. Assuming the entity is already resolved
and looking for it "
+ + "in the file system.");
+ InputStream istream =
getClass().getClassLoader().getResourceAsStream(systemId);
+ if (istream != null) {
+ source = new InputSource(istream);
+ } else {
+ LOG.warn("Failed to load resource [" + systemId + "]
locally.");
+ }
}
} catch (URISyntaxException e) {
LOG.warn("Invalid URI [" + systemId + "].", e);
@@ -97,4 +111,4 @@
// Returning null causes the caller to try accessing the entity online
return source;
}
-}
\ No newline at end of file
+}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications