/** * Digests attributes and child elements of Component element. * @param node the Component element. * @param component the {@link org.dhatim.edisax.model.internal.Component} to populate. * @param namespacePrefix the prefix used to name elements in xml. * @throws org.dhatim.edisax.EDIConfigurationException is thrown when values are badly formatted. */ private void digestComponent(Node node, Component component, String namespacePrefix, MappingNode parent) throws EDIConfigurationException { setValuesForComponent(component, node, namespacePrefix, parent); NodeList nodes = node.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node currentNode = nodes.item(i); if (currentNode.getNodeName().equalsIgnoreCase(namespacePrefix + "sub-component")) { SubComponent subComponent = new SubComponent(); component.getSubComponents().add(subComponent); setValuesForSubComponent(currentNode, subComponent, namespacePrefix, component); } } }
/** * Set values in {@link org.dhatim.edisax.model.internal.SubComponent}. * @param node the {@link org.dhatim.edisax.model.internal.SubComponent} to populate. * @param subComponent the SubComponent element. * @throws org.dhatim.edisax.EDIConfigurationException is thrown when values are badly formatted. */ private void setValuesForSubComponent(Node node, SubComponent subComponent, String namespacePrefix, MappingNode parent) throws EDIConfigurationException { subComponent.setRequired(getNodeValueAsBoolean(node, "required")); setValuesForValueNode(node, subComponent, namespacePrefix, parent); }
startElement(expectedComponent, true); for (int i = 0; i < currentComponentSubComponents.length; i++) { if (expectedSubComponents.get(i).isRequired() && currentComponentSubComponents[i].length() == 0) { throw new EDIParseException(edifactModel.getEdimap(), "Segment [" + segmentCode + "], field " + (fieldIndex + 1) + " (" + field + "), component " + (componentIndex + 1) + " (" + expectedComponent.getXmltag() + "), sub-component " + (i + 1) + " (" + expectedSubComponents.get(i).getXmltag() + ") expected to contain a value. Currently at segment number " + segmentReader.getCurrentSegmentNumber() + ".", expectedSubComponents.get(i), segmentReader.getCurrentSegmentNumber(), segmentReader.getCurrentSegmentFields());
if (expectedSubComponents.get(i).isRequired()) { throwException = true; break;