[doxia-dev] [jira] Created: (DOXIA-27) sink validation (sink advisor)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[doxia-dev] [jira] Created: (DOXIA-27) sink validation (sink advisor)

JIRA jira@codehaus.org
sink validation (sink advisor)
------------------------------

         Key: DOXIA-27
         URL: http://jira.codehaus.org/browse/DOXIA-27
     Project: doxia
        Type: Improvement
    Reporter: Juan F. Codagnone


Hi,
 in the past day i've been writting a twiki parser for doxia. It isn't done
yet, but i started to convert some text using existing Sinks, and while doing
that i've found some problems:
  None of the sinks tries to validates a correct usage. For example in most of
sinks,
      sink.list();
      sint.listItem_();
would generate an invalid output, and you don't find that until you process
the output. I found this a bit fragile.

To solve it, i've created an AdvicedSink class that is a proxy implementation
of a Sink, where you can inject some Advisors to do some crosscutting
validations. The advisors are like AOP and you only must implement one method
instead of the 89 of the Sink.

I've implemented two advisors: one that prints the the sink calls with
indentation:
        head
        head_
        body
           section1
              sectionTitle
                 text
        ...
usefull for debuging, and one that throws a runtime exception if the closing
element doesn't match with the starting, in cases like:
      sink.list();
      sint.listItem_();

In the future i would like to see an advisor that check in a fine grain the
sink events. For example in the XdocSink if i do
      sink.listItem();
      sink.text("foo");
      sink.listItem_();
wrong code is generated, and i must do:
      sink.listItem();
      sink.paragraph();
      sink.text("foo");
      sink._paragraph();
      sink.listItem_();
to get the correct content. And state machine advisor would only allow to call
paragraph item a listitem and that would be reusable for all the sinks.

Example of use:
     final Sink sink = new AdvicedSink(new MethodBeforeAdvice[] {
                new PrintAdvisor(System.out),
                new HangingElementAdvice(),
     }, new XdocSink(writer));

I hope you found it usefull as i do.

Regards,
    Juan.


--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply | Threaded
Open this post in threaded view
|

[doxia-dev] [jira] Updated: (DOXIA-27) sink validation (sink advisor)

JIRA jira@codehaus.org
     [ http://jira.codehaus.org/browse/DOXIA-27?page=all ]

Juan F. Codagnone updated DOXIA-27:
-----------------------------------

    Attachment: DOXIA-27.tar.gz

> sink validation (sink advisor)
> ------------------------------
>
>          Key: DOXIA-27
>          URL: http://jira.codehaus.org/browse/DOXIA-27
>      Project: doxia
>         Type: Improvement
>     Reporter: Juan F. Codagnone
>  Attachments: DOXIA-27.tar.gz
>
>
> Hi,
>  in the past day i've been writting a twiki parser for doxia. It isn't done
> yet, but i started to convert some text using existing Sinks, and while doing
> that i've found some problems:
>   None of the sinks tries to validates a correct usage. For example in most of
> sinks,
>       sink.list();
>       sint.listItem_();
> would generate an invalid output, and you don't find that until you process
> the output. I found this a bit fragile.
> To solve it, i've created an AdvicedSink class that is a proxy implementation
> of a Sink, where you can inject some Advisors to do some crosscutting
> validations. The advisors are like AOP and you only must implement one method
> instead of the 89 of the Sink.
> I've implemented two advisors: one that prints the the sink calls with
> indentation:
>         head
>         head_
>         body
>            section1
>               sectionTitle
>                  text
>         ...
> usefull for debuging, and one that throws a runtime exception if the closing
> element doesn't match with the starting, in cases like:
>       sink.list();
>       sint.listItem_();
> In the future i would like to see an advisor that check in a fine grain the
> sink events. For example in the XdocSink if i do
>       sink.listItem();
>       sink.text("foo");
>       sink.listItem_();
> wrong code is generated, and i must do:
>       sink.listItem();
>       sink.paragraph();
>       sink.text("foo");
>       sink._paragraph();
>       sink.listItem_();
> to get the correct content. And state machine advisor would only allow to call
> paragraph item a listitem and that would be reusable for all the sinks.
> Example of use:
>      final Sink sink = new AdvicedSink(new MethodBeforeAdvice[] {
>                 new PrintAdvisor(System.out),
>                 new HangingElementAdvice(),
>      }, new XdocSink(writer));
> I hope you found it usefull as i do.
> Regards,
>     Juan.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira