public void allowedAttributes(Node node, String[] allowed) { NodeList attributes = selectNodeList(node, "@*"); String unexpectedAttribute = unexpected(attributes, allowed); if (unexpectedAttribute != null) { //Unexpected attribute '{0}' found in '{1}'. ConfigurationException ex = new ConfigurationException(); Object[] args = {unexpectedAttribute, node.getNodeName(), getSourceFilename(node)}; ex.setMessage(UNEXPECTED_ATTRIBUTE, args); throw ex; } }
/** * Check whether the required items are present in the current node as attributes. * * @param node the current Node object * @param allowed the String array of the allowed items **/ public void allowedAttributes(Node node, String[] allowed) { NodeList attributes = selectNodeList(node, "@*"); String unexpectedAttribute = unexpected(attributes, allowed); if (unexpectedAttribute != null) { //Unexpected attribute '{0}' found in '{1}'. ConfigurationException ex = new ConfigurationException(); Object[] args = {unexpectedAttribute, node.getNodeName(), getSourceFilename(node)}; ex.setMessage(UNEXPECTED_ATTRIBUTE, args); throw ex; } }
public void allowedChildElements(Node node, String[] allowed) { NodeList children = selectNodeList(node, "*"); String unexpected = unexpected(children, allowed); if (unexpected != null) { // Unexpected child element '{0}' found in '{1}'. ConfigurationException ex = new ConfigurationException(); Object[] args = {unexpected, node.getNodeName(), getSourceFilename(node)}; ex.setMessage(UNEXPECTED_ELEMENT, args); throw ex; } NodeList textNodes = selectNodeList(node, "text()"); for (int i = 0; i < textNodes.getLength(); i++) { String text = evaluateExpression(textNodes.item(i), ".").toString().trim(); if (text.length() > 0) { //Unexpected text '{0}' found in '{1}'. ConfigurationException ex = new ConfigurationException(); Object[] args = {text, node.getNodeName(), getSourceFilename(node)}; ex.setMessage(UNEXPECTED_TEXT, args); throw ex; } } }
/** * Check whether the required items are present in the current node as attributes. * * @param node the current Node object * @param allowed the String array of the allowed items **/ public void allowedAttributes(Node node, String[] allowed) { NodeList attributes = selectNodeList(node, "@*"); String unexpectedAttribute = unexpected(attributes, allowed); if (unexpectedAttribute != null) { //Unexpected attribute '{0}' found in '{1}'. ConfigurationException ex = new ConfigurationException(); Object[] args = {unexpectedAttribute, node.getNodeName(), getSourceFilename(node)}; ex.setMessage(UNEXPECTED_ATTRIBUTE, args); throw ex; } }
String unexpected = unexpected(children, allowed); if (unexpected != null)
String unexpected = unexpected(children, allowed); if (unexpected != null)