|
GlobalContainer - in graphical mapping (XI) Michal Krawczyk There are times when we want to create many tags from just one source tag - imagine situation, when we get serial numbers as a range (from, to) and we have to create one tag for each serial number. and we want to create a Dest_line for each number in a range from source XML structure:
If we want to create many tags we have to remember that producing only Number's will not be enough because we also have to create the same number of Dest_line's.
GlobalContainer globalContainer = container.getGlobalContainer(); int from = Integer.parseInt(a[0]); int to = Integer.parseInt(b[0]); ArrayList list = new ArrayList(); for (int i=from;i<=to;i++) { String s = String.valueOf(i); list.add(s); result.addValue(s); } globalContainer.setParameter("our_number", list.toArray(new String[0])); Then we can use values from our container to fill the Number tag. The code below inserts values from the container into the result of our function (getContainer): GlobalContainer globalContainer1 = container.getGlobalContainer(); String[] b = (String[]) globalContainer1.getParameter("our_number"); for (int i=0; i<b.length; i++) { result.addValue(b[i]); } |
|