diff --git a/build.xml b/build.xml
index f4113c9..e49d162 100644
--- a/build.xml
+++ b/build.xml
@@ -146,6 +146,7 @@
+
diff --git a/build.xml~ b/build.xml~
deleted file mode 100644
index 4c8c533..0000000
--- a/build.xml~
+++ /dev/null
@@ -1,128 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build/classes/xid/Attributes.class b/build/classes/xid/Attributes.class
deleted file mode 100644
index a2cf8f1..0000000
Binary files a/build/classes/xid/Attributes.class and /dev/null differ
diff --git a/build/classes/xid/ParserErrorHandler.class b/build/classes/xid/ParserErrorHandler.class
deleted file mode 100644
index 02074b4..0000000
Binary files a/build/classes/xid/ParserErrorHandler.class and /dev/null differ
diff --git a/build/classes/xid/Presenter.class b/build/classes/xid/Presenter.class
deleted file mode 100644
index 1ac5e3f..0000000
Binary files a/build/classes/xid/Presenter.class and /dev/null differ
diff --git a/build/classes/xid/TagData.class b/build/classes/xid/TagData.class
deleted file mode 100644
index fdbd824..0000000
Binary files a/build/classes/xid/TagData.class and /dev/null differ
diff --git a/build/classes/xid/TagsData.class b/build/classes/xid/TagsData.class
deleted file mode 100644
index eee90b1..0000000
Binary files a/build/classes/xid/TagsData.class and /dev/null differ
diff --git a/demo/Demo.java b/demo/Demo.java
index f18e85e..48539c3 100644
--- a/demo/Demo.java
+++ b/demo/Demo.java
@@ -125,29 +125,29 @@ class Demo
// Populate attributes of Test 03.
System.out.println ("----------------------------");
datas = new Data ();
- datas.setContent ("identity", 0, "nom", "Jemba");
- datas.setContent ("identity", 0, "prenom", "Epo");
- datas.setContent ("identity", 1, "nom", "Momon");
- datas.setContent ("identity", 1, "prenom", "Christian");
- datas.setContent ("identity", 2, "nom", "Tronche");
- datas.setContent ("identity", 2, "prenom", "Christophe");
+ datas.setContent ("identity", 0, "last_name", "Jemba");
+ datas.setContent ("identity", 0, "first_name", "Epo");
+ datas.setContent ("identity", 1, "last_name", "Momon");
+ datas.setContent ("identity", 1, "first_name", "Christian");
+ datas.setContent ("identity", 2, "last_name", "Tronche");
+ datas.setContent ("identity", 2, "first_name", "Christophe");
errorMessage = new StringBuffer ();
StringBuffer source = new StringBuffer ();
source.append ("
\n");
- source.append (" noid | un nom | un prenom |
\n");
+ source.append (" noid | Jean | Reve |
\n");
source.append ("
");
htmlSource = source.toString ();
html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println ("datas = new Data ();");
- System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");");
- System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");");
- System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");");
- System.out.println ("datas.setContent (\"identity\", 1, \"prenom\", \"Christian\");");
- System.out.println ("datas.setContent (\"identity\", 2, \"nom\", \"Tronche\");");
- System.out.println ("datas.setContent (\"identity\", 2, \"prenom\", \"Christophe\");");
+ System.out.println ("datas.setContent (\"identity\", 0, \"last_name\", \"Jemba\");");
+ System.out.println ("datas.setContent (\"identity\", 0, \"first_name\", \"Epo\");");
+ System.out.println ("datas.setContent (\"identity\", 1, \"last_name\", \"Momon\");");
+ System.out.println ("datas.setContent (\"identity\", 1, \"first_name\", \"Christian\");");
+ System.out.println ("datas.setContent (\"identity\", 2, \"last_name\", \"Tronche\");");
+ System.out.println ("datas.setContent (\"identity\", 2, \"first_name\", \"Christophe\");");
System.out.println ("+");
System.out.println (htmlSource);
@@ -158,13 +158,12 @@ class Demo
// Populate attributes of Test 03.
System.out.println ("----------------------------");
datas = new Data ();
- datas.setContent ("identity", 0, "nom", "Jemba");
- datas.setContent ("identity", 0, "prenom", "Epo");
- datas.setContent ("identity", 1, "nom", "Momon");
- datas.setContent ("identity", 1, "prenom", "Christian");
- datas.setContent ("identity", 2, "nom", "Tronche");
- datas.setContent ("identity", 2, "prenom", "Christophe");
- datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW);
+ datas.setContent ("identity", 0, "last_name", "Jemba");
+ datas.setContent ("identity", 0, "first_name", "Epo");
+ datas.setContent ("identity", 1, "last_name", "Momon");
+ datas.setContent ("identity", 1, "first_name", "Christian");
+ datas.setContent ("identity", 2, "last_name", "Tronche");
+ datas.setContent ("identity", 2, "first_name", "Christophe");
//datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID);
//datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID);
//datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS);
@@ -172,42 +171,52 @@ class Demo
errorMessage = new StringBuffer ();
source = new StringBuffer ();
- source.append ("\n");
- source.append (" noid | un nom | un prenom |
\n");
- source.append (" noid | un nom | un prenom |
\n");
- source.append (" noid | un nom | un prenom |
\n");
- source.append ("
");
+ source.append ("\n");
+ source.append (" noid | First Name | Last Name |
\n");
+ source.append (" noid | Jean | Reve |
\n");
+ source.append (" noid | a first name | a last name |
\n");
+ source.append (" noid | a first name more | a last name more |
\n");
+ source.append ("
\n");
htmlSource = source.toString ();
System.out.println ("datas = new Data ();");
- System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");");
- System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");");
- System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");");
- System.out.println ("datas.setContent (\"identity\", 1, \"prenom\", \"Christian\");");
- System.out.println ("datas.setContent (\"identity\", 2, \"nom\", \"Tronche\");");
- System.out.println ("datas.setContent (\"identity\", 2, \"prenom\", \"Christophe\");");
+ System.out.println ("datas.setContent (\"identity\", 0, \"first_name\", \"Epo\");");
+ System.out.println ("datas.setContent (\"identity\", 0, \"last_name\", \"Jemba\");");
+ System.out.println ("datas.setContent (\"identity\", 1, \"first_name\", \"Christian\");");
+ System.out.println ("datas.setContent (\"identity\", 1, \"last_name\", \"Momon\");");
+ System.out.println ("datas.setContent (\"identity\", 2, \"first_name\", \"Christophe\");");
+ System.out.println ("datas.setContent (\"identity\", 2, \"last_name\", \"Tronche\");");
System.out.println ("+");
System.out.println (htmlSource);
System.out.println ("=>");
- datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW);
+ datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_FIRST_ROW);
System.out.println ("ONLY_FIRST_ROW:");
html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html);
- datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID);
+ System.out.println ("");
+ datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_FIRST_TWO_ROWS);
+ System.out.println ("ONLY_FIRST_TWO_ROWS:");
+ html = Presenter.doXid (htmlSource, datas, errorMessage);
+ System.out.println (html);
+
+ System.out.println ("");
+ datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_ROWS_WITH_ID);
System.out.println ("ONLY_ROWS_WITH_ID:");
html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html);
- datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID);
+ System.out.println ("");
+ datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_ROWS_WITHOUT_ID);
System.out.println ("ONLY_ROWS_WITHOUT_ID:");
html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html);
- datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS);
+ System.out.println ("");
+ datas.setIterationStrategy ("identities", IdData.IterationStrategy.ALL_ROWS);
System.out.println ("ALL_ROWS:");
html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html);
diff --git a/src/xid/Data.java b/src/xid/Data.java
index 991953b..a67a58a 100644
--- a/src/xid/Data.java
+++ b/src/xid/Data.java
@@ -147,11 +147,11 @@ public class Data
/**
*
*/
- public void setIterationStrategy (String id, IdsDataByIndex.IterationStrategy strategy)
+ public void setIterationStrategy (String id, IdData.IterationStrategy strategy)
{
- IdsDataByIndex tags = (IdsDataByIndex) this.idsDataById.getId (id);
+ IdData tag = (IdData) this.getIdData (id);
- tags.setIterationStrategy (strategy);
+ tag.setIterationStrategy (strategy);
}
diff --git a/src/xid/IdData.java b/src/xid/IdData.java
index c217244..a350dbd 100644
--- a/src/xid/IdData.java
+++ b/src/xid/IdData.java
@@ -17,6 +17,11 @@ import java.io.*;
*/
public class IdData implements Serializable, IdDataCore
{
+ public enum IterationStrategy {ONLY_FIRST_ROW, ONLY_FIRST_TWO_ROWS, ONLY_ROWS_WITH_ID, ONLY_ROWS_WITHOUT_ID, ALL_ROWS}
+
+ protected IterationStrategy iterationStrategy;
+
+
public enum MODE {REPLACE, APPEND, IGNORE};
protected Attributes attributes;
@@ -33,6 +38,7 @@ public class IdData implements Serializable, IdDataCore
this.excludeSection = false;
this.displayMode = MODE.REPLACE;
this.content = "";
+ this.iterationStrategy = IterationStrategy.ALL_ROWS;
}
@@ -45,6 +51,7 @@ public class IdData implements Serializable, IdDataCore
this.excludeSection = false;
this.displayMode = MODE.REPLACE;
this.content = text;
+ this.iterationStrategy = IterationStrategy.ALL_ROWS;
}
@@ -135,5 +142,27 @@ public class IdData implements Serializable, IdDataCore
{
return excludeSection;
}
+
+ /**
+ *
+ */
+ public void setIterationStrategy (IterationStrategy strategy)
+ {
+ this.iterationStrategy = strategy;
+ }
+
+
+ /**
+ *
+ */
+ public IterationStrategy getIterationStrategy ()
+ {
+ IterationStrategy result;
+
+ result = this.iterationStrategy;
+
+ //
+ return (result);
+ }
}
diff --git a/src/xid/IdsDataByIndex.java b/src/xid/IdsDataByIndex.java
index 6f70081..5466783 100644
--- a/src/xid/IdsDataByIndex.java
+++ b/src/xid/IdsDataByIndex.java
@@ -8,39 +8,11 @@ import java.io.*;
*/
public class IdsDataByIndex extends Vector implements IdDataCore
{
- public enum IterationStrategy {ONLY_FIRST_ROW, ONLY_ROWS_WITH_ID, ONLY_ROWS_WITHOUT_ID, ALL_ROWS}
-
- protected IterationStrategy iterationStrategy;
-
/**
*
*/
public IdsDataByIndex ()
{
super ();
- this.iterationStrategy = IterationStrategy.ONLY_FIRST_ROW;
- }
-
-
- /**
- *
- */
- public void setIterationStrategy (IterationStrategy strategy)
- {
- this.iterationStrategy = strategy;
- }
-
-
- /**
- *
- */
- public IterationStrategy getIterationStrategy ()
- {
- IterationStrategy result;
-
- result = this.iterationStrategy;
-
- //
- return (result);
}
}
diff --git a/src/xid/Presenter.java b/src/xid/Presenter.java
index edbb1e8..d07c965 100644
--- a/src/xid/Presenter.java
+++ b/src/xid/Presenter.java
@@ -381,148 +381,132 @@ public class Presenter
StringBuffer result;
result = new StringBuffer ();
- NodeList children = node.getChildNodes();
- int childrenCount = children.getLength ();
-
- if ((children == null) || (childrenCount == 0))
+ // Get the iteration strategy.
+ IdData.IterationStrategy strategy;
+
+ NamedNodeMap attributes = node.getAttributes ();
+ if (attributes == null)
{
- result.append (" ");
+ strategy = IdData.IterationStrategy.ALL_ROWS;
}
else
{
- //
- // Is there a IdsDataByIndex associated with the first ELEMENT_NODE child?
- //
- IdsDataByIndex idsData;
+ Node id = attributes.getNamedItem ("id");
- // Find the first ELEMENT_NODE child.
- int childIndex = 0;
- Node child = null;
- boolean ended = false;
- while (!ended)
+ if (id == null)
{
- if (childIndex >= childrenCount)
- {
- ended = true;
- child = null;
- }
- else if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
- {
- ended = true;
- child = children.item (childIndex);
- }
- else
- {
- childIndex += 1;
- }
- }
-
- if (child == null)
- {
- idsData = null;
+ strategy = IdData.IterationStrategy.ALL_ROWS;
}
else
{
- // Searching for the ID value of the child.
- String childId;
-
- NamedNodeMap attrsChild = child.getAttributes ();
-
- if (attrsChild == null)
+ IdDataCore dataCore = datas.getId (id.getNodeValue ());
+ if (dataCore == null)
{
- childId = null;
+ strategy = IdData.IterationStrategy.ALL_ROWS;
+ }
+ else if (dataCore instanceof IdData)
+ {
+ IdData data = (IdData) dataCore;
+ strategy = data.getIterationStrategy ();
}
else
{
- Node idAttrChild;
- idAttrChild = attrsChild.getNamedItem ("id");
-
- if (idAttrChild == null)
- {
- childId = null;
- }
- else
- {
- childId = idAttrChild.getNodeValue ();
- }
- }
-
-
- // Searching for the datas associated to the childId.
- if (childId == null)
- {
- idsData = null;
- }
- else
- {
- // Check if the data is a IdsDataByIndex.
- if (datas.getId (childId) instanceof IdsDataByIndex)
- {
- idsData = (IdsDataByIndex) datas.getId (childId);
- }
- else
- {
- idsData = null;
- }
+ strategy = IdData.IterationStrategy.ALL_ROWS;
}
}
+ }
+
+ // Iterate.
+ NodeList children = node.getChildNodes();
+ int childrenCount = children.getLength ();
+
+ switch (strategy)
+ {
+ case ONLY_FIRST_ROW:
+ int lineCounter = 0;
+ for (int childIndex = 0; childIndex < childrenCount; childIndex++)
+ {
+ if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
+ {
+ lineCounter += 1;
+ if (lineCounter == 1)
+ {
+ result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput));
+ }
+ }
+ else
+ {
+ result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput));
+ }
+ }
+ break;
- // So, is there?
- if (idsData == null)
+ case ONLY_FIRST_TWO_ROWS:
+ lineCounter = 0;
+ for (int childIndex = 0; childIndex < childrenCount; childIndex++)
{
- for (int i = 0; i < childrenCount; i++)
+ if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
{
- result.append (process (children.item(i), datas, tagsData, webappPath, suffix, errorOutput));
+ lineCounter += 1;
+
+ if ((lineCounter == 1) || (lineCounter == 2))
+ {
+ result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput));
+ }
+ }
+ else
+ {
+ result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput));
}
}
- else
+ break;
+
+ case ONLY_ROWS_WITH_ID:
+ for (int childIndex = 0; childIndex < childrenCount; childIndex++)
{
- switch (idsData.getIterationStrategy ())
+ if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
{
- case ONLY_FIRST_ROW:
- for (int i = 0; i <= childIndex; i++)
- {
- result.append (process (children.item (i), datas, tagsData, webappPath, suffix, errorOutput));
- }
- break;
+ NamedNodeMap attrs2 = children.item (childIndex).getAttributes ();
- case ONLY_ROWS_WITH_ID:
- for (int i = 0; i < childrenCount; i++)
+ if ((attrs2 != null) &&
+ (attrs2.getNamedItem ("id") != null))
{
- NamedNodeMap attrs2 = children.item (i).getAttributes ();
-
- if ((attrs2 != null) &&
- (attrs2.getNamedItem ("id") != null))
- {
- result.append (process (children.item(i), datas, tagsData, webappPath, suffix, errorOutput));
- }
+ result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput));
}
- break;
-
- case ONLY_ROWS_WITHOUT_ID:
- for (int i = 0; i < childrenCount; i++)
- {
- // Process row?
- boolean processRow;
-
- NamedNodeMap attrs2 = children.item (i).getAttributes ();
- if ((attrs2 == null) ||
- (attrs2.getNamedItem ("id") == null))
- {
- result.append (process (children.item(i), datas, tagsData, webappPath, suffix, errorOutput));
- }
- }
- break;
-
- case ALL_ROWS:
- for (int i = 0; i < childrenCount; i++)
- {
- result.append (process (children.item(i), datas, tagsData, webappPath, suffix, errorOutput));
- }
- break;
+ }
+ else
+ {
+ result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput));
}
}
+ break;
+
+ case ONLY_ROWS_WITHOUT_ID:
+ for (int childIndex = 0; childIndex < childrenCount; childIndex++)
+ {
+ if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
+ {
+ NamedNodeMap attrs2 = children.item (childIndex).getAttributes ();
+ if ((attrs2 == null) ||
+ (attrs2.getNamedItem ("id") == null))
+ {
+ result.append (process (children.item(childIndex), datas, tagsData, webappPath, suffix, errorOutput));
+ }
+ }
+ else
+ {
+ result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput));
+ }
+ }
+ break;
+
+ case ALL_ROWS:
+ for (int childIndex = 0; childIndex < childrenCount; childIndex++)
+ {
+ result.append (process (children.item(childIndex), datas, tagsData, webappPath, suffix, errorOutput));
+ }
+ break;
}
//