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:

<STMT>
<STMT_RECORD>
<TRANS_DATE>2010 02 26</TRANS_DATE>

<DESCR_LINE>Document No.</DESCR_LINE>
<DESCR_LINE>Payment type</DESCR_LINE>
<DESCR_LINE>Payment code</DESCR_LINE>
<DESCR_LINE>Payment details</DESCR_LINE>
<DESCR_LINE>Counterparty name</DESCR_LINE>
<DESCR_LINE>Counterparty address</DESCR_LINE>
<DESCR_LINE>Counterparty code</DESCR_LINE>

<ORIG_PAYMENT_AMT>xxxx,xx</ORIG_PAYMENT_AMT>

<ORIG_PAYMENT_CCY>yyy</ORIG_PAYMENT_CCY>

<EXCH_RATE>x,xxxx</EXCH_RATE>

<ACC_PAYMENT_AMT>xxxx,xx</ACC_PAYMENT_AMT>

<ACC_PAYMENT_CCY>zzz</ACC_PAYMENT_CCY>

<LTL_PAYMENT_AMT>xxxx,xx</LTL_PAYMENT_AMT>

<RUN_BAL_AMT>zzzz,zz</RUN_BAL_AMT>

<RUN_BAL_CCY>yyy</RUN_BAL_CCY>

</STMT_RECORD>
</STMT>

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 <keyName> there are 14.
so I need to narrow it down to the <keyName> with the attribute var "name" (from a selected index of combobox)

when I have the <keyName> 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);
        }
    }
This article has been dead for over six months. Start a new discussion instead.