private void emitNewTag(String tag) throws SAXException { String previousElement = null; // retrieve the actual previous element int index = elementStack.size(); while (previousElement == null) { if (!elementStack.empty()) { index--; previousElement = (String) elementStack.elementAt(index); } else { previousElement = ""; // exit, to avoid endless loop } if (previousElement.equals(kTag) || previousElement.equals(kTaggedValue) || previousElement.equals(ktaggedValue)) { previousElement = null; // continue to search } } // ignore if not known in Srx format int prevSrxId = XmiMapping.getSrxId(previousElement); if (!enabledOutput) { return; } if (prevSrxId != XmiMapping.UNKNOWN) { int attrId = XmiMapping.getAttrId(prevSrxId, tag); if (attrId != XmiMapping.UNKNOWN) { String mappedAttr = XmiMapping.getMappedAttr(prevSrxId, attrId); emit(mappedAttr + " "); tagFound = true; } } expectingTarget = true; }
public void startElement(String tag, AttributeList attrs) throws SAXException { if (isDebug) emit("start element" + eol); // NOT LOCALIZABLE // keep previous element before adding a new one String previousElement = ""; if (!elementStack.empty()) { previousElement = (String) elementStack.peek(); } elementStack.push(tag); if (tag.equals(kTaggedValue)) { taggedValueMode = true; return; } // ignore <tag> and <value> if outside a <TaggedValue> block if (taggedValueMode) { if (tag.equals(kTag)) { expectingTag = true; } else if (tag.equals(kValue)) { expectingTagValue = true; } } int srxId = XmiMapping.getSrxId(tag); boolean isOccurrenceType = (srxId != XmiMapping.UNKNOWN); if (isOccurrenceType) { emitNewOccurrence(srxId, attrs); } else { if (!enabledOutput) { return; } // if tag = 'NAME' and currentXmiName expected is also 'NAME' if (tag.equals(currentXmiName)) { // ignore if not known in Srx format int prevSrxId = XmiMapping.getSrxId(previousElement); if (prevSrxId != XmiMapping.UNKNOWN) { expectingNameValue = true; } } else if (tag.equals(kXmiReference)) { emitReferencedValue(attrs); } else { // ignore if not known in Srx format int prevSrxId = XmiMapping.getSrxId(previousElement); if (currentSrxId != XmiMapping.UNKNOWN) { int attrId = XmiMapping.getAttrId(currentSrxId, tag); if (attrId != XmiMapping.UNKNOWN) { String mappedAttr = XmiMapping.getMappedAttr(currentSrxId, attrId); if (mappedAttr.equals(MULTIPLICITY)) { // Special case for multiplicity expectingMultiplicity = true; } else if (mappedAttr.equals(ORIGINTABLE)) { // Special case for origin table expectingOriginTable = true; expectingTarget = true; } else if (mappedAttr.equals(TARGETTABLE)) { // Special case for target table expectingTargetTable = true; expectingTarget = true; } else { emit(mappedAttr + " "); expectingTarget = true; } // end if } // end if } // end if } // end if } // end if } // end startElement()