private Field parseGroupField(final NodeList nodeList, final int nodeIndex) throws XPathExpressionException { final String dimensionTypeName = getAttributeValue(nodeList.item(nodeIndex), "dimensionType", "groupSizeEncoding"); Type dimensionType = typeByNameMap.get(dimensionTypeName); if (dimensionType == null) { handleError(nodeList.item(nodeIndex), "could not find dimensionType: " + dimensionTypeName); } else if (!(dimensionType instanceof CompositeType)) { handleError(nodeList.item(nodeIndex), "dimensionType should be a composite type: " + dimensionTypeName); dimensionType = null; } else { ((CompositeType)dimensionType).checkForWellFormedGroupSizeEncoding(nodeList.item(nodeIndex)); } final Field field = new Field.Builder() .name(getAttributeValue(nodeList.item(nodeIndex), "name")) .description(getAttributeValueOrNull(nodeList.item(nodeIndex), "description")) .id(Integer.parseInt(getAttributeValue(nodeList.item(nodeIndex), "id"))) .blockLength(Integer.parseInt(getAttributeValue(nodeList.item(nodeIndex), "blockLength", "0"))) .sinceVersion(Integer.parseInt(getAttributeValue(nodeList.item(nodeIndex), "sinceVersion", "0"))) .dimensionType((CompositeType)dimensionType) .build(); XmlSchemaParser.checkForValidName(nodeList.item(nodeIndex), field.name()); field.groupFields(parseFieldsAndGroups(nodeList.item(nodeIndex))); // recursive call return field; }
/** * Construct a new message from XML Schema. * * @param messageNode from the XML Schema Parsing * @param typeByNameMap holding type information for message * @throws XPathExpressionException on invalid XPath */ public Message(final Node messageNode, final Map<String, Type> typeByNameMap) throws XPathExpressionException { id = Integer.parseInt(getAttributeValue(messageNode, "id")); // required name = getAttributeValue(messageNode, "name"); // required description = getAttributeValueOrNull(messageNode, "description"); // optional blockLength = Integer.parseInt(getAttributeValue(messageNode, "blockLength", "0")); // 0 means not set semanticType = getAttributeValueOrNull(messageNode, "semanticType"); // optional headerType = getAttributeValue(messageNode, "headerType", "messageHeader"); // has default this.typeByNameMap = typeByNameMap; fieldList = parseFieldsAndGroups(messageNode); computeAndValidateOffsets(messageNode, fieldList, blockLength); computedBlockLength = computeMessageRootBlockLength(); validateBlockLength(messageNode, blockLength, computedBlockLength); }