use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.
the class DOMNamespaceHelper method computeName.
public static String computeName(CMNode cmNode, Node parent, String prefix, NamespaceTable namespaceTable) {
String result = cmNode.getNodeName();
//
if (getPrefix(result) == null) {
// $NON-NLS-1$
String qualification = (String) cmNode.getProperty("http://org.eclipse.wst/cm/properties/nsPrefixQualification");
//
if (// $NON-NLS-1$
qualification != null && qualification.equals("qualified")) {
if (prefix == null) {
// todo... add getCMDocument() method to CMNode
// for now use this getProperty() hack
// $NON-NLS-1$
CMDocument cmDocument = (CMDocument) cmNode.getProperty("CMDocument");
if (cmDocument != null) {
// $NON-NLS-1$
String namespaceURI = (String) cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI");
if (namespaceURI != null) {
//
if (namespaceTable == null) {
Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
namespaceTable = new NamespaceTable(document);
if (parent instanceof Element) {
namespaceTable.addElementLineage((Element) parent);
}
}
prefix = namespaceTable.getPrefixForURI(namespaceURI);
}
}
}
if (prefix != null && prefix.length() > 0) {
// $NON-NLS-1$
result = prefix + ":" + result;
}
}
}
return result;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.
the class InferredGrammarFactory method debugPrint.
public void debugPrint(Collection collection) {
for (Iterator iter = collection.iterator(); iter.hasNext(); ) {
CMDocument cmDocument = (CMDocument) iter.next();
// $NON-NLS-1$
System.out.println("-----------------------------------------------");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
System.out.println("cmDocument (" + cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI") + ")");
CMNamedNodeMapImpl elementMap = (CMNamedNodeMapImpl) cmDocument.getElements();
int size = elementMap.getLength();
for (int i = 0; i < size; i++) {
CMElementDeclaration ed = (CMElementDeclaration) elementMap.item(i);
CMDescriptionBuilder builder = new CMDescriptionBuilder();
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println(" ELEMENT " + ed.getNodeName() + " = " + builder.buildDescription(ed));
}
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.
the class CMDocumentFactoryTLD method buildCMDocumentFromJar.
/**
* Builds a CMDocument
*
* @param jarFileName -
* the name of the containing JAR file
* @param contentFileName -
* the path within the JAR for a valid taglib descriptor
*/
protected CMDocument buildCMDocumentFromJar(String jarFileName, String contentFileName) {
// load the taglib descriptor file
DocumentProvider provider = new DocumentProvider();
provider.setValidating(false);
provider.setBaseReference(jarFileName);
provider.setRootElementName(JSP11TLDNames.TAGLIB);
provider.setJarFileName(jarFileName);
provider.setFileName(contentFileName);
// $NON-NLS-1$ //$NON-NLS-2$
CMDocument document = loadDocument("jar:file://" + jarFileName + "!" + contentFileName, provider.getRootElement());
// 8.4.1
return document;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.
the class CSSProposalGeneratorForHTMLTag method setupHTMLTags.
/**
*/
private static String[] setupHTMLTags() {
CMDocument cmdoc = HTMLCMDocumentFactory.getCMDocument(CMDocType.HTML_DOC_TYPE);
CMNamedNodeMap elements = cmdoc.getElements();
Vector names = new Vector();
int nElements = elements.getLength();
for (int i = 0; i < nElements; i++) {
CMElementDeclaration edec = (CMElementDeclaration) elements.item(i);
if (isAttrDefined(edec, HTML40Namespace.ATTR_NAME_STYLE)) {
names.add(edec.getElementName());
}
}
Collections.sort(names);
String[] tags = new String[names.size()];
Iterator iNames = names.iterator();
for (int i = 0; iNames.hasNext(); i++) {
tags[i] = (String) iNames.next();
}
return tags;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.
the class DTDImpl method buildCMDocument.
public static CMDocument buildCMDocument(String uri) {
DTDFile dtdFile = buildDTDModel(uri);
CMDocument cmDocument = (CMDocument) getAdapter(dtdFile);
return cmDocument;
}
Aggregations