public DOMContentBuilder createDOMContentBuilder(Document document) { DOMContentBuilderImpl builder = new DOMContentBuilderImpl(document); return builder; }
public void visitCMAttributeDeclaration(CMAttributeDeclaration ad) { if (alwaysVisit || buildOptionalAttributes(buildPolicy) || ad.getUsage() == CMAttributeDeclaration.REQUIRED) { alwaysVisit = false; String name = computeName(ad, currentParent); String value = valueHelper.getValue(ad, namespaceTable); Attr attr = createAttribute(ad, name, currentParent); attr.setValue(value != null ? value : ""); //$NON-NLS-1$ linkNode(attr); } }
public void createDefaultRootContent(CMDocument cmDocument, CMElementDeclaration rootCMElementDeclaration, List namespaceInfoList) throws Exception { this.namespaceInfoList = namespaceInfoList; createDefaultRootContent(cmDocument, rootCMElementDeclaration); }
public void visitCMDataType(CMDataType dataType) { Text text = null; String value = null; // For backward compatibility: // Previous code uses a property value but new one uses // buildPolicy. if (getProperty(PROPERTY_BUILD_BLANK_TEXT_NODES) != null && getProperty(PROPERTY_BUILD_BLANK_TEXT_NODES).equals("true")) //$NON-NLS-1$ buildPolicy = buildPolicy ^ BUILD_TEXT_NODES; if (buildTextNodes(buildPolicy)) { value = valueHelper.getValue(dataType); if (value == null) { if (currentParent != null && currentParent.getNodeType() == Node.ELEMENT_NODE) { value = currentParent.getNodeName(); } else { value = "pcdata"; //$NON-NLS-1$ } } } else { value = ""; //$NON-NLS-1$ } text = createTextNode(dataType, value, currentParent); linkNode(text); }
public void visitCMElementDeclaration(CMElementDeclaration ed) { int forcedMin = (buildOptionalElements(buildPolicy) || alwaysVisit) ? 1 : 0; int min = Math.max(ed.getMinOccur(), forcedMin); int gmin = group.getMinOccur(); if (gmin == 0) if (buildOptionalElements(buildPolicy)) { int max = Math.min(ed.getMaxOccur(), getNumOfRepeatableElements()); if (max < min) max = min; if (buildFirstSubstitution(buildPolicy) || isAbstract(ed)) // leave ed = getSubstitution(ed); element = createElement(ed, computeName(ed, currentParent), currentParent); handlePushParent(element, ed); int size = nodeMap.getLength(); for (int j = 0; j < size; j++) { visitCMNode(nodeMap.item(j)); visitCMNode(content); CMDataType dataType = ed.getDataType(); if (dataType != null) { visitCMDataType(dataType);
DOMContentBuilderImpl contentBuilder = new DOMContentBuilderImpl(xmlDocument); contentBuilder.setBuildPolicy(buildPolicy); contentBuilder.setExternalCMDocumentSupport(new MyExternalCMDocumentSupport(namespaceInfoList, xmlFileName)); contentBuilder.createDefaultRootContent(cmDocument, cmElementDeclaration, namespaceInfoList);
public static void testPopulateDocumentFromGrammarFile(Document document, String grammarFileName, String rootElementName, boolean hack) { try { CMDocument cmDocument = ContentModelManager.getInstance().createCMDocument(grammarFileName, null); CMNamedNodeMap elementMap = cmDocument.getElements(); CMElementDeclaration element = (CMElementDeclaration) elementMap.getNamedItem(rootElementName); DOMContentBuilderImpl contentBuilder = new DOMContentBuilderImpl(document); contentBuilder.supressCreationOfDoctypeAndXMLDeclaration = hack; contentBuilder.createDefaultRootContent(cmDocument, element); System.out.println(); System.out.println("-----------------------------"); //$NON-NLS-1$ DOMWriter writer = new DOMWriter(); if (hack) { writer.print(document, grammarFileName); } else { writer.print(document); } System.out.println("-----------------------------"); //$NON-NLS-1$ } catch (Exception e) { System.out.println("Error: " + e); //$NON-NLS-1$ e.printStackTrace(); } }
public void visitCMGroup(CMGroup e) { cmGroupStack.push(e); int forcedMin = (buildOptionalElements(buildPolicy) || alwaysVisit) ? 1 : 0; int min = Math.max(e.getMinOccur(), forcedMin); max = getNumOfRepeatableElements(); else max = Math.min(e.getMaxOccur(), getNumOfRepeatableElements()); if (e.getOperator() == CMGroup.CHOICE && buildFirstChoice(buildPolicy)) { CMNode hintNode = null; visitCMNode(cmNode);
public String computeName(CMNode cmnode, Node parent) { String name = super.computeName(cmnode, parent); // don't change the case unless we're certain it is meaningless // if (cmnode instanceof HTMLCMNode && ((HTMLCMNode) cmnode).shouldIgnoreCase()) { if (shouldIgnoreCase(cmnode)) { if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION) { if (fTagCase == HTMLCorePreferenceNames.LOWER) name = name.toLowerCase(); else if (fTagCase == HTMLCorePreferenceNames.UPPER) name = name.toUpperCase(); // else do nothing } else if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) { if (fAttrCase == HTMLCorePreferenceNames.LOWER) name = name.toLowerCase(); else if (fAttrCase == HTMLCorePreferenceNames.UPPER) name = name.toUpperCase(); // else do nothing } } return name; }
rootElement = createElement(rootCMElementDeclaration, name, document); manager.addNamespaceInfo(rootElement, namespaceInfoList, true); createDefaultContent(document, rootCMElementDeclaration);