Manage a prefix for the TagsData processAttributes.

This commit is contained in:
administrateur 2007-01-24 03:39:27 +01:00
parent d0606fe62e
commit cbfbfc71d5
6 changed files with 26 additions and 4 deletions

Binary file not shown.

BIN
dist/test.jar vendored

Binary file not shown.

BIN
dist/xid.jar vendored

Binary file not shown.

View file

@ -495,7 +495,7 @@ public class Presenter
result.append (node.getNodeName());
// Build attributes.
result.append (processAttributes (attrs, data));
result.append (processAttributes (attrs, data, Integer.toString (nLine)));
if ((node.getChildNodes () == null) &&
((data == null) || data.display ().equals ("")))
@ -1039,6 +1039,20 @@ public class Presenter
{
StringBuffer result;
result = processAttributes (attrs, model, "");
//
return (result);
}
/*
*
*/
static protected StringBuffer processAttributes (NamedNodeMap attrs, TagData model, String prefix)
{
StringBuffer result;
result = new StringBuffer ();
// Build the original attributes list.
@ -1089,7 +1103,15 @@ public class Presenter
while (iterator.hasNext ())
{
Map.Entry<String, String> attribute = (Map.Entry<String, String>) iterator.next();
result.append(" " + attribute.getKey () + "=\"" + attribute.getValue ()+ "\"");
if (attribute.getKey ().equals ("id"))
{
result.append(" " + attribute.getKey () + "=\"" + attribute.getValue () + '_' + prefix + "\"");
}
else
{
result.append(" " + attribute.getKey () + "=\"" + attribute.getValue ()+ "\"");
}
}
//

View file

@ -235,7 +235,7 @@ class Test
errorMessage = new StringBuffer ();
html = Presenter.doXid ("<ul>\n<li id='words'>a word</li>\n</ul>", datas, "", errorMessage);
html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, "", errorMessage);
System.out.println ("----------------------------");
System.out.println ("datas = new TagsDataId ();");
@ -247,7 +247,7 @@ class Test
System.out.println ("datas.setContent (\"words\", 5, \"fox\");");
System.out.println ("+");
System.out.println ("<ul>");
System.out.println ("<li id='words'>a word</li>");
System.out.println (" <li id='words'>a word</li>");
System.out.println ("</ul>");
System.out.println ("=>");
System.out.println (html);