Could someone help me understand why my list does not have all the children of my element? (JDOM Element class) I wanted to send the items from the list to setters in another Class.
if (attributeValue.equals(name)) {
Object k = element;
if (k instanceof Element) {
Element keyElement = (Element) k;
List keyNameChild = keyElement.getChildren();
Iterator childIterator = keyNameChild.iterator();
while (childIterator.hasNext()) {
System.out.println("count: " + count);
count++;
Object knc = childIterator.next();
if (knc instanceof Element) {
Element keyNameElement = (Element) knc;
String elementName = keyNameElement.getName();
String elementValue = keyNameElement.getValue();
//System.out.println("call #: "+count);
System.out.println("XMLReaderProgressions sends Progressions a elementName and elementValue");
System.out.println("elementName: " + elementName);
System.out.println("elementValue: " + elementValue);
Progression p = new Progression();
p.progressionFields(elementName, elementValue);
System.out.println("back for another name and value");
//count++;
process(keyElement);
}
}
}
}Hi,
Here i need to create XSLT for the XML i shown below.
In this XML the "STMT_RECORD" tag will be repeating and
"DESCR_LINE" tag can vary i.e. this time it is 7. It can be 20 or 30.
I just want to know that how to use loop for "DESCR_LINE".
If i am using xsl:for-each for STMT_RECORD" so am getting only 1st value of "DESCR_LINE"
Please suggest any solution.
Note:- can change XML (if needed)
Here is my XML Code:
2010 02 26Document No.Payment typePayment codePayment detailsCounterparty nameCounterparty addressCounterparty codexxxx,xxyyyx,xxxxxxxx,xxzzzxxxx,xxzzzz,zzyyy
I am very new to XML but if you added a attribute to them it may help find them and stat or stop on one.
I'm looking for a certain element there are 14.
so I need to narrow it down to the with the attribute var "name" (from a selected index of combobox)
when I have the with the attribute matching var "name" I make an object of that element.
I then make a list of all the children of this element there are 51 in the xml.
I go through that list and for each child I collect the name and CDATA value and send it to another class.
Why isn't there anything in my keyNameChildList?
public void inspect(Element element) {
if (!element.isRootElement()) {
//Print a blank line to separate it from the previous
//element
//System.out.println();
}
if (element.getName().equals("keyName")) {
List attributes = element.getAttributes();
Iterator iteratorAttr = attributes.iterator();
while (iteratorAttr.hasNext()) {
Attribute attribute = (Attribute) iteratorAttr.next();
String attributeValue = attribute.getValue();
if (attributeValue.equals(name)) {
Object k = element;
if (k instanceof Element) {
Element keyNameElement = (Element) k;
List keyNameChildList = keyNameElement.getChildren();
Iterator iterator = keyNameChildList.iterator();
while (iterator.hasNext()) {
System.out.println("count: " + count);
count++;
String elementName = keyElement.getName();
String elementValue = keyElement.getValue();
//System.out.println("call #: "+count);
System.out.println("XMLReaderProgressions sends Progressions a elementName and elementValue");
System.out.println("elementName: " + elementName);
System.out.println("elementValue: " + elementValue);
Progression p = new Progression();
p.progressionFields(elementName, elementValue);
System.out.println("back for another name and value");
count++;
}
}
}
}
} else {
process(element);
}
}