List of usage examples for org.w3c.dom Element getTagName
public String getTagName();
From source file:org.etudes.ambrosia.impl.UiServiceImpl.java
/** * Check the element's tag for a known Component tag, and create the component from the tag. * // w w w .j av a 2s . c o m * @param xml * The element. */ protected Component parseComponent(Element xml) { if (xml.getTagName().equals("alert")) return new UiAlert(this, xml); if (xml.getTagName().equals("alias")) return new UiAlias(this, xml); if (xml.getTagName().equals("attachments")) return new UiAttachments(this, xml); if (xml.getTagName().equals("attachmentsEdit")) return new UiAttachmentsEdit(this, xml); if (xml.getTagName().equals("countdownTimer")) return new UiCountdownTimer(this, xml); if (xml.getTagName().equals("countEdit")) return new UiCountEdit(this, xml); if (xml.getTagName().equals("courier")) return new UiCourier(this, xml); if (xml.getTagName().equals("container")) return new UiContainer(this, xml); if (xml.getTagName().equals("dateEdit")) return new UiDateEdit(this, xml); if (xml.getTagName().equals("divider")) return new UiDivider(this, xml); if (xml.getTagName().equals("durationEdit")) return new UiDurationEdit(this, xml); if (xml.getTagName().equals("entityActionBar")) return new UiEntityActionBar(this, xml); if (xml.getTagName().equals("entityDisplay")) return new UiEntityDisplay(this, xml); if (xml.getTagName().equals("entityList")) return new UiEntityList(this, xml); if (xml.getTagName().equals("floatEdit")) return new UiFloatEdit(this, xml); if (xml.getTagName().equals("fileUpload")) return new UiFileUpload(this, xml); if (xml.getTagName().equals("fillIn")) return new UiFillIn(this, xml); if (xml.getTagName().equals("finePrint")) return new UiFinePrint(this, xml); if (xml.getTagName().equals("fragment")) return new UiFragment(this, xml); if (xml.getTagName().equals("gap")) return new UiGap(this, xml); if (xml.getTagName().equals("hidden")) return new UiHidden(this, xml); if (xml.getTagName().equals("htmlEdit")) return new UiHtmlEdit(this, xml); if (xml.getTagName().equals("iconKey")) return new UiIconKey(this, xml); if (xml.getTagName().equals("instructions")) return new UiInstructions(this, xml); if (xml.getTagName().equals("interface")) return new UiInterface(this, xml); if (xml.getTagName().equals("menuBar")) return new UiMenuBar(); if (xml.getTagName().equals("modeBar")) return new UiModeBar(this, xml); if (xml.getTagName().equals("modelComponent")) return new UiModelComponent(this, xml); if (xml.getTagName().equals("navigation")) return new UiNavigation(this, xml); if (xml.getTagName().equals("navigationBar")) return new UiNavigationBar(this, xml); if (xml.getTagName().equals("overlay")) return new UiOverlay(this, xml); if (xml.getTagName().equals("pager")) return new UiPager(this, xml); if (xml.getTagName().equals("password")) return new UiPassword(this, xml); if (xml.getTagName().equals("section")) return new UiSection(this, xml); if (xml.getTagName().equals("selection")) return new UiSelection(this, xml); if (xml.getTagName().equals("text")) return new UiText(this, xml); if (xml.getTagName().equals("textEdit")) return new UiTextEdit(this, xml); if (xml.getTagName().equals("toggle")) return new UiToggle(this, xml); if (xml.getTagName().equals("view")) return new UiInterface(this, xml); if (xml.getTagName().equals("warning")) return new UiWarning(this, xml); return null; }
From source file:org.etudes.ambrosia.impl.UiServiceImpl.java
/** * Create the appropriate Decision based on the XML element. * /*from w w w . ja va 2 s. c om*/ * @param xml * The xml element. * @return a Decision object. */ protected Decision parseDecision(Element xml) { if (xml == null) return null; if (xml.getTagName().equals("hasValueDecision")) return new UiHasValueDecision(this, xml); if (xml.getTagName().equals("compareDecision")) return new UiCompareDecision(this, xml); if (xml.getTagName().equals("andDecision")) return new UiAndDecision(this, xml); if (xml.getTagName().equals("orDecision")) return new UiOrDecision(this, xml); if (xml.getTagName().equals("pastDateDecision")) return new UiPastDateDecision(this, xml); if (xml.getTagName().equals("trueDecision")) return new UiTrueDecision(this, xml); if (!xml.getTagName().equals("decision")) return null; String type = StringUtil.trimToNull(xml.getAttribute("type")); if ("hasValue".equals(type)) return new UiHasValueDecision(this, xml); if ("compare".equals(type)) return new UiCompareDecision(this, xml); if ("and".equals(type)) return new UiAndDecision(this, xml); if ("or".equals(type)) return new UiOrDecision(this, xml); if ("pastDate".equals(type)) return new UiPastDateDecision(this, xml); if ("true".equals(type)) return new UiTrueDecision(this, xml); return new UiDecision(this, xml); }
From source file:org.etudes.ambrosia.impl.UiServiceImpl.java
/** * Create the appropriate EntityDisplayRow based on the XML element. * /*from w w w . j av a 2 s. c o m*/ * @param xml * The xml element. * @return a PropertyRow object. */ protected EntityDisplayRow parseEntityDisplayRow(Element xml) { if (xml == null) return null; // if (xml.getTagName().equals("modelColumn")) return new UiPropertyColumn(this, xml); if (!xml.getTagName().equals("row")) return null; // TODO: support types? String type = StringUtil.trimToNull(xml.getAttribute("type")); // if ("model".equals(type)) return new UiPropertyColumn(this, xml); return new UiEntityDisplayRow(this, xml); }
From source file:org.etudes.ambrosia.impl.UiServiceImpl.java
/** * Create the appropriate EntityListColumn based on the XML element. * /*from ww w .j ava 2 s .com*/ * @param xml * The xml element. * @return a EntityListColumn object. */ protected EntityListColumn parseEntityListColumn(Element xml) { if (xml == null) return null; if (xml.getTagName().equals("autoColumn")) return new UiAutoColumn(this, xml); if (xml.getTagName().equals("modelColumn")) return new UiPropertyColumn(this, xml); if (xml.getTagName().equals("orderColumn")) return new UiOrderColumnSelect(this, xml); if (xml.getTagName().equals("selectionColumn")) return new UiSelectionColumn(this, xml); if (!xml.getTagName().equals("column")) return null; String type = StringUtil.trimToNull(xml.getAttribute("type")); if ("auto".equals(type)) return new UiAutoColumn(this, xml); if ("model".equals(type)) return new UiPropertyColumn(this, xml); if ("order".equals(type)) return new UiOrderColumnSelect(this, xml); if ("selection".equals(type)) return new UiSelectionColumn(this, xml); return new UiEntityListColumn(this, xml); }
From source file:org.etudes.ambrosia.impl.UiServiceImpl.java
/** * Create the appropriate PropertyReference based on the XML element. * /* w w w . j a v a 2 s . c o m*/ * @param xml * The xml element. * @return a PropertyReference object. */ protected PropertyReference parsePropertyReference(Element xml) { if (xml == null) return null; if (xml.getTagName().equals("booleanModel")) return new UiBooleanPropertyReference(this, xml); if (xml.getTagName().equals("constantModel")) return new UiConstantPropertyReference(this, xml); if (xml.getTagName().equals("contextInfoModel")) return new UiContextInfoPropertyReference(this, xml); if (xml.getTagName().equals("countModel")) return new UiCountPropertyReference(this, xml); if (xml.getTagName().equals("dateModel")) return new UiDatePropertyReference(this, xml); if (xml.getTagName().equals("durationModel")) return new UiDurationPropertyReference(this, xml); if (xml.getTagName().equals("floatModel")) return new UiFloatPropertyReference(this, xml); if (xml.getTagName().equals("htmlModel")) return new UiHtmlPropertyReference(this, xml); if (xml.getTagName().equals("iconModel")) return new UiIconPropertyReference(this, xml); if (xml.getTagName().equals("imageModel")) return new UiImagePropertyReference(this, xml); if (xml.getTagName().equals("pagingModel")) return new UiPagingPropertyReference(this, xml); if (xml.getTagName().equals("textModel")) return new UiTextPropertyReference(this, xml); if (xml.getTagName().equals("urlModel")) return new UiUrlPropertyReference(this, xml); if (xml.getTagName().equals("userInfoModel")) return new UiUserInfoPropertyReference(this, xml); if (xml.getTagName().equals("enumModel")) return new UiEnumPropertyReference(this, xml); if (xml.getTagName().equals("componentModel")) return new UiComponentPropertyReference(this, xml); if (!xml.getTagName().equals("model")) return null; String type = StringUtil.trimToNull(xml.getAttribute("type")); if ("boolean".equals(type)) return new UiBooleanPropertyReference(this, xml); if ("constant".equals(type)) return new UiConstantPropertyReference(this, xml); if ("contextInfo".equals(type)) return new UiContextInfoPropertyReference(this, xml); if ("count".equals(type)) return new UiCountPropertyReference(this, xml); if ("date".equals(type)) return new UiDatePropertyReference(this, xml); if ("duration".equals(type)) return new UiDurationPropertyReference(this, xml); if ("float".equals(type)) return new UiFloatPropertyReference(this, xml); if ("html".equals(type)) return new UiHtmlPropertyReference(this, xml); if ("icon".equals(type)) return new UiIconPropertyReference(this, xml); if ("image".equals(type)) return new UiImagePropertyReference(this, xml); if ("paging".equals(type)) return new UiPagingPropertyReference(this, xml); if ("text".equals(type)) return new UiTextPropertyReference(this, xml); if ("url".equals(type)) return new UiUrlPropertyReference(this, xml); if ("userInfo".equals(type)) return new UiUserInfoPropertyReference(this, xml); if ("enum".equals(type)) return new UiEnumPropertyReference(this, xml); if ("component".equals(type)) return new UiComponentPropertyReference(this, xml); return new UiPropertyReference(this, xml); }
From source file:org.etudes.mneme.impl.ImportQti2ServiceImpl.java
/** * read each node and write it as is./*from w ww .j a v a2 s . c om*/ * * @param doc * @param itemBodyElement * @return */ private String normalizeElementBody(Document doc, Element itemBodyElement) { if (itemBodyElement == null) return ""; try { doc.getDocumentElement().normalize(); DocumentTraversal traversal = (DocumentTraversal) doc; NodeIterator iterator = traversal.createNodeIterator(itemBodyElement, NodeFilter.SHOW_ELEMENT, null, true); for (Node n = iterator.nextNode(); n != null; n = iterator.nextNode()) { String tagname = ((Element) n).getTagName(); if (tagname.equalsIgnoreCase(itemBodyElement.getTagName())) { StringBuilder textContent = new StringBuilder(); String nodeContent = getAllLevelsTextContent(n, textContent, false, null, null, null); return nodeContent; } } } catch (Exception e) { return itemBodyElement.getTextContent(); } return itemBodyElement.getTextContent(); }
From source file:org.etudes.mneme.impl.ImportQti2ServiceImpl.java
/** * For unsupported question , get the whole text along with options. * @param doc/*www. j av a2s . c o m*/ * @param itemBodyElement * @param wholeText * @param unzipLocation * @param context * @param embedMedia * @return */ private String normalizeItemBodyElement(Document doc, Element itemBodyElement, boolean wholeText, String unzipLocation, String context, List<String> embedMedia) { if (itemBodyElement == null) return ""; try { doc.getDocumentElement().normalize(); DocumentTraversal traversal = (DocumentTraversal) doc; NodeIterator iterator = traversal.createNodeIterator(itemBodyElement, NodeFilter.SHOW_ELEMENT, null, true); for (Node n = iterator.nextNode(); n != null; n = iterator.nextNode()) { String tagname = ((Element) n).getTagName(); if (tagname.equalsIgnoreCase(itemBodyElement.getTagName())) { StringBuilder textContent = new StringBuilder(); String nodeContent = getAllLevelsTextContent(n, textContent, wholeText, unzipLocation, context, embedMedia); return nodeContent; } } } catch (Exception e) { return itemBodyElement.getTextContent(); } return itemBodyElement.getTextContent(); }
From source file:org.exist.security.xacml.XACMLUtil.java
/** * Parses a DOM representation of a policy document into an * <code>AbstractPolicy</code>. * * @param policyDoc The DOM <code>Document</code> representing * the XACML policy or policy set./*from w w w . j a v a 2 s. co m*/ * @return The parsed policy * @throws ParsingException if there is an error parsing the document */ public AbstractPolicy parsePolicyDocument(Document policyDoc) throws ParsingException { final Element root = policyDoc.getDocumentElement(); final String name = root.getTagName(); if (name.equals(XACMLConstants.POLICY_SET_ELEMENT_LOCAL_NAME)) { return PolicySet.getInstance(root, pdp.getPDPConfig().getPolicyFinder()); } else if (name.equals(XACMLConstants.POLICY_ELEMENT_LOCAL_NAME)) { return Policy.getInstance(root); } else { throw new ParsingException( "The root element of the policy document must be '" + XACMLConstants.POLICY_SET_ID_LOCAL_NAME + "' or '" + XACMLConstants.POLICY_SET_ID_LOCAL_NAME + "', was: '" + name + "'"); } }
From source file:org.fcrepo.server.security.PolicyParser.java
/** * Parses the given policy and optionally schema validates it. * * @param policyStream//from w ww.ja va2s .co m * the serialized XACML policy * @param validate * whether to schema validate * @return the parsed policy. * @throws ValidationException * if the given xml is not a valid policy. This will occur if it * is not well-formed XML, its root element is not named * <code>Policy</code> or <code>PolicySet</code>, it triggers * a parse exception in the Sun libraries when constructing an * <code>AbstractPolicy</code> from the DOM, or (if validation * is true) it is not schema-valid. */ public AbstractPolicy parse(InputStream policyStream, boolean schemaValidate) throws ValidationException { // Parse; die if not well-formed Document doc = null; DocumentBuilder domParser = null; try { domParser = XmlTransformUtility.borrowDocumentBuilder(); domParser.setErrorHandler(THROW_ALL); doc = domParser.parse(policyStream); } catch (Exception e) { throw new ValidationException("Policy invalid; malformed XML", e); } finally { if (domParser != null) { XmlTransformUtility.returnDocumentBuilder(domParser); } } if (schemaValidate) { // XSD-validate; die if not schema-valid Validator validator = null; try { validator = m_validators.borrowObject(); validator.validate(new DOMSource(doc)); } catch (Exception e) { throw new ValidationException("Policy invalid; schema" + " validation failed", e); } finally { if (validator != null) try { m_validators.returnObject(validator); } catch (Exception e) { logger.warn(e.getMessage(), e); } } } // Construct AbstractPolicy from doc; die if root isn't "Policy[Set]" Element root = doc.getDocumentElement(); String rootName = root.getTagName(); try { if (rootName.equals("Policy")) { return Policy.getInstance(root); } else if (rootName.equals("PolicySet")) { return PolicySet.getInstance(root); } else { throw new ValidationException( "Policy invalid; root element is " + rootName + ", but should be " + "Policy or PolicySet"); } } catch (ParsingException e) { throw new ValidationException("Policy invalid; failed parsing by " + "Sun XACML implementation", e); } }
From source file:org.getobjects.eoaccess.EOModelLoader.java
/** * Handle the "model" tag.//from w ww . j a v a 2 s . c o m * <p> * Attributes: * <pre> * version * schema - String - the default schema * </pre> * * Children: * <pre> * element tags * </pre> */ protected EOModel loadModelFromElement(Element _node) { if (_node == null) { this.addError("got no model node for parsing"); return null; } if (!_node.getTagName().equals("model")) { this.addError("given node is not a <model> tag"); return null; } /* process model attributes */ String modelVersion = _node.getAttribute("version"); String schemaName = _node.getAttribute("schema"); Map<String, Object> modelOpts = new HashMap<String, Object>(2); modelOpts.put("version", modelVersion); modelOpts.put("defaultSchema", schemaName); /* process entities */ EOEntity[] entities = null; NodeList entityNodes = _node.getElementsByTagName("entity"); if (entityNodes != null && entityNodes.getLength() > 0) { int entityCount = entityNodes.getLength(); entities = new EOEntity[entityCount]; for (int i = 0; i < entityCount; i++) { entities[i] = this.loadEntityFromElement((Element) entityNodes.item(i), modelOpts); if (entities[i] == null) { this.addError("could not load entity from node: " + entityNodes.item(i)); return null; } } } else { /* No entities are specified in the model, which means that we should * fetch all data from the information schema of the database. This is * the same like this model: * <model version="1.0"> * <entity tableNameLike="*"> * <attribute columnNameLike="*" /> * </entity> * </model> */ EOAttribute[] patternAttributes = new EOAttribute[1]; patternAttributes[0] = EOAttribute.patternAttributeForColumnWithNameLike("*"); if (patternAttributes[0] == null) { this.addError("could not construct a-pattern"); return null; } entities = new EOEntity[1]; entities[0] = EOEntity.patternEntityForExternalNameLike("*", patternAttributes); if (entities[0] == null) { this.addError("could not construct e-pattern"); return null; } } EOModel model = new EOModel(entities); model.connectRelationships(); return model; }