/** * Required element. * * @param tag required tag * @param xmlElement handler * @throws Exception exception */ public void required(@Nonnull final String tag, @Nonnull final XmlProcessor xmlElement) throws Exception { if (isEndTag()) { throw new Exception("found end tag but required tag [" + tag + "]"); } if (!matchesTag(tag)) { throw new Exception("Expected tag [" + tag + "] but was [" + xpp.getName() + "]"); } processElement(xmlElement); nextTag(); }
/** * One or more element. * * @param tag element tag * @param xmlElement handler * @throws Exception exception */ public void oneOrMore(@Nonnull final String tag, @Nonnull final XmlProcessor xmlElement) throws Exception { if (isEndTag()) { throw new Exception("End tag reached but was expecting [" + tag + "]"); } if (!matchesTag(tag)) { throw new Exception("Expected tag [" + tag + "] but was [" + xpp.getName() + "]"); } processElement(xmlElement); nextTag(); zeroOrMore(tag, xmlElement); }
/** * Optional element. * * @param tag required tag * @param xmlElement handler * @throws Exception exception */ public void optional(@Nonnull final String tag, @Nonnull final XmlProcessor xmlElement) throws Exception { if (isEndTag()) { return; } if (!matchesTag(tag)) { return; } processElement(xmlElement); nextTag(); }
/** * Zero or more element. * * @param tag element tag * @param xmlElement handler * @throws Exception exception */ public void zeroOrMore(@Nonnull final String tag, @Nonnull final XmlProcessor xmlElement) throws Exception { if (isEndTag()) { return; } if (!matchesTag(tag)) { return; } processElement(xmlElement); nextTag(); zeroOrMore(tag, xmlElement); }
/** * SubstitionGroup Support. * * @param substGroup SubstitutionGroup * @throws Exception exception */ public void zeroOrMore(@Nonnull final SubstitutionGroup substGroup) throws Exception { if (isEndTag()) { return; } XmlProcessor element = substGroup.matches(xpp.getName()); if (element == null) { return; } processElement(element); nextTag(); zeroOrMore(substGroup); }