private static void adjustChoiceMaxSiblings(ISchemaCompositor compositor, HashMap<String, Integer> siblings) { if (isSimpleChoice(compositor)) { // Supported // Update all child element occurrences of the choice compositor // to the number of occurrences found // Each choice occurrence counts as one occurrence for all child elements // of that choice int childElementCount = countChoiceElementChildren(compositor, siblings); updateChoiceElementChildren(compositor, siblings, childElementCount); } else { // Not supported // IMPORTANT: Any child of choice that is not an element (e.g. // sequence, choice) is not supported, in future could recursively // calculate, but time vs benefit is not worth it // Remove all elements nested in compositors from validation check // by setting their occurrences to integer MIN updateChoiceElementChildren(compositor, siblings, Integer.MIN_VALUE); } }
/** * @param sElement * @param element * @return A set of elements that are first-level children of * <code>element</code>, that violate max occurence rules defined by * <code>sElement</code>. */ public static HashSet<ElementOccurrenceResult> findMaxOccurenceViolations(ISchemaElement sElement, Element element) { // Calculate the number of occurrences of each XML tag name // in the node's direct children HashMap<String, Integer> tagNameMap = countXMLChildrenByTagName(element); return processChildrenMax(sElement, tagNameMap, element); }
private static void processObjectMax(ISchemaObject schemaObject, HashSet<ElementOccurrenceResult> elementSet, HashMap<String, Integer> siblings, int multiplicityTracker, Element element) { if (schemaObject instanceof ISchemaElement) { ISchemaElement schemaElement = (ISchemaElement) schemaObject; Element childElement = findChildElement(element, schemaElement.getName()); if (childElement != null) { processElementMax(schemaElement, elementSet, siblings, multiplicityTracker, childElement); } } else if (schemaObject instanceof ISchemaCompositor) { ISchemaCompositor sCompositor = (ISchemaCompositor) schemaObject; processCompositorMax(sCompositor, elementSet, siblings, multiplicityTracker, element); } }
/** * @param sElement * @param element * @return A set of elements that are first-level children of * <code>element</code>, that violate min occurence rules defined by * <code>sElement</code>. */ public static HashSet<ElementOccurrenceResult> findMinOccurenceViolations(ISchemaElement sElement, Element element) { // Calculate the number of occurrences of each XML tag name // in the node's direct children HashMap<String, Integer> tagNameMap = countXMLChildrenByTagName(element); return processChildrenMin(sElement, tagNameMap); }
private static void processChoiceMin(ISchemaCompositor compositor, HashSet<ElementOccurrenceResult> elementSet, HashMap<String, Integer> siblings, int multiplicityTracker) { // Unbounded min occurs are represented by the maximum integer value if (multiplicityTracker < Integer.MAX_VALUE) { // Multiply the min occurs amount to the overall multiplicity multiplicityTracker = compositor.getMinOccurs() * multiplicityTracker; } adjustChoiceMinSiblings(compositor, siblings); ISchemaObject[] schemaObject = compositor.getChildren(); // Process the compositors children for (int i = 0; i < compositor.getChildCount(); i++) { processObjectMin(schemaObject[i], elementSet, siblings, multiplicityTracker); } }
private static void processChoiceMax(ISchemaCompositor compositor, HashSet<ElementOccurrenceResult> elementSet, HashMap<String, Integer> siblings, int multiplicityTracker, Element element) { // Unbounded max occurs are represented by the maximum integer value if (multiplicityTracker < Integer.MAX_VALUE) { // Multiply the max occurs amount to the overall multiplicity multiplicityTracker = compositor.getMaxOccurs() * multiplicityTracker; } adjustChoiceMaxSiblings(compositor, siblings); ISchemaObject[] schemaObject = compositor.getChildren(); // Process the compositors children for (int i = 0; i < compositor.getChildCount(); i++) { processObjectMax(schemaObject[i], elementSet, siblings, multiplicityTracker, element); } }
/** * @param element * @param schemaElement */ private void validateMinElementMult(Element element, ISchemaElement schemaElement) { // Validate min element occurence violations int minSeverity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT); if (minSeverity != CompilerFlags.IGNORE) { HashSet<?> minElementSet = ElementOccurenceChecker.findMinOccurenceViolations(schemaElement, element); Iterator<?> minIterator = minElementSet.iterator(); while (minIterator.hasNext()) { reportMinOccurenceViolation(element, (ElementOccurrenceResult) minIterator.next(), minSeverity); } } }
/** * @param element * @param schemaElement */ private void validateMaxElementMult(Element element, ISchemaElement schemaElement) { // Validate max element occurence violations int maxSeverity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT); if (maxSeverity != CompilerFlags.IGNORE) { HashSet<?> maxElementSet = ElementOccurenceChecker.findMaxOccurenceViolations(schemaElement, element); Iterator<?> maxIterator = maxElementSet.iterator(); while (maxIterator.hasNext()) { reportMaxOccurenceViolation((ElementOccurrenceResult) maxIterator.next(), maxSeverity); } } }
/** * @param sElement * @param element * @return A set of elements that are first-level children of * <code>element</code>, that violate min occurence rules defined by * <code>sElement</code>. */ public static HashSet findMinOccurenceViolations(ISchemaElement sElement, Element element) { // Calculate the number of occurrences of each XML tag name // in the node's direct children HashMap tagNameMap = countXMLChildrenByTagName(element); return processChildrenMin(sElement, tagNameMap); }
/** * @param compositor * @param elementSet * @param siblings * @param multiplicityTracker */ private static void processChoiceMin( ISchemaCompositor compositor, HashSet elementSet, HashMap siblings, int multiplicityTracker) { // Unbounded min occurs are represented by the maximum integer value if (multiplicityTracker < Integer.MAX_VALUE) { // Multiply the min occurs amount to the overall multiplicity multiplicityTracker = compositor.getMinOccurs() * multiplicityTracker; } adjustChoiceMinSiblings(compositor, siblings); ISchemaObject[] schemaObject = compositor.getChildren(); // Process the compositors children for (int i = 0; i < compositor.getChildCount(); i++) { processObjectMin(schemaObject[i], elementSet, siblings, multiplicityTracker); } }
/** * @param compositor * @param elementSet * @param siblings * @param multiplicityTracker */ private static void processChoiceMax( ISchemaCompositor compositor, HashSet elementSet, HashMap siblings, int multiplicityTracker, Element element) { // Unbounded max occurs are represented by the maximum integer value if (multiplicityTracker < Integer.MAX_VALUE) { // Multiply the max occurs amount to the overall multiplicity multiplicityTracker = compositor.getMaxOccurs() * multiplicityTracker; } adjustChoiceMaxSiblings(compositor, siblings); ISchemaObject[] schemaObject = compositor.getChildren(); // Process the compositors children for (int i = 0; i < compositor.getChildCount(); i++) { processObjectMax(schemaObject[i], elementSet, siblings, multiplicityTracker, element); } }
/** * @param element * @param schemaElement */ private void validateMinElementMult(Element element, ISchemaElement schemaElement) { // Validate min element occurence violations int minSeverity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT); if (minSeverity != CompilerFlags.IGNORE) { HashSet minElementSet = ElementOccurenceChecker .findMinOccurenceViolations(schemaElement, element); Iterator minIterator = minElementSet.iterator(); while (minIterator.hasNext()) { reportMinOccurenceViolation(element, (ElementOccurrenceResult) minIterator.next(), minSeverity); } } }
/** * @param element * @param schemaElement */ private void validateMaxElementMult(Element element, ISchemaElement schemaElement) { // Validate max element occurence violations int maxSeverity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT); if (maxSeverity != CompilerFlags.IGNORE) { HashSet maxElementSet = ElementOccurenceChecker .findMaxOccurenceViolations(schemaElement, element); Iterator maxIterator = maxElementSet.iterator(); while (maxIterator.hasNext()) { reportMaxOccurenceViolation( (ElementOccurrenceResult) maxIterator.next(), maxSeverity); } } }
private static void adjustChoiceMinSiblings(ISchemaCompositor compositor, HashMap<String, Integer> siblings) { if (isSimpleChoice(compositor)) { // Supported // Update all child element occurrences of the choice compositor // to the number of occurrences found // Each choice occurrence counts as one occurrence for all child elements // of that choice int childElementCount = countChoiceElementChildren(compositor, siblings); updateChoiceElementChildren(compositor, siblings, childElementCount); } else { // Not supported // IMPORTANT: Any child of choice that is not an element (e.g. // sequence, choice) is not supported, in future could recursively // caculate, but time vs benefit is not worth it // Remove all elements nested in compositors from validation check // by setting their occurrences to integer MAX updateChoiceElementChildren(compositor, siblings, Integer.MAX_VALUE); } }
/** * @param schemaObject * @param proposalList * @param siblings * @param multiplicityTracker */ private static void processObjectMax(ISchemaObject schemaObject, HashSet elementSet, HashMap siblings, int multiplicityTracker, Element element) { if (schemaObject instanceof ISchemaElement) { ISchemaElement schemaElement = (ISchemaElement)schemaObject; Element childElement = findChildElement(element, schemaElement.getName()); if (childElement != null) { processElementMax(schemaElement, elementSet, siblings, multiplicityTracker, childElement); } } else if (schemaObject instanceof ISchemaCompositor) { ISchemaCompositor sCompositor = (ISchemaCompositor)schemaObject; processCompositorMax(sCompositor, elementSet, siblings, multiplicityTracker, element); } }
/** * @param sElement * @param element * @return A set of elements that are first-level children of * <code>element</code>, that violate max occurence rules defined by * <code>sElement</code>. */ public static HashSet findMaxOccurenceViolations(ISchemaElement sElement, Element element) { // Calculate the number of occurrences of each XML tag name // in the node's direct children HashMap tagNameMap = countXMLChildrenByTagName(element); return processChildrenMax(sElement, tagNameMap, element); }
/** * @param compositor * @param siblings */ private static void adjustChoiceMaxSiblings(ISchemaCompositor compositor, HashMap siblings) { if (isSimpleChoice(compositor)) { // Supported // Update all child element occurrences of the choice compositor // to the number of occurences found // Each choice occurence counts as one occurence for all child elements // of that choice int childElementCount = countChoiceElementChildren(compositor, siblings); updateChoiceElementChildren(compositor, siblings, childElementCount); } else { // Not supported // IMPORTANT: Any child of choice that is not an element (e.g. // sequence, choice) is not supported, in future could recursively // caculate, but time vs benefit is not worth it // Remove all elements nested in compositors from validation check // by setting their occurrences to integer MIN updateChoiceElementChildren(compositor, siblings, Integer.MIN_VALUE); } }
/** * @param compositor * @param siblings */ private static void adjustChoiceMinSiblings(ISchemaCompositor compositor, HashMap siblings) { if (isSimpleChoice(compositor)) { // Supported // Update all child element occurrences of the choice compositor // to the number of occurences found // Each choice occurence counts as one occurence for all child elements // of that choice int childElementCount = countChoiceElementChildren(compositor, siblings); updateChoiceElementChildren(compositor, siblings, childElementCount); } else { // Not supported // IMPORTANT: Any child of choice that is not an element (e.g. // sequence, choice) is not supported, in future could recursively // caculate, but time vs benefit is not worth it // Remove all elements nested in compositors from validation check // by setting their occurrences to integer MAX updateChoiceElementChildren(compositor, siblings, Integer.MAX_VALUE); } }