You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mo...@apache.org on 2003/01/26 07:43:04 UTC
cvs commit: jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl ApplyTemplatesTag.java StyleTag.java StylesheetTag.java TemplateTag.java
morgand 2003/01/25 22:43:04
Modified: jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl
ApplyTemplatesTag.java StyleTag.java
StylesheetTag.java TemplateTag.java
Log:
converted jsl taglib from Exception to JellyTagException
Revision Changes Path
1.7 +14 -8 jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl/ApplyTemplatesTag.java
Index: ApplyTemplatesTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl/ApplyTemplatesTag.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ApplyTemplatesTag.java 11 Dec 2002 12:40:55 -0000 1.6
+++ ApplyTemplatesTag.java 26 Jan 2003 06:43:04 -0000 1.7
@@ -57,7 +57,7 @@
*/
package org.apache.commons.jelly.tags.jsl;
-import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.logging.Log;
@@ -90,10 +90,10 @@
// Tag interface
//-------------------------------------------------------------------------
/** By default just evaluate the body */
- public void doTag(XMLOutput output) throws Exception {
+ public void doTag(XMLOutput output) throws JellyTagException {
StylesheetTag tag = (StylesheetTag) findAncestorWithClass( StylesheetTag.class );
if (tag == null) {
- throw new JellyException(
+ throw new JellyTagException(
"<applyTemplates> tag must be inside a <stylesheet> tag"
);
}
@@ -103,11 +103,17 @@
tag.setStylesheetOutput(output);
Object source = tag.getXPathSource();
- if ( select != null ) {
- stylesheet.applyTemplates( source, select );
- }
- else {
- stylesheet.applyTemplates( source );
+ // for some reason, these DOM4J methods only throw Exception
+ try {
+ if ( select != null ) {
+ stylesheet.applyTemplates( source, select );
+ }
+ else {
+ stylesheet.applyTemplates( source );
+ }
+ }
+ catch (Exception e) {
+ throw new JellyTagException(e);
}
tag.setStylesheetOutput(oldOutput);
1.6 +17 -9 jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl/StyleTag.java
Index: StyleTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl/StyleTag.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StyleTag.java 16 Jan 2003 09:20:47 -0000 1.5
+++ StyleTag.java 26 Jan 2003 06:43:04 -0000 1.6
@@ -57,12 +57,14 @@
*/
package org.apache.commons.jelly.tags.jsl;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.MissingAttributeException;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.xpath.XPathTagSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.rule.Stylesheet;
+import org.jaxen.JaxenException;
import org.jaxen.XPath;
/**
@@ -89,22 +91,28 @@
// Tag interface
//-------------------------------------------------------------------------
- public void doTag(XMLOutput output) throws Exception {
+ public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
Stylesheet stylesheet = getStylesheet();
if (stylesheet == null) {
throw new MissingAttributeException("stylesheet");
}
-
- Object source = getSource();
- if (log.isDebugEnabled()) {
- log.debug("About to evaluate stylesheet on source: " + source);
- }
- if (stylesheet instanceof JellyStylesheet) {
+ if (stylesheet instanceof JellyStylesheet) {
JellyStylesheet jellyStyle = (JellyStylesheet) stylesheet;
jellyStyle.setOutput(output);
}
- stylesheet.run(source);
+
+ // dom4j only seems to throw Exception
+ try {
+ Object source = getSource();
+ if (log.isDebugEnabled()) {
+ log.debug("About to evaluate stylesheet on source: " + source);
+ }
+
+ stylesheet.run(source);
+ } catch (Exception e) {
+ throw new JellyTagException(e);
+ }
}
@@ -132,7 +140,7 @@
/** @return the source on which the stylesheet should run
*/
- protected Object getSource() throws Exception {
+ protected Object getSource() throws JaxenException {
Object source = getXPathContext();
if ( select != null ) {
return select.evaluate(source);
1.11 +21 -10 jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl/StylesheetTag.java
Index: StylesheetTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl/StylesheetTag.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- StylesheetTag.java 16 Jan 2003 09:20:47 -0000 1.10
+++ StylesheetTag.java 26 Jan 2003 06:43:04 -0000 1.11
@@ -57,6 +57,7 @@
*/
package org.apache.commons.jelly.tags.jsl;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.xpath.XPathSource;
import org.apache.commons.jelly.xpath.XPathTagSupport;
@@ -64,6 +65,7 @@
import org.apache.commons.logging.LogFactory;
import org.dom4j.rule.Rule;
import org.dom4j.rule.Stylesheet;
+import org.jaxen.JaxenException;
import org.jaxen.XPath;
@@ -111,7 +113,8 @@
}
/**
- * Sets the XMLOutput to use by the current stylesheet
*/
+ * Sets the XMLOutput to use by the current stylesheet
+ */
public void setStylesheetOutput(XMLOutput output) {
if (stylesheet instanceof JellyStylesheet) {
JellyStylesheet jellyStyle = (JellyStylesheet) stylesheet;
@@ -140,7 +143,7 @@
// Tag interface
//-------------------------------------------------------------------------
- public void doTag(XMLOutput output) throws Exception {
+ public void doTag(XMLOutput output) throws JellyTagException {
stylesheet = createStylesheet(output);
// run the body to add the rules
@@ -151,13 +154,21 @@
context.setVariable(var, stylesheet);
}
else {
- Object source = getSource();
-
- if (log.isDebugEnabled()) {
- log.debug("About to evaluate stylesheet on source: " + source);
- }
-
- stylesheet.run(source);
+
+ //dom4j seems to only throw generic Exceptions
+ try {
+ Object source = getSource();
+
+ if (log.isDebugEnabled()) {
+ log.debug("About to evaluate stylesheet on source: " + source);
+ }
+
+ stylesheet.run(source);
+ }
+ catch (Exception e) {
+ throw new JellyTagException(e);
+ }
+
}
}
@@ -201,7 +212,7 @@
/** @return the source on which the stylesheet should run
*/
- protected Object getSource() throws Exception {
+ protected Object getSource() throws JaxenException {
Object source = getXPathContext();
if ( select != null ) {
return select.evaluate(source);
1.11 +3 -3 jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl/TemplateTag.java
Index: TemplateTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl/TemplateTag.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TemplateTag.java 16 Jan 2003 09:20:47 -0000 1.10
+++ TemplateTag.java 26 Jan 2003 06:43:04 -0000 1.11
@@ -58,7 +58,7 @@
package org.apache.commons.jelly.tags.jsl;
-import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.xpath.XPathSource;
@@ -103,10 +103,10 @@
// Tag interface
//-------------------------------------------------------------------------
- public void doTag(XMLOutput output) throws Exception {
+ public void doTag(XMLOutput output) throws JellyTagException {
StylesheetTag tag = (StylesheetTag) findAncestorWithClass( StylesheetTag.class );
if (tag == null) {
- throw new JellyException( "This <template> tag must be used inside a <stylesheet> tag" );
+ throw new JellyTagException( "This <template> tag must be used inside a <stylesheet> tag" );
}
if ( log.isDebugEnabled() ) {
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>