Author: alexsmirnov
Date: 2009-09-18 20:22:07 -0400 (Fri, 18 Sep 2009)
New Revision: 15630
Added:
root/cdk/trunk/plugins/README.odt
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/ProcessingException.java
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/SAXConsumer.java
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java
root/cdk/trunk/plugins/xinclude/pom.xml
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/XIncludeTransformer.java
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/xpointer/XPointerContext.java
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/util/dom/DOMStreamer.java
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/util/dom/DOMUtils.java
Log:
convert Cocoon XInclude Transformer to SAX handler
Added: root/cdk/trunk/plugins/README.odt
===================================================================
(Binary files differ)
Property changes on: root/cdk/trunk/plugins/README.odt
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java 2009-09-18
23:00:33 UTC (rev 15629)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java 2009-09-19
00:22:07 UTC (rev 15630)
@@ -26,7 +26,7 @@
* </ul>
* <p> </p>
*<h3>Facet annotations.</h3>
-* <p>There are two methods to define component facet. At the class level, developer
could use @{@link Facets annotations. It is also possible to define facet
getter/setter methods for facet and mark one of them with @{@link Facet}
annotation.</p>
+ * <p>There are two methods to define component facet. At the class level,
developer could use @{@link Facets annotations. It is also possible to define
facet getter/setter methods for facet and mark one of them with @{@link Facet}
annotation.</p>
*
*/
Modified: root/cdk/trunk/plugins/xinclude/pom.xml
===================================================================
--- root/cdk/trunk/plugins/xinclude/pom.xml 2009-09-18 23:00:33 UTC (rev 15629)
+++ root/cdk/trunk/plugins/xinclude/pom.xml 2009-09-19 00:22:07 UTC (rev 15630)
@@ -1,128 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
-
http://www.apache.org/licenses/LICENSE-2.0
+
http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
+ <!-- $Id: pom.xml 699337 2008-09-26 14:24:57Z reinhard $ -->
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
- <!-- $Id: pom.xml 699337 2008-09-26 14:24:57Z reinhard $ -->
- <project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>jar</packaging>
+ <parent>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-plugins</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>jar</packaging>
- <parent>
- <groupId>org.richfaces.cdk</groupId>
-
<artifactId>maven-plugins</artifactId>
-
<version>4.0.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>xinclude</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <name>Cocoon 3: xinclude transformer</name>
- <description>Cocoon 3 xinclude transformer with Xpointer scheme
support.</description>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>xinclude</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <name>Cocoon 3: xinclude transformer</name>
+ <description>Cocoon 3 xinclude transformer with Xpointer scheme
support.</description>
- <dependencies>
-<dependency>
- <groupId>org.apache.cocoon.pipeline</groupId>
- <artifactId>cocoon-pipeline</artifactId>
- <version>3.0.0-alpha-1</version>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
- </dependency>
+ <dependencies>
+ <!--
+ <dependency> <groupId>org.apache.cocoon.pipeline</groupId>
+ <artifactId>cocoon-pipeline</artifactId>
+ <version>3.0.0-alpha-1</version> </dependency>
+ -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
- <!-- Other dependencies -->
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <scope>runtime</scope>
- </dependency>
+ <!-- Other dependencies -->
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>runtime</scope>
+ </dependency>
- <!-- Test dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <scope>test</scope>
- <version>1.2</version>
- </dependency>
- </dependencies>
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <scope>test</scope>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ </dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.1</version>
- <configuration>
- <archive>
- <manifestEntries>
- <Cocoon-Block-Name>${pom.artifactId}</Cocoon-Block-Name>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>javacc-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>javacc</id>
- <goals>
- <goal>javacc</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>target/generated-sources/javacc</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.1</version>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Cocoon-Block-Name>${pom.artifactId}</Cocoon-Block-Name>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>javacc-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>javacc</id>
+ <goals>
+ <goal>javacc</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/generated-sources/javacc</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
</project>
Added:
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/ProcessingException.java
===================================================================
---
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/ProcessingException.java
(rev 0)
+++
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/ProcessingException.java 2009-09-19
00:22:07 UTC (rev 15630)
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.apache.cocoon.pipeline.component.sax;
+
+import org.xml.sax.SAXException;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ProcessingException extends SAXException {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public ProcessingException() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public ProcessingException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public ProcessingException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public ProcessingException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Added:
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/SAXConsumer.java
===================================================================
---
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/SAXConsumer.java
(rev 0)
+++
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/SAXConsumer.java 2009-09-19
00:22:07 UTC (rev 15630)
@@ -0,0 +1,36 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.apache.cocoon.pipeline.component.sax;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface SAXConsumer extends ContentHandler, LexicalHandler {
+
+}
Modified:
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/XIncludeTransformer.java
===================================================================
---
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/XIncludeTransformer.java 2009-09-18
23:00:33 UTC (rev 15629)
+++
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/XIncludeTransformer.java 2009-09-19
00:22:07 UTC (rev 15630)
@@ -25,31 +25,59 @@
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.component.xpointer.XPointer;
import org.apache.cocoon.pipeline.component.xpointer.XPointerContext;
import org.apache.cocoon.pipeline.component.xpointer.parser.ParseException;
import org.apache.cocoon.pipeline.component.xpointer.parser.XPointerFrameworkParser;
-import org.apache.cocoon.pipeline.util.URLConnectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.ext.EntityResolver2;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
public final class XIncludeTransformer
- extends AbstractXMLProducer
- implements XMLConsumer {
+ implements SAXConsumer {
- private static final String XINCLUDE_NAMESPACE_URI =
"http://www.w3.org/2001/XInclude";
+ private static final class DummyLexicalHandler implements LexicalHandler {
+ public void startEntity(String name) throws SAXException {
+ }
+ public void startDTD(String name, String publicId, String systemId)
+ throws SAXException {
+ }
+
+ public void startCDATA() throws SAXException {
+ }
+
+ public void endEntity(String name) throws SAXException {
+ }
+
+ public void endDTD() throws SAXException {
+ }
+
+ public void endCDATA() throws SAXException {
+ }
+
+ public void comment(char[] ch, int start, int length) throws SAXException {
+
+ }
+ }
+
+ private static final String XINCLUDE_NAMESPACE_URI =
"http://www.w3.org/2001/XInclude";
+
private static final String XINCLUDE_INCLUDE = "include";
private static final String XINCLUDE_FALLBACK = "fallback";
@@ -78,8 +106,8 @@
private static final String HTTP_ACCEPT_LANGUAGE = "Accept-Language";
- private final Log logger = LogFactory.getLog(getClass());
+ private static final Log logger = LogFactory.getLog(XIncludeTransformer.class);
/** The nesting level of xi:include elements that have been encountered. */
private int xIncludeElementLevel = 0;
@@ -95,7 +123,7 @@
*/
private Locator locator;
- private URL baseUrl;
+ private URI baseUri;
/**
* Keep a map of namespaces prefix in the source document to pass it
@@ -103,31 +131,70 @@
*/
private final Map<String, String> namespaces = new HashMap<String,
String>();
- public XIncludeTransformer() {
- // default empty constructor
- }
+ private ContentHandler contentHandler;
- public XIncludeTransformer(URL baseUrl) {
- this.setBaseUrl(baseUrl);
- }
+ private LexicalHandler lexicalHandler;
- @Override
- public void setConfiguration(Map<String, ? extends Object> configuration) {
- this.setBaseUrl((URL) configuration.get("baseUrl"));
- }
+ private EntityResolver2 resolver;
+ public XIncludeTransformer() {
+ // default empty constructor
+ }
- public void setBaseUrl(URL baseUrl) {
- this.baseUrl = baseUrl;
+ public XIncludeTransformer(URI baseUri) {
+ this.setBaseUri(baseUri);
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the resolver
+ */
+ public EntityResolver2 getResolver() {
+ return resolver;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param resolver the resolver to set
+ */
+ public void setResolver(EntityResolver2 resolver) {
+ this.resolver = resolver;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the contentHandler
+ */
+ public ContentHandler getContentHandler() {
+ return contentHandler;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the lexicalHandler
+ */
+ public LexicalHandler getLexicalHandler() {
+ if (lexicalHandler == null) {
+ lexicalHandler = new DummyLexicalHandler();
+
+ }
+
+ return lexicalHandler;
+ }
+
+ public void setBaseUri(URI baseUri) {
+ this.baseUri = baseUri;
}
/**
* Eventually previous errors don't reset local variables status, so
* every time a new consumer is set, local variables should be re-initialized
*/
- @Override
- protected void setXMLConsumer(XMLConsumer xmlConsumer) {
- super.setXMLConsumer(xmlConsumer);
- this.xIncludeElementLevel = 0;
+ protected void setContentHandler(ContentHandler delegateHandler) {
+ this.contentHandler = delegateHandler;
+ if (delegateHandler instanceof LexicalHandler) {
+ lexicalHandler = (LexicalHandler) delegateHandler;
+ }
+ this.xIncludeElementLevel = 0;
this.fallbackElementLevel = 0;
this.useFallbackLevel = 0;
}
@@ -158,13 +225,13 @@
public void startDocument() throws SAXException {
if (xIncludeElementLevel == 0) {
- getXMLConsumer().startDocument();
+ getContentHandler().startDocument();
}
}
public void endDocument() throws SAXException {
if (xIncludeElementLevel == 0) {
- getXMLConsumer().endDocument();
+ getContentHandler().endDocument();
}
}
@@ -205,7 +272,7 @@
}
} else if (isEvaluatingContent()) {
// Copy other elements through when appropriate:
- getXMLConsumer().startElement(uri, localName, name, atts);
+ getContentHandler().startElement(uri, localName, name, atts);
}
}
@@ -245,7 +312,7 @@
if (href == null || href.length() == 0) {
throw new SAXException("XIncludeTransformer: encountered empty href (=
href pointing to the current document).");
}
- URL source = createSource(href);
+ InputSource source = createSource(href);
URLConnection urlConnection = null;
try {
@@ -262,19 +329,19 @@
if (XINCLUDE_PARSE_XML.equals(parse)) {
/* sends Accept and Accept-Language */
- if (urlConnection instanceof HttpURLConnection) {
- HttpURLConnection httpURLConnection =
- (HttpURLConnection) urlConnection;
+// if (urlConnection instanceof HttpURLConnection) {
+// HttpURLConnection httpURLConnection =
+// (HttpURLConnection) urlConnection;
+//
+// if (accept != null && accept.length() > 0) {
+// httpURLConnection.setRequestProperty(HTTP_ACCEPT, accept);
+// }
+//
+// if (acceptLanguage != null && acceptLanguage.length() >
0) {
+// httpURLConnection.setRequestProperty(HTTP_ACCEPT_LANGUAGE,
acceptLanguage);
+// }
+// }
- if (accept != null && accept.length() > 0) {
- httpURLConnection.setRequestProperty(HTTP_ACCEPT, accept);
- }
-
- if (acceptLanguage != null && acceptLanguage.length() > 0)
{
- httpURLConnection.setRequestProperty(HTTP_ACCEPT_LANGUAGE,
acceptLanguage);
- }
- }
-
if (xpointer != null && xpointer.length() > 0) {
try {
XPointer xPointer = XPointerFrameworkParser.parse(xpointer);
@@ -345,7 +412,7 @@
int read;
char ary[] = new char[1024 * 4];
while ((read = reader.read(ary)) != -1) {
- getXMLConsumer().characters(ary, 0, read);
+ getContentHandler().characters(ary, 0, read);
}
} catch (IOException e) {
useFallbackLevel++;
@@ -382,24 +449,32 @@
}
}
- private URL createSource(String sourceAtt) {
+ private InputSource createSource(String sourceAtt) throws SAXException {
try {
- URL source = null;
- if (sourceAtt.contains(":")) {
- source = new URL(sourceAtt);
- } else {
- source = new URL(this.baseUrl, sourceAtt);
+ InputSource source = null;
+ URI sourceURI = URI.create(sourceAtt);
+ if(!sourceURI.isAbsolute() && null != this.baseUri){
+ sourceAtt = this.baseUri.resolve(sourceURI).toString();
+ }
+ if(null != resolver){
+ source = resolver.resolveEntity(null, sourceAtt);
+ }
+ if(null == source){
+ source = new InputSource(sourceAtt);
}
if (this.logger.isDebugEnabled()) {
- this.logger.debug("Including source: " + source);
+ this.logger.debug("Including source: " + sourceAtt);
}
-
return source;
- } catch (MalformedURLException e) {
- String message = "Can't parse URL " + sourceAtt;
+ } catch (IllegalArgumentException e) {
+ String message = "Invalid xinclude URI " + sourceAtt;
this.logger.error(message, e);
throw new ProcessingException(message, e);
- }
+ } catch (IOException e) {
+ String message = "Can't resolve URL " + sourceAtt;
+ this.logger.error(message, e);
+ throw new ProcessingException(message, e);
+ }
}
public void endElement(String uri, String localName, String name)
@@ -418,7 +493,7 @@
}
} else if (isEvaluatingContent()) {
// Copy other elements through when appropriate:
- getXMLConsumer().endElement(uri, localName, name);
+ getContentHandler().endElement(uri, localName, name);
}
}
@@ -427,7 +502,7 @@
if (isEvaluatingContent()) {
// removed xinclude namespace from result document
if (!uri.equals(XINCLUDE_NAMESPACE_URI)) {
- getXMLConsumer().startPrefixMapping(prefix, uri);
+ getContentHandler().startPrefixMapping(prefix, uri);
}
namespaces.put(prefix, uri);
}
@@ -435,20 +510,20 @@
public void endPrefixMapping(String prefix) throws SAXException {
if (isEvaluatingContent()) {
- getXMLConsumer().endPrefixMapping(prefix);
+ getContentHandler().endPrefixMapping(prefix);
namespaces.remove(prefix);
}
}
public void startCDATA() throws SAXException {
if (isEvaluatingContent()) {
- getXMLConsumer().startCDATA();
+ getLexicalHandler().startCDATA();
}
}
public void endCDATA() throws SAXException {
if (isEvaluatingContent()) {
- getXMLConsumer().startCDATA();
+ getLexicalHandler().startCDATA();
}
}
@@ -463,27 +538,27 @@
public void startEntity(String name) throws SAXException {
if (isEvaluatingContent()) {
- getXMLConsumer().startEntity(name);
+ getLexicalHandler().startEntity(name);
}
}
public void endEntity(String name) throws SAXException {
if (isEvaluatingContent()) {
- getXMLConsumer().endEntity(name);
+ getLexicalHandler().endEntity(name);
}
}
public void characters(char[] ch, int start, int length)
throws SAXException {
if (isEvaluatingContent()) {
- getXMLConsumer().characters(ch, start, length);
+ getContentHandler().characters(ch, start, length);
}
}
public void ignorableWhitespace(char[] ch, int start, int length)
throws SAXException {
if (isEvaluatingContent()) {
- getXMLConsumer().ignorableWhitespace(ch, start, length);
+ getContentHandler().ignorableWhitespace(ch, start, length);
}
}
@@ -494,7 +569,7 @@
public void processingInstruction(String target, String data)
throws SAXException {
if (isEvaluatingContent()) {
- getXMLConsumer().processingInstruction(target, data);
+ getContentHandler().processingInstruction(target, data);
}
}
@@ -504,12 +579,12 @@
}
this.locator = locator;
- getXMLConsumer().setDocumentLocator(locator);
+ getContentHandler().setDocumentLocator(locator);
}
public void skippedEntity(String name) throws SAXException {
if (isEvaluatingContent()) {
- getXMLConsumer().skippedEntity(name);
+ getContentHandler().skippedEntity(name);
}
}
Modified:
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/xpointer/XPointerContext.java
===================================================================
---
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/xpointer/XPointerContext.java 2009-09-18
23:00:33 UTC (rev 15629)
+++
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/xpointer/XPointerContext.java 2009-09-19
00:22:07 UTC (rev 15630)
@@ -26,10 +26,11 @@
import javax.xml.namespace.NamespaceContext;
-import org.apache.cocoon.pipeline.component.sax.XMLConsumer;
+import org.apache.cocoon.pipeline.component.sax.SAXConsumer;
import org.apache.cocoon.pipeline.util.dom.DOMUtils;
import org.apache.commons.logging.Log;
import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -47,15 +48,16 @@
private String xPointer;
- private URL source;
+ private InputSource source;
+
- private XMLConsumer xmlConsumer;
+ private SAXConsumer xmlConsumer;
private Log logger;
private Document document;
- public XPointerContext(String xPointer, URL source, XMLConsumer xmlConsumer, Log
logger) {
+ public XPointerContext(String xPointer, InputSource source, SAXConsumer xmlConsumer,
Log logger) {
this.xPointer = xPointer;
this.source = source;
this.xmlConsumer = xmlConsumer;
@@ -66,11 +68,11 @@
return xPointer;
}
- public URL getSource() {
+ public InputSource getSource() {
return source;
}
- public XMLConsumer getXmlConsumer() {
+ public SAXConsumer getXmlConsumer() {
return xmlConsumer;
}
Modified:
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/util/dom/DOMStreamer.java
===================================================================
---
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/util/dom/DOMStreamer.java 2009-09-18
23:00:33 UTC (rev 15629)
+++
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/util/dom/DOMStreamer.java 2009-09-19
00:22:07 UTC (rev 15630)
@@ -20,7 +20,7 @@
import java.util.Map.Entry;
-import org.apache.cocoon.pipeline.component.sax.XMLConsumer;
+import org.apache.cocoon.pipeline.component.sax.SAXConsumer;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.EntityReference;
@@ -34,14 +34,14 @@
final class DOMStreamer {
- private XMLConsumer xmlConsumer;
+ private SAXConsumer xmlConsumer;
private ElementInfo currentElementInfo;
/** Counter used when generating new namespace prefixes. */
private int newPrefixCounter;
- public DOMStreamer(XMLConsumer xmlConsumer) {
+ public DOMStreamer(SAXConsumer xmlConsumer) {
this.xmlConsumer = xmlConsumer;
}
Modified:
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/util/dom/DOMUtils.java
===================================================================
---
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/util/dom/DOMUtils.java 2009-09-18
23:00:33 UTC (rev 15629)
+++
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/util/dom/DOMUtils.java 2009-09-19
00:22:07 UTC (rev 15630)
@@ -25,9 +25,10 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.cocoon.pipeline.component.sax.XMLConsumer;
+import org.apache.cocoon.pipeline.component.sax.SAXConsumer;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -39,18 +40,18 @@
// instances are not allowed
}
- public static Document toDOM(URL source) throws SAXException, IOException {
+ public static Document toDOM(InputSource source) throws SAXException, IOException {
DocumentBuilder documentBuilder;
try {
documentBuilder = DBF.newDocumentBuilder();
- return documentBuilder.parse(source.openStream());
+ return documentBuilder.parse(source);
} catch (ParserConfigurationException e) {
throw new SAXException("Error during XPointer evaluation while trying to
load "
+ source, e);
}
}
- public static void stream(Node node, XMLConsumer xmlConsumer) throws SAXException {
+ public static void stream(Node node, SAXConsumer xmlConsumer) throws SAXException {
new DOMStreamer(xmlConsumer).stream(node);
}