You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2004/09/22 13:56:13 UTC
svn commit: rev 47045 - in cocoon/branches/BRANCH_2_1_X/src: blocks/databases/java/org/apache/cocoon/transformation blocks/linkrewriter/java/org/apache/cocoon/transformation blocks/portal/java/org/apache/cocoon/portal/coplets/basket blocks/portal/java/org/apache/cocoon/portal/transformation blocks/repository/java/org/apache/cocoon/transformation blocks/session-fw/java/org/apache/cocoon/webapps/session/transformation java/org/apache/cocoon/transformation
Author: vgritsenko
Date: Wed Sep 22 04:56:13 2004
New Revision: 47045
Modified:
cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/transformation/SQLTransformer.java
cocoon/branches/BRANCH_2_1_X/src/blocks/linkrewriter/java/org/apache/cocoon/transformation/VariableRewriterTransformer.java
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplets/basket/BasketTransformer.java
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
cocoon/branches/BRANCH_2_1_X/src/blocks/repository/java/org/apache/cocoon/transformation/SourcePropsWritingTransformer.java
cocoon/branches/BRANCH_2_1_X/src/blocks/session-fw/java/org/apache/cocoon/webapps/session/transformation/SessionPreTransformer.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/JPathTransformer.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/SimpleFormTransformer.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java
Log:
AbstractSAXTransformer cleanup:
Make sure namespaceURI is not null, add javadoc.
Make sure defaultNamespaceURI is not null, add javadoc.
Implementations of AbstractSAXTransformer should set defaultNamespaceURI, not namespaceURI.
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/transformation/SQLTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/transformation/SQLTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/transformation/SQLTransformer.java Wed Sep 22 04:56:13 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed 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
- *
+ *
* 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.
@@ -171,10 +171,10 @@
/** Encoding we use for CLOB field */
protected String clobEncoding;
-
+
/** The default encoding for xml */
protected String xmlDefaultEncoding;
-
+
/**
* Constructor
*/
@@ -182,7 +182,7 @@
this.format = new Properties();
this.format.put(OutputKeys.METHOD, "text");
this.format.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
- this.namespaceURI = NAMESPACE;
+ this.defaultNamespaceURI = NAMESPACE;
}
/** The connection used by all top level queries */
@@ -866,7 +866,7 @@
protected HashMap outParametersNames = null;
/** Handling of case of column names in results */
- protected String columnCase;
+ protected String columnCase;
protected Query( SQLTransformer transformer, int query_index ) {
this.transformer = transformer;
@@ -1127,7 +1127,7 @@
protected String getColumnValue( int i ) throws SQLException {
int numberOfChar = 1024;
String retval;
-
+
if (rs.getMetaData().getColumnType(i) == java.sql.Types.DOUBLE) {
retval = SQLTransformer.getStringValue( rs.getBigDecimal( i ) );
} else if (rs.getMetaData().getColumnType(i) == java.sql.Types.CLOB) {
@@ -1145,7 +1145,7 @@
}
retval = buffer.toString();
} else {
- retval = SQLTransformer.getStringValue( rs.getObject( i ) );
+ retval = SQLTransformer.getStringValue( rs.getObject( i ) );
}
return retval;
}
@@ -1211,12 +1211,12 @@
if ( value.length() > 0 && value.charAt(0) == '<') {
try {
String stripped = value;
-
- // Strip off the XML Declaration if there is one!
+
+ // Strip off the XML Declaration if there is one!
if( stripped.startsWith( "<?xml " ) ) {
stripped = stripped.substring( stripped.indexOf( "?>" ) + 2 );
}
-
+
if (transformer.parser == null) {
transformer.parser = (SAXParser)manager.lookup(SAXParser.ROLE);
}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/linkrewriter/java/org/apache/cocoon/transformation/VariableRewriterTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/linkrewriter/java/org/apache/cocoon/transformation/VariableRewriterTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/linkrewriter/java/org/apache/cocoon/transformation/VariableRewriterTransformer.java Wed Sep 22 04:56:13 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed 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
- *
+ *
* 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.
@@ -35,7 +35,7 @@
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
-/**
+/**
* Rewrites URIs in links to a value determined by an InputModule.
* The URI scheme identifies the InputModule to use, and the rest of the URI is
* used as the attribute name.
@@ -137,10 +137,10 @@
* @version CVS $Id$
*/
public class VariableRewriterTransformer
- extends AbstractSAXTransformer implements Initializable, Disposable
-{
+ extends AbstractSAXTransformer
+ implements Initializable, Disposable {
- private static String NAMESPACE="";
+ private static final String NAMESPACE = "";
/** A list of attributes considered 'links' */
private Set linkAttrs;
@@ -150,11 +150,11 @@
private Set outSchemes;
/** Configuration passed to the component once through configure(). */
- private Configuration origConf;
+ private Configuration origConf;
/** Derivation of origConf with variables obtained from setup() parameters.
* Recreated once per invocation. */
- private Configuration conf;
+ private Configuration conf;
private InputModuleHelper modHelper;
@@ -169,14 +169,14 @@
super.configure(conf);
this.origConf = conf;
}
-
+
/**
* Initiate resources prior to this component becoming active.
*/
public void initialize() throws Exception {
- this.namespaceURI = NAMESPACE;
+ this.defaultNamespaceURI = NAMESPACE;
this.modHelper = new InputModuleHelper();
- modHelper.setup(this.manager);
+ this.modHelper.setup(this.manager);
}
/**
@@ -231,7 +231,7 @@
String name,
String raw,
Attributes attr)
- throws ProcessingException, IOException, SAXException
+ throws ProcessingException, IOException, SAXException
{
Attributes newAttrs = null;
boolean matched = false;
@@ -339,7 +339,7 @@
// Note: configure() and initialize() are not called after every
//recycle, so don't null origConf
}
-
+
/* (non-Javadoc)
* @see org.apache.avalon.framework.activity.Disposable#dispose()
*/
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplets/basket/BasketTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplets/basket/BasketTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplets/basket/BasketTransformer.java Wed Sep 22 04:56:13 2004
@@ -1,12 +1,12 @@
/*
* Copyright 2004,2004 The Apache Software Foundation.
- *
+ *
* Licensed 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
- *
+ *
* 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.
@@ -33,36 +33,35 @@
/**
* This transformer supports the basket feature. It can generate links to
* add content and to upload files into the basket.
- *
- * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- *
- * @version CVS $Id: BasketTransformer.java,v 1.2 2004/03/05 13:02:11 bdelacretaz Exp $
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id$
*/
public class BasketTransformer
extends AbstractSAXTransformer {
/** The namespace URI to listen for. */
public static final String NAMESPACE_URI = "http://apache.org/cocoon/portal/basket/1.0";
-
+
/** Element to add a link */
protected static final String ADD_ITEM_ELEMENT = "add-item";
-
+
/** Element to upload an item */
protected static final String UPLOAD_ITEM_ELEMENT = "upload-item";
-
+
/** Element for the upload form */
protected static final String UPLOAD_FORM_ELEMENT = "upload-form";
/** Upload element list */
protected List uploadElements = new ArrayList();
-
+
/**
* Constructor
*/
public BasketTransformer() {
- this.namespaceURI = NAMESPACE_URI;
+ this.defaultNamespaceURI = NAMESPACE_URI;
}
-
+
/* (non-Javadoc)
* @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
*/
@@ -85,7 +84,7 @@
this.uploadElements = new ArrayList();
}
}
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.transformation.AbstractSAXTransformer#startTransformingElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/
@@ -112,9 +111,11 @@
} finally {
this.manager.release(service);
}
+
} else if ( UPLOAD_ITEM_ELEMENT.equals(name) ) {
this.uploadElements.add(attr.getValue("name"));
this.startElement("", "input", "input", attr);
+
} else if ( UPLOAD_FORM_ELEMENT.equals(name) ) {
AttributesImpl ai = new AttributesImpl(attr);
PortalService service = null;
@@ -147,7 +148,7 @@
this.endElement("", "input", "input");
}
}
+
}
}
-
-}
\ No newline at end of file
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java Wed Sep 22 04:56:13 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2002,2004 The Apache Software Foundation.
- *
+ *
* Licensed 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
- *
+ *
* 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.
@@ -31,32 +31,33 @@
* elements replaces the URI form the attribute which is specified within
* an attribute called "attribute" and renames the element as specified
* within an attribute called "element".
- *
+ *
* Example:<br><br>
- *
+ *
* <pre>
* <root xmlns:ev="http://apache.org/cocoon/portal/eventlink/1.0">
* <ev:eventlink href="http://eventlinkexample" element="a" attribute="href">linktext</ev:eventlink>
* </root><br></pre>
*
* will be replaced with something like:<br><br>
- *
+ *
* <pre>
* <root>
* <a href="portal?cocoon-portal-event=8">linktext</a>
* </root><br></pre>
- *
- * The transformer will create two CopletLinkEvents and insert corresponding links
- * to them to the XML instead of "http://eventlinkexample". If such a link is pressed
+ *
+ * The transformer will create two CopletLinkEvents and insert corresponding links
+ * to them to the XML instead of "http://eventlinkexample". If such a link is pressed
* the corresponding CopletLinkEvent is sent to the Subscribers to be handled.<br>
* Please see also the documentation of superclass AbstractCopletTransformer for how
* the coplet instance data are acquired.
- *
+ *
* @author <a href="mailto:gernot.koller@rizit.at">Gernot Koller</a>
- *
- * @version CVS $Id: NewEventLinkTransformer.java,v 1.7 2004/03/16 09:16:59 cziegeler Exp $
+ *
+ * @version CVS $Id$
*/
public class NewEventLinkTransformer extends AbstractCopletTransformer {
+
/**
* The namespace URI to listen for.
*/
@@ -79,7 +80,7 @@
public static final String ELEMENT_ATTR = "element";
/**
- * Used to store elements' name between startTransformingElement and endTransformingElement.
+ * Used to store elements' name between startTransformingElement and endTransformingElement.
*/
private Stack elementStack = new Stack();
@@ -95,7 +96,7 @@
* @see java.lang.Object#Object()
*/
public NewEventLinkTransformer() {
- this.namespaceURI = NAMESPACE_URI;
+ this.defaultNamespaceURI = NAMESPACE_URI;
}
/**
@@ -227,11 +228,10 @@
* @param portalEvent value of the "cocoon-portal-event" parameter
* @throws SAXException if sending the SAX events failed
*/
- private void sendHiddenFields(
- ContentHandler contentHandler,
- String portalAction,
- String portalEvent)
- throws SAXException {
+ private void sendHiddenFields(ContentHandler contentHandler,
+ String portalAction,
+ String portalEvent)
+ throws SAXException {
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute("", "type", "type", "CDATA", "hidden");
attributes.addAttribute(
@@ -261,7 +261,7 @@
* @see org.apache.cocoon.transformation.AbstractSAXTransformer#endTransformingElement(String, String, String)
*/
public void endTransformingElement(String uri, String name, String raw)
- throws SAXException {
+ throws SAXException {
String elementName = (String) elementStack.pop();
contentHandler.endElement("", elementName, elementName);
}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/repository/java/org/apache/cocoon/transformation/SourcePropsWritingTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/repository/java/org/apache/cocoon/transformation/SourcePropsWritingTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/repository/java/org/apache/cocoon/transformation/SourcePropsWritingTransformer.java Wed Sep 22 04:56:13 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed 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
- *
+ *
* 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.
@@ -33,7 +33,7 @@
/**
* This transformer allows you to set and remove properties on an InspectableSource.
- *
+ *
* <p>Input XML document example:</p>
* <pre>
* <page>
@@ -50,12 +50,12 @@
* ...
* </page>
* </pre>
- *
+ *
* @author <a href="mailto:gcasper@s-und-n.de">Guido Casper</a>
- * @version CVS $Id: SourcePropsWritingTransformer.java,v 1.5 2004/03/05 13:02:22 bdelacretaz Exp $
+ * @version CVS $Id$
*/
public class SourcePropsWritingTransformer
- extends AbstractSAXTransformer {
+ extends AbstractSAXTransformer {
public static final String SPWT_URI = "http://apache.org/cocoon/propwrite/1.0";
@@ -73,13 +73,13 @@
private static final int STATE_REMOVE = 4;
private int state;
-
+
/**
* Constructor
* Set the namespace
*/
public SourcePropsWritingTransformer() {
- this.namespaceURI = SPWT_URI;
+ this.defaultNamespaceURI = SPWT_URI;
}
public void recycle() {
@@ -223,7 +223,7 @@
this.state = STATE_PATCH;
this.stack.push(this.endRecording());
this.stack.push(REMOVE_ELEMENT);
-
+
// default
} else {
super.endTransformingElement(uri, name, raw);
@@ -234,7 +234,7 @@
}
}
- private void setProperty(String src, Element element)
+ private void setProperty(String src, Element element)
throws ProcessingException, IOException, SAXException {
if (src != null && element != null) {
try {
@@ -254,10 +254,10 @@
this.getLogger().error("Error setting properties on "+src);
}
}
-
- private void removeProperty(String src, Element element)
- throws ProcessingException, IOException, SAXException {
-
+
+ private void removeProperty(String src, Element element)
+ throws ProcessingException, IOException, SAXException {
+
if (src != null && element != null) {
try {
Source source = this.resolver.resolveURI(src);
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/session-fw/java/org/apache/cocoon/webapps/session/transformation/SessionPreTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/session-fw/java/org/apache/cocoon/webapps/session/transformation/SessionPreTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/session-fw/java/org/apache/cocoon/webapps/session/transformation/SessionPreTransformer.java Wed Sep 22 04:56:13 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed 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
- *
+ *
* 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.
@@ -32,10 +32,10 @@
* pipeline.
*
* @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
- * @version CVS $Id: SessionPreTransformer.java,v 1.4 2004/03/19 14:16:54 cziegeler Exp $
+ * @version CVS $Id$
*/
public class SessionPreTransformer
-extends AbstractSessionTransformer {
+ extends AbstractSessionTransformer {
/*
* The XML commands
@@ -61,7 +61,7 @@
protected int processingGetXML;
public SessionPreTransformer() {
- this.namespaceURI = SessionConstants.SESSION_NAMESPACE_URI;
+ this.defaultNamespaceURI = SessionConstants.SESSION_NAMESPACE_URI;
}
/**
@@ -90,11 +90,9 @@
*/
public void endElement(String uri, String name, String raw) throws SAXException {
super.endElement(uri, name, raw);
- if (uri != null
- && namespaceURI != null
- && uri.equals(namespaceURI) == true
+ if (namespaceURI.equals(uri)
&& this.processingGetXML > 0
- && name.equals(GETXML_ELEMENT) == true) {
+ && name.equals(GETXML_ELEMENT)) {
this.processingGetXML--;
this.ignoreEventsCount--;
this.ignoreHooksCount--;
@@ -111,11 +109,9 @@
String raw,
Attributes attr)
throws SAXException {
- if (uri != null
- && namespaceURI != null
- && uri.equals(namespaceURI) == true
+ if (namespaceURI.equals(uri)
&& this.processingGetXML > 0
- && name.equals(GETXML_ELEMENT) == true) {
+ && name.equals(GETXML_ELEMENT)) {
this.processingGetXML++;
this.ignoreEventsCount++;
this.ignoreHooksCount++;
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java Wed Sep 22 04:56:13 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed 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
- *
+ *
* 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.
@@ -57,65 +57,73 @@
import org.xml.sax.helpers.AttributesImpl;
/**
- * This class is the basis for all transformers. It provides various useful
- * methods and hooks for implementing own custom transformers.<p>
- * <p>
- * The basic behaviour of each transformer consists of the following four parts:
- * <ul>
- * <li>Listen for specific events with a given namespace</li>
- * <li>Collect information via these events</li>
- * <li>Process the information</li>
- * <li>Create new events from the processed information</li>
- * </ul><p>
- * For all these four purposes the AbstractSAXTransformer offers some
- * powerful methods and hooks:
- * <p>
- * Namespace handling<p>
- * By setting the instance variable namespaceURI to the namespace the
- * events are filtered and only events with this namespace are send to
- * the two hooks startTransformingElement() and endTransformingElement().<p>
- * It is possible to override the default
- * namespace for the transformer by specifying the parameter "namespaceURI"
- * in the pipeline. This avoids possible namespace collisions.<p>
+ * This class is the basis for all transformers. It provides various useful
+ * methods and hooks for implementing own custom transformers.
+ *
+ * <p>The basic behaviour of each transformer consists of the following four
+ * parts:</p>
+ * <ul>
+ * <li>Listen for specific events with a given namespace</li>
+ * <li>Collect information via these events</li>
+ * <li>Process the information</li>
+ * <li>Create new events from the processed information</li>
+ * </ul>
*
- * Recording of information<p>
- * There are several methods for recording information, e.g. startRecording(),
- * startTextRecording() etc. These methods collect information from the xml
- * stream for further processing.<p>
+ * <p>For all these four purposes the AbstractSAXTransformer offers some
+ * powerful methods and hooks:</p>
*
- * Creating new events<p>
- * New events can be easily created with the <code>sendEvents()</code>
- * method, the <code>sendStartElementEvent()</code> methods, the <code>sendEndElementEvent()</code>
- * method or the <code>sendTextEvent()</code> method.<p>
+ * <h3>Namespace handling</h3>
+ * By setting the instance variable namespaceURI to the namespace the
+ * events are filtered and only events with this namespace are send to
+ * the two hooks: <code>startTransformingElement</code> and
+ * <code>endTransformingElement</code>. It is possible to override the default
+ * namespace for the transformer by specifying the parameter "namespaceURI"
+ * in the pipeline. This avoids possible namespace collisions.
*
- * Initialization<p>
- * Before the document is processed the setupTransforming() hook is invoked.
+ * <h3>Recording of information</h3>
+ * There are several methods for recording information, e.g. startRecording(),
+ * startTextRecording() etc. These methods collect information from the xml
+ * stream for further processing.
*
+ * <h3>Creating new events</h3>
+ * New events can be easily created with the <code>sendEvents()</code>
+ * method, the <code>sendStartElementEvent()</code> methods, the
+ * <code>sendEndElementEvent()</code> method or the
+ * <code>sendTextEvent()</code> method.
+ *
+ * <h3>Initialization</h3>
+ * Before the document is processed the <code>setupTransforming</code> hook
+ * is invoked.
*
* @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
* @version CVS $Id$
*/
public abstract class AbstractSAXTransformer
-extends AbstractTransformer
-implements Serviceable, Configurable, Recyclable {
+ extends AbstractTransformer
+ implements Serviceable, Configurable, Recyclable {
- /** Controlls SAX event handling.
- * If set to true all whitespace events are ignored.
+ /**
+ * Controlls SAX event handling.
+ * If set to true all whitespace events are ignored.
*/
protected boolean ignoreWhitespaces;
- /** Controlls SAX event handling
- * If set to true all characters events containing only whitespaces
- * are ignored.
+
+ /**
+ * Controlls SAX event handling.
+ * If set to true all characters events containing only whitespaces
+ * are ignored.
*/
protected boolean ignoreEmptyCharacters;
- /** Controlls SAX event handling
+ /**
+ * Controlls SAX event handling.
* If this is incremented all events are not forwarded to the next
* pipeline component, but the hooks are still called.
*/
protected int ignoreEventsCount;
- /** Controlls SAX event handling
+ /**
+ * Controlls SAX event handling.
* If this is greater than zero, the hooks are not called. Attention,
* make sure, that you decrement this counter properly as your hooks are
* not called anymore!
@@ -123,25 +131,31 @@
protected int ignoreHooksCount;
/**
- * The used namespace for the SAX filtering.
- * This is either the defaultNamespaceURI or the value
- * set by the "namespaceURI" parameter for the pipeline.
+ * The namespace used by the transformer for the SAX events filtering.
+ * This either equals to the {@link #defaultNamespaceURI} or to the value
+ * set by the <code>namespaceURI</code> sitemap parameter for the pipeline.
+ * Must never be null.
*/
- protected String namespaceURI;
+ protected String namespaceURI;
/**
* This is the default namespace used by the transformer.
- * It should be set in the constructor.
+ * Implementations should set its value in the constructor.
+ * Must never be null.
+ */
+ protected String defaultNamespaceURI;
+
+ /**
+ * A stack for collecting information.
+ * The stack is important for collection information especially when
+ * the tags can be nested.
*/
- protected String defaultNamespaceURI;
+ protected Stack stack = new Stack();
- /** A stack for collecting information.
- * The stack is important for collection information especially when
- * the tags can be nested.
+ /**
+ * The stack of current used recorders
*/
- protected Stack stack = new Stack();
- /** The stack of current used recorders */
- protected Stack recorderStack = new Stack();
+ protected Stack recorderStack = new Stack();
/** The current Request object */
protected Request request;
@@ -163,22 +177,24 @@
/** Are we already initialized for the current request? */
private boolean isInitialized;
- /** Empty attributes (for performance). This can be used
- * do create own attributes, but make sure to clean them
- * afterwords.
+ /**
+ * Empty attributes (for performance). This can be used
+ * do create own attributes, but make sure to clean them
+ * afterwords.
*/
protected AttributesImpl emptyAttributes = new AttributesImpl();
/** The namespaces and their prefixes */
private List namespaces = new ArrayList(5);
+
/** The current prefix for our namespace */
private String ourPrefix;
-
+
+
/* (non-Javadoc)
* @see Configurable#configure(Configuration)
*/
- public void configure(Configuration configuration)
- throws ConfigurationException {
+ public void configure(Configuration configuration) throws ConfigurationException {
}
/* (non-Javadoc)
@@ -187,19 +203,19 @@
public void setup(SourceResolver resolver,
Map objectModel,
String src,
- Parameters par)
- throws ProcessingException,
- SAXException,
- IOException {
+ Parameters params)
+ throws ProcessingException, SAXException, IOException {
+
if (getLogger().isDebugEnabled()) {
getLogger().debug("Setup resolver=" + resolver +
- ", objectModel="+objectModel+
- ", src="+src+
- ", parameters="+par);
+ ", objectModel=" + objectModel +
+ ", src=" + src +
+ ", parameters=" + params);
}
+ // defaultNamespaceURI should never be null
if (this.defaultNamespaceURI == null) {
- this.defaultNamespaceURI = this.namespaceURI;
+ this.defaultNamespaceURI = "";
}
this.objectModel = objectModel;
@@ -207,13 +223,13 @@
this.response = ObjectModelHelper.getResponse(objectModel);
this.context = ObjectModelHelper.getContext(objectModel);
this.resolver = resolver;
- this.parameters = par;
+ this.parameters = params;
this.source = src;
this.isInitialized = false;
// get the current namespace
- this.namespaceURI = this.parameters.getParameter("namespaceURI",
- this.defaultNamespaceURI);
+ this.namespaceURI = params.getParameter("namespaceURI",
+ this.defaultNamespaceURI);
this.ignoreHooksCount = 0;
this.ignoreEventsCount = 0;
@@ -226,6 +242,7 @@
*/
public void recycle() {
super.recycle();
+ this.namespaceURI = null;
this.objectModel = null;
this.request = null;
this.response = null;
@@ -254,7 +271,7 @@
*/
public void startDocument()
throws SAXException {
- if ( !this.isInitialized ) {
+ if (!this.isInitialized) {
try {
this.setupTransforming();
} catch (ProcessingException local) {
@@ -290,18 +307,14 @@
String raw,
Attributes attr)
throws SAXException {
- if (uri != null
- && namespaceURI != null
- && uri.equals(namespaceURI) == true
- && this.ignoreHooksCount == 0) {
-
+ if (namespaceURI.equals(uri) && ignoreHooksCount == 0) {
// this is our namespace:
try {
- this.startTransformingElement(uri, name, raw, attr);
- } catch (ProcessingException pException) {
- throw new SAXException("ProcessingException: " + pException, pException);
- } catch (IOException ioe) {
- throw new SAXException("Exception occured during processing: " + ioe, ioe);
+ startTransformingElement(uri, name, raw, attr);
+ } catch (ProcessingException e) {
+ throw new SAXException("ProcessingException: " + e, e);
+ } catch (IOException e) {
+ throw new SAXException("IOException occured during processing: " + e, e);
}
} else {
if (ignoreEventsCount == 0) {
@@ -310,25 +323,21 @@
}
}
-
/**
* Process the SAX event.
* The namespace of the event is checked. If it is the defined namespace
* for this transformer the endTransformingElement() hook is called.
*/
- public void endElement(String uri, String name, String raw) throws SAXException {
- if (uri != null
- && namespaceURI != null
- && uri.equals(namespaceURI) == true
- && this.ignoreHooksCount == 0) {
-
+ public void endElement(String uri, String name, String raw)
+ throws SAXException {
+ if (namespaceURI.equals(uri) && this.ignoreHooksCount == 0) {
// this is our namespace:
try {
- this.endTransformingElement(uri, name, raw);
+ endTransformingElement(uri, name, raw);
} catch (ProcessingException e) {
throw new SAXException("ProcessingException: " + e, e);
- } catch (IOException ioe) {
- throw new SAXException("Exception occured during processing: " + ioe, ioe);
+ } catch (IOException e) {
+ throw new SAXException("IOException occured during processing: " + e, e);
}
} else {
if (ignoreEventsCount == 0) {
@@ -343,7 +352,7 @@
public void characters(char[] p0, int p1, int p2)
throws SAXException {
if (this.ignoreEventsCount == 0) {
- if (this.ignoreEmptyCharacters == true) {
+ if (this.ignoreEmptyCharacters) {
String value = new String(p0, p1, p2);
if (value.trim().length() > 0) {
super.characters(p0, p1, p2);
@@ -364,11 +373,13 @@
}
}
+
/*
* Recording of events.
* With this method all events are not forwarded to the next component in the pipeline.
* They are recorded to create a document fragment.
*/
+
private LexicalHandler originalLexicalHandler;
private ContentHandler originalContentHandler;
@@ -377,13 +388,13 @@
* Do not invoke this method directly.
*/
protected void addRecorder(XMLConsumer recorder) {
- if (this.recorderStack.empty() == true) {
+ if (this.recorderStack.empty()) {
// redirect if first (top) recorder
this.originalLexicalHandler = this.lexicalHandler;
this.originalContentHandler = this.contentHandler;
}
- this.setContentHandler(recorder);
- this.setLexicalHandler(recorder);
+ setContentHandler(recorder);
+ setLexicalHandler(recorder);
this.recorderStack.push(recorder);
}
@@ -395,15 +406,16 @@
Object recorder = this.recorderStack.pop();
if (this.recorderStack.empty() == true) {
// undo redirect if no recorder any more
- this.setContentHandler(originalContentHandler);
- this.setLexicalHandler(originalLexicalHandler);
+ setContentHandler(originalContentHandler);
+ setLexicalHandler(originalLexicalHandler);
this.originalLexicalHandler = null;
this.originalContentHandler = null;
} else {
- XMLConsumer next = (XMLConsumer)recorderStack.peek();
- this.setContentHandler(next);
- this.setLexicalHandler(next);
+ XMLConsumer next = (XMLConsumer) recorderStack.peek();
+ setContentHandler(next);
+ setLexicalHandler(next);
}
+
return recorder;
}
@@ -415,7 +427,7 @@
*/
public void startSAXRecording()
throws SAXException {
- this.addRecorder(new SaxBuffer());
+ addRecorder(new SaxBuffer());
}
/**
@@ -426,7 +438,7 @@
*/
public XMLizable endSAXRecording()
throws SAXException {
- return (XMLizable)this.removeRecorder();
+ return (XMLizable) this.removeRecorder();
}
/**
@@ -439,8 +451,7 @@
if (getLogger().isDebugEnabled()) {
getLogger().debug("Start text recording");
}
- XMLConsumer recorder = new TextRecorder();
- addRecorder(recorder);
+ addRecorder(new TextRecorder());
sendStartPrefixMapping();
}
@@ -453,7 +464,7 @@
throws SAXException {
sendEndPrefixMapping();
- TextRecorder recorder = (TextRecorder)this.removeRecorder();
+ TextRecorder recorder = (TextRecorder) removeRecorder();
String text = recorder.getText();
if (getLogger().isDebugEnabled()) {
getLogger().debug("End text recording. Text=" + text);
@@ -485,7 +496,7 @@
public String endSerializedXMLRecording()
throws SAXException, ProcessingException {
DocumentFragment fragment = endRecording();
- String text = XMLUtils.serializeNode(fragment, (Properties)this.stack.pop());
+ String text = XMLUtils.serializeNode(fragment, (Properties) this.stack.pop());
if (getLogger().isDebugEnabled()) {
getLogger().debug("End serialized XML recording. XML=" + text);
}
@@ -504,8 +515,7 @@
if (getLogger().isDebugEnabled()) {
getLogger().debug("Start parameters recording");
}
- XMLConsumer recorder = new ParametersRecorder();
- addRecorder(recorder);
+ addRecorder(new ParametersRecorder());
sendStartPrefixMapping();
}
@@ -521,7 +531,7 @@
throws SAXException {
sendEndPrefixMapping();
- ParametersRecorder recorder = (ParametersRecorder)this.removeRecorder();
+ ParametersRecorder recorder = (ParametersRecorder) this.removeRecorder();
SourceParameters parameters = recorder.getParameters(source);
if (getLogger().isDebugEnabled()) {
getLogger().debug("End parameters recording. Parameters=" + parameters);
@@ -540,7 +550,7 @@
throws SAXException {
sendEndPrefixMapping();
- ParametersRecorder recorder = (ParametersRecorder)this.removeRecorder();
+ ParametersRecorder recorder = (ParametersRecorder) removeRecorder();
SourceParameters parameters = recorder.getParameters(source);
if (getLogger().isDebugEnabled()) {
getLogger().debug("End parameters recording. Parameters=" + parameters);
@@ -584,6 +594,7 @@
final DocumentFragment recordedDocFrag = doc.createDocumentFragment();
final Node root = doc.getDocumentElement();
root.normalize();
+
boolean appendedNode = false;
while (root.hasChildNodes() == true) {
Node child = root.getFirstChild();
@@ -672,7 +683,7 @@
*/
public void sendTextEvent(String text)
throws SAXException {
- this.characters(text.toCharArray(), 0, text.length());
+ characters(text.toCharArray(), 0, text.length());
}
/**
@@ -684,7 +695,7 @@
*/
public void sendStartElementEvent(String localname)
throws SAXException {
- this.startElement("", localname, localname, emptyAttributes);
+ startElement("", localname, localname, emptyAttributes);
}
/**
@@ -697,8 +708,8 @@
*/
public void sendStartElementEventNS(String localname)
throws SAXException {
- this.startElement(this.namespaceURI,
- localname, this.ourPrefix+':' + localname, emptyAttributes);
+ startElement(this.namespaceURI,
+ localname, this.ourPrefix + ':' + localname, emptyAttributes);
}
/**
@@ -711,7 +722,7 @@
*/
public void sendStartElementEvent(String localname, Attributes attr)
throws SAXException {
- this.startElement("", localname, localname, attr);
+ startElement("", localname, localname, attr);
}
/**
@@ -724,8 +735,8 @@
*/
public void sendStartElementEventNS(String localname, Attributes attr)
throws SAXException {
- this.startElement(this.namespaceURI,
- localname, this.ourPrefix+':' + localname, attr);
+ startElement(this.namespaceURI,
+ localname, this.ourPrefix + ':' + localname, attr);
}
/**
@@ -737,7 +748,7 @@
*/
public void sendEndElementEvent(String localname)
throws SAXException {
- this.endElement("", localname, localname);
+ endElement("", localname, localname);
}
/**
@@ -749,8 +760,8 @@
*/
public void sendEndElementEventNS(String localname)
throws SAXException {
- this.endElement(this.namespaceURI,
- localname, this.ourPrefix+':' + localname);
+ endElement(this.namespaceURI,
+ localname, this.ourPrefix + ':' + localname);
}
/**
@@ -851,7 +862,7 @@
if (prefix != null) {
this.namespaces.add(new String[] {prefix, uri});
}
- if ( this.namespaceURI != null && this.namespaceURI.equals(uri)) {
+ if (namespaceURI.equals(uri)) {
this.ourPrefix = prefix;
}
if (this.ignoreEventsCount == 0) {
@@ -883,7 +894,7 @@
}
this.namespaces.remove(i);
- if ( prefix.equals(this.ourPrefix) ) {
+ if (prefix.equals(this.ourPrefix)) {
this.ourPrefix = null;
// now search if we have a different prefix for our namespace
found = false;
@@ -891,13 +902,13 @@
i = l-1;
while (!found && i >= 0) {
String currentNS = ((String[])this.namespaces.get(i))[1];
- if (currentNS.equals(this.namespaceURI)) {
+ if (namespaceURI.equals(currentNS)) {
found = true;
} else {
i--;
}
}
- if ( found ) {
+ if (found) {
this.ourPrefix = ((String[])this.namespaces.get(i))[0];
}
}
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java Wed Sep 22 04:56:13 2004
@@ -51,7 +51,7 @@
import java.util.Map;
/**
-* @cocoon.sitemap.component.documentation
+ * @cocoon.sitemap.component.documentation
* This transformer triggers for the element <code>include</code> in the
* namespace "http://apache.org/cocoon/include/1.0".
* The <code>src</code> attribute contains the url which points to
@@ -185,7 +185,7 @@
* Set the namespace
*/
public CIncludeTransformer() {
- this.namespaceURI = CINCLUDE_NAMESPACE_URI;
+ this.defaultNamespaceURI = CINCLUDE_NAMESPACE_URI;
}
/**
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/JPathTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/JPathTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/JPathTransformer.java Wed Sep 22 04:56:13 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed 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
- *
+ *
* 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.
@@ -34,7 +34,7 @@
/**
* @cocoon.sitemap.component.documentation
* Transformer implementation of the JPath XSP tag library.
- *
+ *
* @cocoon.sitemap.component.name jpath
* @cocoon.sitemap.component.logger sitemap.transformer.jpath
*
@@ -100,10 +100,8 @@
*
* @exception Exception if an error occurs
*/
- public void initialize()
- throws Exception {
-
- namespaceURI = JPATH_NAMESPACE_URI;
+ public void initialize() throws Exception {
+ this.defaultNamespaceURI = JPATH_NAMESPACE_URI;
m_re = new RE("id");
m_cache = new HashMap();
}
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/SimpleFormTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/SimpleFormTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/SimpleFormTransformer.java Wed Sep 22 04:56:13 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed 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
- *
+ *
* 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.
@@ -43,14 +43,14 @@
import java.util.List;
import java.util.Map;
-/**
+/**
* @cocoon.sitemap.component.documentation
- * Eliminates the need for XSP to use FormValidatorAction or HTML forms.
+ * Eliminates the need for XSP to use FormValidatorAction or HTML forms.
* Caveat: Select options need a value attribute to work correctly.
*
* @cocoon.sitemap.component.name simple-form
* @cocoon.sitemap.component.logger sitemap.transformer.simple-form
- *
+ *
*
* <p>This transformer fills all HTML 4 form elements with values from
* an InputModule, e.g. request, with the same name. It handles select
@@ -77,13 +77,13 @@
*
* <p><em>Names of error elements are never augmented by prefix, suffix or
* form name.</em></p>
- *
+ *
* <p>Page parts with multiple occurrences depending on the number of
* actual parameters can be enclosed in <repeat on="expr" using="var"/>
* elements. <em>expr</em> is used to determine the number of occurrences
* and <em>var</em> will be expanded with the ordinary number. Repeat elements
* can be nested.</p>
- *
+ *
* <p>Example:</p>
* <pre>
* <repeat on="mult" using="i"><input type="text" name="mult[${i}]"/></repeat>
@@ -100,9 +100,9 @@
*
* <p>Configuration elements:
* <table>
- * <tr><td>input-module</td><td>(String) InputModule configuration,
+ * <tr><td>input-module</td><td>(String) InputModule configuration,
* defaults to an empty configuration and the "request-param" module</td></tr>
- * <tr><td>fixed-attribute</td><td>(String) Name of the attribute used to
+ * <tr><td>fixed-attribute</td><td>(String) Name of the attribute used to
* indicate that this element should not be changed. ("fixed")</td></tr>
* <tr><td>use-form-name</td><td>(boolean) Add the name of the form to the
* name of form elements. Uses default Separator , if default separator is null
@@ -110,7 +110,7 @@
* <tr><td>use-form-name-twice</td><td>(boolean) Add the name of the form twice to the
* name of form elements. This is useful when the form instance has no
* all enclosing root tag and the form name is used instead <em>and</em> the
- * form name needs to be used to find the form data. Uses default Separator ,
+ * form name needs to be used to find the form data. Uses default Separator ,
* if default separator is null or empty, separator is set to "/".("false")</td></tr>
* <tr><td>separator</td><td>(String) Separator between form name and element name ("/")
* </td></tr>
@@ -277,7 +277,7 @@
protected Map formValues = null;
/**
- * Keep track of repeater status.
+ * Keep track of repeater status.
*/
protected class RepeaterStatus {
public String var = null;
@@ -296,7 +296,7 @@
}
/**
- * Keep track of multiple values.
+ * Keep track of multiple values.
*/
protected static class ValueList {
private int current = -1;
@@ -320,7 +320,6 @@
public SimpleFormTransformer() {
this.defaultNamespaceURI = "";
- this.namespaceURI = "";
}
/** set per instance variables to defaults */
@@ -464,7 +463,7 @@
this.reset();
}
- /**
+ /**
* Generate string representation of attributes. For debug only.
*/
protected String printAttributes(Attributes attr) {
@@ -761,8 +760,8 @@
/**
* Start processing a form element. Sets protection indicator if attribute
- * "fixed" is present and either "true" or "yes". Removes attribute "fixed"
- * if present.
+ * "fixed" is present and either "true" or "yes". Removes attribute "fixed"
+ * if present.
* @param uri The namespace of the element.
* @param name The local name of the element.
* @param raw The qualified name of the element.
@@ -797,7 +796,7 @@
* Start recording repeat element contents and push repeat expression and
* variable to repeater stack. Only start recording, if no other recorder is
* currently running.
- *
+ *
* @param uri
* @param name
* @param raw
@@ -826,7 +825,7 @@
/**
* Stop recording repeat contents and replay required number of times.
* Stop only if outmost repeat element is ending.
- *
+ *
* @param uri
* @param name
* @param raw
@@ -962,7 +961,7 @@
/**
* Remove extra information from element's attributes. Currently only removes
* the repeater variable from the element's name attribute if present.
- *
+ *
* @param attr
* @return modified attributes
*/
@@ -1041,7 +1040,7 @@
/**
* Obtain values from used InputModule if not done already and return the
* next value. If no more values exist, returns null.
- *
+ *
* @param name
* @return
*/
@@ -1114,7 +1113,7 @@
/**
* Calls the super's method startTransformingElement.
- *
+ *
* @param uri
* @param name
* @param raw
@@ -1131,9 +1130,9 @@
* ignoreEventsCount if skip is true. Increment can be done either before
* invoking super's method, so that the element itself is skipped, or afterwards,
* so that only the children are skipped.
- *
+ *
* @param skip
- * @param skipChildrenOnly
+ * @param skipChildrenOnly
* @param uri
* @param name
* @param raw
@@ -1172,7 +1171,7 @@
/**
* Calls the super's method endTransformingElement and decrements the
* ignoreEventsCount if larger than zero.
- *
+ *
* @param uri
* @param name
* @param raw
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java Wed Sep 22 04:56:13 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed 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
- *
+ *
* 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.
@@ -84,11 +84,11 @@
* <source:reinsert>[Optional] The XPath (relative to <source:replace/>) to backup the overwritten node to</source:reinsert> - eg: "foo/versions" or "/doc/versions/foo". NOTE: If specified and a node is replaced, all children of this replaced node will be reinserted at the given path.
* <source:fragment>The XML Fragment to be written</source:fragment> - eg: "<foo><bar id="dogcow"/></foo>" or "<foo/><bar><dogcow/><bar/>" etc.
* <source:insert>
- *
+ *
* <source:delete > - deletes an existing asset.
* <source:source>The System ID of the asset to be deleted</source:source> - eg: "docs/blah.xml" or "context://blah.xml" etc.
* <source:path>[Ignored] XPath to specify how your content is wrapped</source:path>
- * <source:fragment>[Ignored]The XML Fragment to be written</source:fragment>
+ * <source:fragment>[Ignored]The XML Fragment to be written</source:fragment>
* <source:delete>
* </pre>
*
@@ -283,13 +283,13 @@
/** The XPath processor */
protected XPathProcessor xpathProcessor;
-
+
/**
* Constructor.
* Sets the namespace.
*/
public SourceWritingTransformer() {
- this.namespaceURI = SWT_URI;
+ this.defaultNamespaceURI = SWT_URI;
}
/**
@@ -336,7 +336,7 @@
}
// Element: insert
- if (this.state == STATE_OUTSIDE
+ if (this.state == STATE_OUTSIDE
&& (name.equals(INSERT_ELEMENT) || name.equals(WRITE_ELEMENT))) {
this.state = (name.equals(INSERT_ELEMENT) ? STATE_INSERT : STATE_WRITE);
@@ -470,9 +470,9 @@
this.stack.pop();
}
} while ( !tag.equals("END"));
-
+
this.deleteSource(sourceName);
- this.state = STATE_OUTSIDE;
+ this.state = STATE_OUTSIDE;
// Element: file
} else if (name.equals(SOURCE_ELEMENT) && this.state == STATE_FILE) {
this.state = this.parent_state;
@@ -769,11 +769,11 @@
this.reportResult(localSerializer, tagname, message, target, result, action);
}
- private void reportResult(String localSerializer,
- String tagname,
- String message,
- String target,
- String result,
+ private void reportResult(String localSerializer,
+ String tagname,
+ String message,
+ String target,
+ String result,
String action)
throws SAXException {
sendStartElementEvent(RESULT_ELEMENT);
@@ -799,8 +799,8 @@
}
sendEndElementEvent(RESULT_ELEMENT);
}
-
-
+
+
/* (non-Javadoc)
* @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager)
*/