@Override public Object createObject(Attributes attributes) throws Exception { String nodeType = attributes.getValue("type"); if (nodeType == null || "".equals(nodeType)) { // uses Node.ELEMENT_NODE return new NodeCreateRule(); } else if ("element".equals(nodeType)) { return new NodeCreateRule(Node.ELEMENT_NODE); } else if ("fragment".equals(nodeType)) { return new NodeCreateRule(Node.DOCUMENT_FRAGMENT_NODE); } else { throw new RuntimeException( "Unrecognized node type: " + nodeType + ". This attribute is optional or can have a value of element|fragment."); } } }
/** * Checks whether control needs to be returned to Digester. * * @param namespaceURI the namespace URI * @param localName the local name * @param qName the qualified (prefixed) name * @throws SAXException if the DOM implementation throws an exception */ @Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException { addTextIfPresent(); try { if (depth == 0) { getDigester().setCustomContentHandler(oldContentHandler); getDigester().push(root); getDigester().endElement(namespaceURI, localName, qName); } top = top.getParentNode(); depth--; } catch (DOMException e) { throw new SAXException(e.getMessage()); } }
/** * @see Rule#begin(String, String, Attributes) */ public final void begin(final String namespace, final String name, final Attributes attributes) throws Exception { super.begin(namespace, name, attributes); src = attributes.getValue("src"); expr = attributes.getValue("expr"); if (!SCXMLHelper.isStringEmpty(src)) { String path = null; if (pr == null) { path = src; } else { path = pr.resolvePath(src); } try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory. newInstance(); DocumentBuilder db = dbFactory.newDocumentBuilder(); attrNode = db.parse(path); } catch (Throwable t) { // you read that correctly org.apache.commons.logging.Log log = LogFactory. getLog(SCXMLDigester.class); log.error(t.getMessage(), t); } return; } }
/** * @see Rule#begin(String, String, Attributes) */ public final void begin(final String namespace, final String name, final Attributes attributes) throws Exception { super.begin(namespace, name, attributes); src = attributes.getValue("src"); expr = attributes.getValue("expr"); if (!SCXMLHelper.isStringEmpty(src)) { String path = null; if (pr == null) { path = src; } else { path = pr.resolvePath(src); } try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory. newInstance(); DocumentBuilder db = dbFactory.newDocumentBuilder(); attrNode = db.parse(path); } catch (Throwable t) { // you read that correctly org.apache.commons.logging.Log log = LogFactory. getLog(SCXMLParser.class); log.error(t.getMessage(), t); } return; } }
if (nodeType == Node.ELEMENT_NODE) { Element element = null; if (getDigester().getNamespaceAware()) { element = doc.createElementNS(namespaceURI, name); getDigester().setCustomContentHandler(builder);
/** * <p>Ensure that the object at the top of the stack is a * <code>DescriptionBean</code>, then perform the standard * superclass processing.</p> * * @param namespace the namespace URI of the matching element, or an * empty string if the parser is not namespace aware or the element has * no namespace * @param name the local name if the parser is namespace aware, or just * the element name otherwise * @param attributes The attribute list of this element * * @exception IllegalStateException if the parent stack element is not * of type FeatureBean */ public void begin(String namespace, String name, Attributes attributes) throws Exception { assert digester.peek() instanceof DescriptionBean : "Assertion Error: Expected DescriptionBean to be at the top of the stack"; // Perform our standard superclass processing if (digester.getLogger().isDebugEnabled()) { digester.getLogger().debug("[DescriptionTextRule]{" + digester.getMatch() + "} Begin"); } super.begin(namespace, name, attributes); }
public Object createObject(Attributes attributes) throws Exception { String nodeType = attributes.getValue("type"); if (nodeType == null || "".equals(nodeType)) { // uses Node.ELEMENT_NODE return new NodeCreateRule(); } else if ("element".equals(nodeType)) { return new NodeCreateRule(Node.ELEMENT_NODE); } else if ("fragment".equals(nodeType)) { return new NodeCreateRule(Node.DOCUMENT_FRAGMENT_NODE); } else { throw new RuntimeException( "Unrecognized node type: " + nodeType + ". This attribute is optional or can have a value of element|fragment."); } } }
/** * Checks whether control needs to be returned to Digester. * * @param namespaceURI the namespace URI * @param localName the local name * @param qName the qualified (prefixed) name * @throws SAXException if the DOM implementation throws an exception */ public void endElement(String namespaceURI, String localName, String qName) throws SAXException { addTextIfPresent(); try { if (depth == 0) { getDigester().setCustomContentHandler(oldContentHandler); getDigester().push(root); getDigester().endElement(namespaceURI, localName, qName); } top = top.getParentNode(); depth--; } catch (DOMException e) { throw new SAXException(e.getMessage()); } }
if (nodeType == Node.ELEMENT_NODE) { Element element = null; if (getDigester().getNamespaceAware()) { element = doc.createElementNS(namespaceURI, name); getDigester().setCustomContentHandler(builder);