Donate Share

Jericho HTML Parser

Subscribe

A problem with a nested tag

You are viewing a single message from this topic. View all messages.

  1. 2009-10-23 11:28:40 UTC

    Hi Martin,

    excellent, it works pretty fine, thank you so much.

    > i.e. the tag <cb:message key='id007' text='Order it' /> would have getName()=="message".

    Actually, it would have getName()=="cb:message" (just a note for another reader)....

    > the isServerTag argument is set to true, which allows the tags to be found inside attributes of normal tags without deregistering the normal tag types.

    A little bit confusing argument name, isn't it?

    > This is quite messy as registering tags is a static function so they will remain registered for all Source instances. This might be a problem in a multithreaded environment.

    Well, i think it is worse than a problem. Even in singlethreaded environment. ;-)

    I need to parse several tens or hundreds of JSP files.

    And I should register/deregister StartTagTypeJSP (and special StartTagTypeJspDirective, see another topic please) for every file. Or to remember the last prefix and register/deregister StartTagTypeJSP when the prefix was changed.

    Are you going to remove the "static mess" ? For example to use the "Factory" design pattern?

    I would preffer the code like this:

    Map&lt;String, SourceFactory&gt; prefix2factory;
    
    ...
    for every File:
    
    SourceFactory fac = prefix2factory.get(prefixFound);
    if (fac == null) {
    
      fac = SourceFactory.create();
      fac.registerTagType(new StartTagTypeJSP(prefixFound));
      prefix2factory.put(prefixFound, fac);
    }
    
    Source parser = fac.createSource(new BufferedReader(new FileReader(aFile)));
    

    > Personally I think the use of xml-style JSP tags inside normal tag attributes is bad practice, even if it is quite common.

    You are probably right.

    But I think it is good idea to keep the business code and texts for an end user together, it is much easier for a developer. Those texts (in HTML tags) should be localised to several languages.

    Do you have a better solution for this instead of JSP tags inside normal tag attributes? I would really appreciate your advice. :-)

    Thank you again. Mike.

< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.