You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2008/01/13 02:37:40 UTC
svn commit: r611520 - in /cocoon/branches/BRANCH_2_1_X:
src/java/org/apache/cocoon/transformation/IncludeTransformer.java status.xml
Author: joerg
Date: Sat Jan 12 17:37:39 2008
New Revision: 611520
URL: http://svn.apache.org/viewvc?rev=611520&view=rev
Log:
COCOON-2149: Add capability to IncludeTransformer to strip the root element from included XML content.
Modified:
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/IncludeTransformer.java
cocoon/branches/BRANCH_2_1_X/status.xml
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/IncludeTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/IncludeTransformer.java?rev=611520&r1=611519&r2=611520&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/IncludeTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/IncludeTransformer.java Sat Jan 12 17:37:39 2008
@@ -85,6 +85,16 @@
* relative to the source document location. This is consistent with
* {@link XIncludeTransformer} behavior, but differs from {@link CIncludeTransformer}.
*
+ * <h3>Root Element Stripping</h3>
+ * <p>The root element of included content may be automatically stripped by specifying
+ * <code>strip-root="true"</code> on the <code>include</code> element. This is the same
+ * functionality as provided by {@link org.apache.cocoon.transformation.CIncludeTransformer}.
+ *
+ * <p>Example:</p>
+ * <pre>
+ * <i:include xmlns:i="http://apache.org/cocoon/include/1.0"
+ * src="cocoon://path/to/include" strip-root="true"/>
+ * </pre>
*
* <h3>Parameters Passing</h3>
* <p>Parameters to be passed to the included sources can be specified in two ways:
@@ -195,6 +205,9 @@
/** <p>The name of the parse attribute indicating type of included source processing: xml or text.</p> */
private static final String PARSE_ATTRIBUTE = "parse";
+ /** <p>The name of the strip-root attribute indicating that the root element of included xml source should be stripped.</p> */
+ private static final String STRIP_ROOT_ATTRIBUTE = "strip-root";
+
/** <p>The name of the attribute indicating the parameter name.</p> */
private static final String NAME_ATTRIBUTE = "name";
@@ -482,6 +495,9 @@
/** The mime type hint to the {@link org.apache.excalibur.xmlizer.XMLizer} when parsing the source content. */
protected String mimeType;
+ /** The flag indicating whether to strip the root element. */
+ private boolean stripRoot;
+
/** The buffer collecting fallback content. */
protected SaxBuffer fallback;
@@ -571,11 +587,11 @@
new IncludeXMLPipe(getLogger(), contentHandler, lexicalHandler,
recursive, recursiveParallel? parallel: false, recursiveParallel));
} else if (this.parse) {
- SourceUtil.toSAX(manager, source, this.mimeType,
- new IncludeXMLConsumer(contentHandler, lexicalHandler));
+ IncludeXMLConsumer includeXMLConsumer = new IncludeXMLConsumer(contentHandler, lexicalHandler);
+ includeXMLConsumer.setIgnoreRootElement(stripRoot);
+ SourceUtil.toSAX(manager, source, this.mimeType, includeXMLConsumer);
} else {
- SourceUtil.toCharacters(source, "utf-8",
- contentHandler);
+ SourceUtil.toCharacters(source, "utf-8", contentHandler);
}
if (getLogger().isDebugEnabled()) {
@@ -812,6 +828,10 @@
} else if (element.mimeType == null) {
element.mimeType = "text/xml";
}
+
+ /* Defaults to false */
+ String stripRoot = atts.getValue(STRIP_ROOT_ATTRIBUTE);
+ element.stripRoot = Boolean.valueOf(stripRoot).booleanValue();
/* Ignore nested content */
push(new NOPRecorder(){});
Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=611520&r1=611519&r2=611520&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Sat Jan 12 17:37:39 2008
@@ -182,6 +182,9 @@
<changes>
<release version="2.1.12" date="TBD">
+ <action dev="JH" type="add" fixes-bug="COCOON-2149" due-to="Ellis Pritchard" due-to-email="ellis@nukinetics.com">
+ Add capability to IncludeTransformer to strip the root element from included XML content.
+ </action>
<action dev="CZ" type="fix" fixes-bug="COCOON-2159">
Auth Block: Fix error in PipelineSecurityHandler which prevented additional data to be added
to the user properties.