\", \"class\", \"aDivClass\");");
System.out.println ("datas.setAttribute (\"
\", \"style\", \"background-color: #000000;\");");
System.out.println ("datas.setAttribute (\"number\", \"style\", \"background-color: #0000FF;\");");
System.out.println ("=>");
System.out.println (html);
- */
}
}
diff --git a/src/xid/Presenter.java b/src/xid/Presenter.java
index 941fcae..edbb1e8 100644
--- a/src/xid/Presenter.java
+++ b/src/xid/Presenter.java
@@ -91,9 +91,9 @@ public class Presenter
/*
*
*/
- public StringBuffer doXid (IdsDataById datas, StringBuffer errorOutput)
+ public StringBuffer doXid (Data datas, StringBuffer errorOutput)
{
- return (doXid (datas, null, errorOutput));
+ return (doXid (datas.getIdsDataById (), datas.getTagsDataById (), errorOutput));
}
/*
@@ -168,6 +168,15 @@ public class Presenter
+ /*
+ *
+ */
+ static public StringBuffer doXid (String html, Data datas, StringBuffer errorOutput)
+ {
+ return (doXid (html, datas.getIdsDataById (), datas.getTagsDataById (), "", errorOutput));
+ }
+
+
/*
*
*/
@@ -529,7 +538,13 @@ public class Presenter
* @param attrMap
* @param idAttr
*/
- static protected StringBuffer processObjectTag (Node node, NamedNodeMap attrMap, Node idAttr, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput)
+ static protected StringBuffer processObjectTag (Node node,
+ NamedNodeMap attrMap,
+ Node idAttr,
+ IdsDataById datas,
+ TagsDataById tagsData,
+ String webappPath,
+ StringBuffer errorOutput)
{
StringBuffer result;
@@ -550,7 +565,6 @@ public class Presenter
codetype = attrMap.getNamedItem ("codetype").getNodeValue ();
}
-
// Check tag requirements.
if ((attrMap == null) ||
(codetype == null) ||
@@ -577,7 +591,7 @@ public class Presenter
}
catch (Exception ex)
{
- result.append ("unable to build the file tree");
+ errorOutput.append ("unable to build the file tree");
log.debug ("unable to build the file tree");
}
@@ -589,7 +603,7 @@ public class Presenter
if (nodes.getLength () == 0)
{
- result.append ("no body tag in include html");
+ errorOutput.append ("no body tag in include html");
log.debug ("no body tag in include html");
}
else
@@ -599,19 +613,26 @@ public class Presenter
}
catch (Exception e)
{
- result.append ("error getting child");
+ errorOutput.append ("error getting child");
log.debug ("error getting child");
}
// Process the body child as part of the primary tree.
- NodeList bodyChildren = body.getChildNodes ();
-
- if (bodyChildren != null)
+ if (body == null)
{
- int childCount = bodyChildren.getLength ();
- for (int childCounter = 0; childCounter < childCount; childCounter++)
+ errorOutput.append ("xid object body empty.");
+ }
+ else
+ {
+ NodeList bodyChildren = body.getChildNodes ();
+
+ if (bodyChildren != null)
{
- result.append (process (bodyChildren.item (childCounter), datas, tagsData, webappPath, errorOutput));
+ int childCount = bodyChildren.getLength ();
+ for (int childCounter = 0; childCounter < childCount; childCounter++)
+ {
+ result.append (process (bodyChildren.item (childCounter), datas, tagsData, webappPath, errorOutput));
+ }
}
}
@@ -677,98 +698,41 @@ public class Presenter
result = new StringBuffer ();
String tag = node.getNodeName();
- String idValue = idAttr.getNodeValue();
- log.debug ("tag=" + tag);
-
- // Get data of this id.
- IdDataCore dataCore = datas.get (idAttr.getNodeValue ());
-
- if (dataCore == null)
+ if (tag.equals ("object"))
{
- result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput));
+ result.append (processObjectTag (node, attrs, idAttr, datas, tagsData, webappPath, errorOutput));
}
- else if (dataCore instanceof IdData)
+ else
{
- IdData data = (IdData) dataCore;
+ String idValue = idAttr.getNodeValue();
- String theClass;
- if (data == null)
- {
- theClass = null;
- }
- else
- {
- theClass = data.getAttributes ().getAttribute ("class");
- }
+ log.debug ("tag=" + tag);
- if ((theClass == null) ||
- (!theClass.equals ("xid:nodisplay")))
+ // Get data of this id.
+ IdDataCore dataCore = datas.get (idAttr.getNodeValue ());
+
+ if (dataCore == null)
{
- // Open the tag.
- result.append ("<");
- result.append (node.getNodeName());
+ result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput));
+ }
+ else if (dataCore instanceof IdData)
+ {
+ IdData data = (IdData) dataCore;
- // Build attributes.
- Attributes tagAttributes;
- if (tagsData == null)
+ String theClass;
+ if (data == null)
{
- tagAttributes = null;
+ theClass = null;
}
else
{
- TagData tagData = tagsData.getId (node.getNodeName ());
- if (tagData == null)
- {
- tagAttributes = null;
- }
- else
- {
- tagAttributes = tagData.getAttributes ();
- }
+ theClass = data.getAttributes ().getAttribute ("class");
}
-
- result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, suffix));
- if ((node.getChildNodes () == null) &&
- ((data == null) || data.display ().equals ("")))
+ if ((theClass == null) ||
+ (!theClass.equals ("xid:nodisplay")))
{
- // Close the tag.
- result.append (" />");
- }
- else
- {
- result.append ('>');
-
- // Insert data.
- if ((data == null) ||
- (data.display ().equals ("")))
- {
- result.append (processChildren (node, datas, tagsData, webappPath, suffix, errorOutput));
- }
- else
- {
- result.append (data.display ());
- }
-
- // Close the tag.
- result.append ("");
- result.append (node.getNodeName());
- result.append ('>');
- }
- }
- }
- else if (dataCore instanceof IdsDataByIndex)
- {
- IdsDataByIndex tags = (IdsDataByIndex) dataCore;
-
- int nbLines = tags.size ();
- for (int nLine = 0; nLine < nbLines; nLine++)
- {
- if (tags.elementAt (nLine) instanceof IdData)
- {
- IdData data = (IdData) tags.elementAt (nLine);
-
// Open the tag.
result.append ("<");
result.append (node.getNodeName());
@@ -791,14 +755,14 @@ public class Presenter
tagAttributes = tagData.getAttributes ();
}
}
-
- result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, Integer.toString (nLine)));
+
+ result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, suffix));
if ((node.getChildNodes () == null) &&
((data == null) || data.display ().equals ("")))
{
// Close the tag.
- result.append (" />\n");
+ result.append (" />");
}
else
{
@@ -818,22 +782,87 @@ public class Presenter
// Close the tag.
result.append ("");
result.append (node.getNodeName());
- result.append (">\n");
+ result.append ('>');
}
}
- else
+ }
+ else if (dataCore instanceof IdsDataByIndex)
+ {
+ IdsDataByIndex tags = (IdsDataByIndex) dataCore;
+
+ int nbLines = tags.size ();
+ for (int nLine = 0; nLine < nbLines; nLine++)
{
- // Manage a Hashmap.
- IdsDataById data = (IdsDataById) tags.elementAt (nLine);
-
- result.append (Presenter.processElementWithId (node, attrs, idAttr, data, tagsData, webappPath, Integer.toString (nLine), errorOutput));
- result.append ('\n');
+ if (tags.elementAt (nLine) instanceof IdData)
+ {
+ IdData data = (IdData) tags.elementAt (nLine);
+
+ // Open the tag.
+ result.append ("<");
+ result.append (node.getNodeName());
+
+ // Build attributes.
+ Attributes tagAttributes;
+ if (tagsData == null)
+ {
+ tagAttributes = null;
+ }
+ else
+ {
+ TagData tagData = tagsData.getId (node.getNodeName ());
+ if (tagData == null)
+ {
+ tagAttributes = null;
+ }
+ else
+ {
+ tagAttributes = tagData.getAttributes ();
+ }
+ }
+
+ result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, Integer.toString (nLine)));
+
+ if ((node.getChildNodes () == null) &&
+ ((data == null) || data.display ().equals ("")))
+ {
+ // Close the tag.
+ result.append (" />\n");
+ }
+ else
+ {
+ result.append ('>');
+
+ // Insert data.
+ if ((data == null) ||
+ (data.display ().equals ("")))
+ {
+ result.append (processChildren (node, datas, tagsData, webappPath, suffix, errorOutput));
+ }
+ else
+ {
+ result.append (data.display ());
+ }
+
+ // Close the tag.
+ result.append ("");
+ result.append (node.getNodeName());
+ result.append (">\n");
+ }
+ }
+ else
+ {
+ // Manage a Hashmap.
+ IdsDataById data = (IdsDataById) tags.elementAt (nLine);
+
+ result.append (Presenter.processElementWithId (node, attrs, idAttr, data, tagsData, webappPath, Integer.toString (nLine), errorOutput));
+ result.append ('\n');
+ }
}
}
- }
- else
- {
- log.warn ("Unknow type of IdDataId");
+ else
+ {
+ log.warn ("Unknow type of IdDataId");
+ }
}
//
@@ -930,7 +959,17 @@ public class Presenter
}
else
{
- result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput));
+
+ String tag = node.getNodeName();
+
+ if (tag.equals ("object"))
+ {
+ result.append (processObjectTag (node, attrs, idAttr, datas, tagsData, webappPath, errorOutput));
+ }
+ else
+ {
+ result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput));
+ }
}
break;
diff --git a/test/xid/test/Test.java b/test/xid/test/Test.java
index 7184856..5ec5b99 100644
--- a/test/xid/test/Test.java
+++ b/test/xid/test/Test.java
@@ -83,7 +83,7 @@ class Test
datas.setContent ("name", "Superman");
errorMessage = new StringBuffer ();
- html = Presenter.doXid ("
a name
", datas, "", errorMessage);
+ html = Presenter.doXid ("
a name
", datas, errorMessage);
System.out.println (check ("only content change", html, "
Superman
"));
@@ -97,7 +97,7 @@ class Test
datas.setAttribute ("lastname", "class", "nameClass");
errorMessage = new StringBuffer ();
- html = Presenter.doXid ("
a last name
", datas, "", errorMessage);
+ html = Presenter.doXid ("
a last name
", datas, errorMessage);
System.out.println (check ("content and attributes", html, "
Spiderman
"));
// Populate attributes of Test 03.
@@ -112,7 +112,7 @@ class Test
errorMessage = new StringBuffer ();
- html = Presenter.doXid ("
", datas, "", errorMessage);
+ html = Presenter.doXid ("
", datas, errorMessage);
System.out.println (check ("list assertion 1", html, "
alpha"));
System.out.println (check ("list assertion 2", html, "
bravo"));
@@ -138,7 +138,7 @@ class Test
source.append ("
noid | un nom | un prenom |
\n");
source.append ("");
htmlSource = source.toString ();
- html = Presenter.doXid (htmlSource, datas, "", errorMessage);
+ html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (check ("table 1 assertion 1", html, "
noid | Jemba | Epo |
"));
System.out.println (check ("table 1 assertion 2", html, "
noid | Momon | Christian |
"));