bloritsch 01/07/11 11:04:09
Modified: src/org/apache/cocoon/components/url Tag: cocoon_20_branch
URLFactoryImpl.java
src/org/apache/cocoon/transformation Tag: cocoon_20_branch
XIncludeTransformer.java
webapp Tag: cocoon_20_branch cocoon.xconf
Log:
Fix XInclude Processor and update namespace to current standards.
Note: fixed relative file URL error in URLFactory
Revision Changes Path
No revision
No revision
1.2.2.4 +6 -1
xml-cocoon2/src/org/apache/cocoon/components/url/URLFactoryImpl.java
Index: URLFactoryImpl.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/url/URLFactoryImpl.java,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -u -r1.2.2.3 -r1.2.2.4
--- URLFactoryImpl.java 2001/06/21 19:35:04 1.2.2.3
+++ URLFactoryImpl.java 2001/07/11 18:03:43 1.2.2.4
@@ -29,7 +29,7 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version $Id: URLFactoryImpl.java,v 1.2.2.3 2001/06/21 19:35:04 giacomo Exp $
+ * @version $Id: URLFactoryImpl.java,v 1.2.2.4 2001/07/11 18:03:43 bloritsch Exp $
*/
public class URLFactoryImpl extends AbstractLoggable implements URLFactory,
Component, Configurable, Contextualizable {
@@ -93,6 +93,11 @@
public URL getURL(URL base, String location) throws MalformedURLException {
if ( base != null ) {
+ if (base.getProtocol().equals("file")) {
+ File temp = new File(base.getPath(), location);
+ return getURL("file:" + temp.getAbsolutePath());
+ }
+
return getURL(new URL(base, location).toExternalForm());
} else {
return getURL(location);
No revision
No revision
1.6.2.5 +36 -13
xml-cocoon2/src/org/apache/cocoon/transformation/XIncludeTransformer.java
Index: XIncludeTransformer.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/XIncludeTransformer.java,v
retrieving revision 1.6.2.4
retrieving revision 1.6.2.5
diff -u -r1.6.2.4 -r1.6.2.5
--- XIncludeTransformer.java 2001/07/07 19:08:33 1.6.2.4
+++ XIncludeTransformer.java 2001/07/11 18:03:54 1.6.2.5
@@ -53,7 +53,7 @@
* by the SAX event FSM yet.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Donald Ball</a>
- * @version CVS $Revision: 1.6.2.4 $ $Date: 2001/07/07 19:08:33 $ $Author: giacomo $
+ * @version CVS $Revision: 1.6.2.5 $ $Date: 2001/07/11 18:03:54 $ $Author:
bloritsch $
*/
public class XIncludeTransformer extends AbstractTransformer implements Composable,
Recyclable, Disposable {
@@ -64,7 +64,7 @@
public static final String XMLBASE_NAMESPACE_URI =
"http://www.w3.org/XML/1998/namespace";
public static final String XMLBASE_ATTRIBUTE = "base";
- public static final String XINCLUDE_NAMESPACE_URI =
"http://www.w3.org/1999/XML/xinclude";
+ public static final String XINCLUDE_NAMESPACE_URI =
"http://www.w3.org/2001/XInclude";
public static final String XINCLUDE_INCLUDE_ELEMENT = "include";
public static final String XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE = "href";
public static final String XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE = "parse";
@@ -121,9 +121,12 @@
throw new SAXException(e);
}
}
- if (uri != null && name != null && uri.equals(XINCLUDE_NAMESPACE_URI) &&
name.equals(XINCLUDE_INCLUDE_ELEMENT)) {
+ if (XINCLUDE_NAMESPACE_URI.equals(uri) &&
XINCLUDE_INCLUDE_ELEMENT.equals(name)) {
String href = attr.getValue("",XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE);
String parse =
attr.getValue("",XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE);
+
+ if (null == parse) parse="xml";
+
try {
processXIncludeElement(href, parse);
} catch (MalformedURLException e) {
@@ -151,24 +154,35 @@
public void setDocumentLocator(Locator locator) {
try {
base_xmlbase_uri = urlFactory.getURL(locator.getSystemId());
- current_xmlbase_uri = base_xmlbase_uri;
- //if (current_xmlbase_uri == null) {
- current_xmlbase_uri = base_xmlbase_uri;
- // }
// If url ends with .xxx then truncate to dir
- if (current_xmlbase_uri.toExternalForm().lastIndexOf('.') >
current_xmlbase_uri.toExternalForm().lastIndexOf('/'))
- current_xmlbase_uri = new
URL(current_xmlbase_uri.toExternalForm().substring(0,current_xmlbase_uri.toExternalForm().lastIndexOf('/')+1));
+ if (base_xmlbase_uri.toExternalForm().lastIndexOf('.') >
base_xmlbase_uri.toExternalForm().lastIndexOf('/')) {
+ base_xmlbase_uri = new
URL(base_xmlbase_uri.toExternalForm().substring(0,base_xmlbase_uri.toExternalForm().lastIndexOf('/')+1));
+ }
+
+ if (current_xmlbase_uri == null) {
+ current_xmlbase_uri = base_xmlbase_uri;
+ }
} catch (MalformedURLException e) {getLogger().debug("XincludeTransformer",
e);}
super.setDocumentLocator(locator);
}
protected void startXMLBaseAttribute(String uri, String name, String value)
throws MalformedURLException {
+ String urlLoc = value;
+
+ if (! urlLoc.endsWith("/")) {
+ urlLoc += "/";
+ }
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("XIncludeTransformer: XMLBase = " + urlLoc);
+ }
+
if (current_xmlbase_uri != null) {
xmlbase_stack.push(current_xmlbase_uri);
}
- current_xmlbase_uri = urlFactory.getURL(value);
+ current_xmlbase_uri = urlFactory.getURL(urlLoc);
xmlbase_element_uri_stack.push(last_xmlbase_element_uri);
last_xmlbase_element_uri = uri;
@@ -178,6 +192,10 @@
}
protected void endXMLBaseAttribute() {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("XIncludeTransformer: XMLBase ended");
+ }
+
if (xmlbase_stack.size() > 0) {
current_xmlbase_uri = (URL)xmlbase_stack.pop();
} else {
@@ -188,18 +206,23 @@
}
protected void processXIncludeElement(String href, String parse) throws
SAXException,MalformedURLException,IOException {
- getLogger().debug("Processing XInclude element: href="+href+",
parse="+parse);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Processing XInclude element: href="+href+",
parse="+parse);
+ getLogger().debug("Base URI: " + current_xmlbase_uri.toExternalForm());
+ }
URL url;
String suffix;
int index = href.indexOf('#');
if (index < 0) {
- url = urlFactory.getURL(current_xmlbase_uri,"/"+href);
+ url = urlFactory.getURL(current_xmlbase_uri,href);
suffix = "";
} else {
url = urlFactory.getURL(current_xmlbase_uri,href.substring(0,index));
suffix = href.substring(index+1);
+ }
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("URL: "+url+"\nSuffix: "+suffix);
}
- getLogger().debug("URL: "+url+"\nSuffix: "+suffix);
Object object = url.getContent();
getLogger().debug("Object: "+object);
if (parse.equals("text")) {
No revision
No revision
1.7.2.10 +0 -3 xml-cocoon2/webapp/cocoon.xconf
Index: cocoon.xconf
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/cocoon.xconf,v
retrieving revision 1.7.2.9
retrieving revision 1.7.2.10
diff -u -r1.7.2.9 -r1.7.2.10
--- cocoon.xconf 2001/07/10 14:05:23 1.7.2.9
+++ cocoon.xconf 2001/07/11 18:04:03 1.7.2.10
@@ -183,9 +183,6 @@
</jdbc>
</datasources>
- <!-- this component is used as a PoolController for the sitemap component pools
-->
- <pool-controller
class="org.apache.avalon.excalibur.component.DefaultComponentPoolController"/>
-
<!-- A StreamPipeline either
collects a Reader and let it produce a character stream
or connects a EventPipeline with a
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]