cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Fiol BonnĂ­n <antonio.f...@gmail.com>
Subject Re: Can i do this thing?
Date Tue, 08 Nov 2005 19:09:27 GMT
2005/11/8, Angelo Immediata <angeloimm@libero.it>:
> Hi all. I must do a link rewriteron an HTML file tha i have form tidy generator. I must
rewite the link by using some values contained in a java.util.Map; i have this Map populated
by the content in the tag "<a"; i.e if the link is <a href="controllo.html"> controllo
criminale</a> in the Map i have done a similar thing:
>
> Map m = new HasMap();
> m.put( "controllo criminale", "pageId=2" );
>
> By this linkrewriter i want to do a similar thing:
>
> to take the value of the tag a (that is the String controllo criminale)
>
> to check if this string is present in the map (if m.contains("controllo criminale"))
>
> to change the href value from href="controllo.html" to href="invoke?pageId=2"
>
>
> Can i do a similar thing by using SAX or must i use DOM. If i can use SAX... can anyone
show me how i can do?
>
> Thanks to all.
>   Angelo.


If the only thing you may have inside the <a...>...</a> is some text,
it should not be difficult to write it using SAX.

On startElement, if it's an <a>, don't send it, but store the
attributes in an instance variable.
If you have some attributes stored, you do not commit text either, but
check the map, and change the attributes accordingly, commit the <a>
with the new attributes, commit the text, and remove the attributes
from your variable.

Of course, that would need some tweeking to support empty <a>
elements, nested <a> elements, and other strange artifacts you might
have.


Other than that, if you can generate the map as some XML, aggregate it
with your input HTML, and transform it with some XSL.


--
Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message