crafterm 2002/11/06 09:52:51 Modified: src/java/org/apache/cocoon/transformation JPathTransformer.java Log: * Added support for the <jpath:continuation/> element Revision Changes Path 1.2 +35 -10 xml-cocoon2/src/java/org/apache/cocoon/transformation/JPathTransformer.java Index: JPathTransformer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/JPathTransformer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JPathTransformer.java 6 Nov 2002 15:53:40 -0000 1.1 +++ JPathTransformer.java 6 Nov 2002 17:52:51 -0000 1.2 @@ -80,6 +80,7 @@ * * <ul> * <li><jpath:value-of select=".."/> element. + * <li><jpath:continuation/> element. * <li>jpath:action attribute on all elements that implicitly replaces any * occurance of the string 'id' with the continuation id (useful when * writing form action attributes). eg: @@ -99,18 +100,21 @@ /** jpath:action attribute constant */ public static final String JPATH_ACTION = "jpath:action"; - /** jpath:value-of element constant*/ + /** jpath:value-of element constant */ public static final String JPATH_VALUEOF = "value-of"; /** jpath:value-of select attribute constant */ public static final String JPATH_VALUEOF_SELECT = "select"; + /** jpath:continuation element constant */ + public static final String JPATH_CONTINUATION = "continuation"; + + /** jpath:continuation select attribute constant */ + public static final String JPATH_CONTINUATION_SELECT = "select"; + // web contination private WebContinuation m_kont; - // web continuation level - private int m_level = 0; - // regular expression for matching 'id' strings with jpath:action private RE m_re; @@ -191,8 +195,10 @@ ) throws ProcessingException ,IOException, SAXException { - if (name.equals(JPATH_VALUEOF)) { - valueOf(attr); + if (JPATH_VALUEOF.equals(name)) { + doValueOf(attr); + } else if (JPATH_CONTINUATION.equals(name)) { + doContinuation(attr); } else { super.startTransformingElement(uri, name, raw, attr); } @@ -213,7 +219,8 @@ ) throws ProcessingException, IOException, SAXException { - if (name.equals(JPATH_VALUEOF)) { + if (JPATH_VALUEOF.equals(name) || + JPATH_CONTINUATION.equals(name)) { return; // do nothing } else { super.endTransformingElement(uri, name, raw); @@ -240,7 +247,7 @@ String value = a.getValue(idx); // REVISIT(MC): support for continuation level - String id = m_kont.getContinuation(m_level).getId(); + String id = m_kont.getContinuation(0).getId(); a.removeAttribute(idx); a.addAttribute( @@ -256,7 +263,7 @@ * @exception SAXException if a SAX error occurs * @exception ProcessingException if a processing error occurs */ - private void valueOf(final Attributes a) + private void doValueOf(final Attributes a) throws SAXException, ProcessingException { String select = a.getValue(JPATH_VALUEOF_SELECT); @@ -285,6 +292,24 @@ "jpath:" + JPATH_VALUEOF + " specified without a select attribute" ); } + } + + /** + * Helper method to process a <jpath:continuation select=""/> element + * + * @param a an <code>Attributes</code> value + * @exception SAXException if an error occurs + */ + private void doContinuation(final Attributes a) + throws SAXException { + + final String level = a.getValue(JPATH_CONTINUATION_SELECT); + + final String id = (level != null) + ? m_kont.getContinuation(Integer.decode(level).intValue()).getId() + : m_kont.getContinuation(0).getId(); + + sendTextEvent(id); } /**
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]