use of org.w3c.dom.DocumentType in project webtools.sourceediting by eclipse.
the class DocumentImpl method getDocumentTypeId.
public String getDocumentTypeId() {
DocumentType docType = getDocumentType();
if (docType == null)
return null;
String id = docType.getPublicId();
if (id == null)
id = docType.getSystemId();
return id;
}
use of org.w3c.dom.DocumentType in project webtools.sourceediting by eclipse.
the class DocumentImpl method getDocumentElement.
/**
* getDocumentElement
*
* @return org.w3c.dom.Element From DOM 2 Spec: documentElement of type
* Element [p.62] , readonly This is a convenience [p.119]
* attribute that allows direct access to the child node that is
* the root element of the document. For HTML documents, this is
* the element with the tagName "HTML". Note: we differ from this
* definition a little in that we don't necessarily take the first
* child but also look to match the name. In a well formed
* document, of course, the result is the same, but not
* necessarily the same in an ill-formed document.
*/
public Element getDocumentElement() {
String name = null;
DocumentType docType = getDocumentType();
if (docType != null) {
name = docType.getName();
}
Element[] first = new Element[1];
Element docElement = findDocumentElement(name, this, first, noMaxSearch);
if (docElement == null) {
docElement = first[0];
}
return docElement;
}
use of org.w3c.dom.DocumentType in project liferay-ide by liferay.
the class HookUtil method getDTDVersion.
/**
* A small utility method used to compute the DTD version
*
* @param document
* - the document that is loaded by the editor
*/
public static String getDTDVersion(Document document) {
String dtdVersion = null;
DocumentType docType = document.getDoctype();
if (docType != null) {
String publicId = docType.getPublicId();
String systemId = docType.getSystemId();
if ((publicId != null) && (systemId != null)) {
if (publicId.contains("6.0.0") || systemId.contains("6.0.0")) {
dtdVersion = "6.0.0";
} else if (publicId.contains("6.1.0") || systemId.contains("6.1.0")) {
dtdVersion = "6.1.0";
}
}
}
return dtdVersion;
}
use of org.w3c.dom.DocumentType in project liferay-ide by liferay.
the class VersionedDTDRootElementController method _checkDocType.
private boolean _checkDocType() {
try {
Document document = _getDocument();
if (document == null) {
return false;
}
DocumentType docType = document.getDoctype();
if (docType == null) {
return false;
}
Matcher publicIdMatcher = _publicIdPattern.matcher(docType.getPublicId());
if (!publicIdMatcher.matches()) {
return false;
}
String version = publicIdMatcher.group(1);
if (version == null) {
return false;
}
Matcher systemIdMatcher = _systemIdPattern.matcher(docType.getSystemId());
if (!systemIdMatcher.matches()) {
return false;
}
String systemIdVersion = systemIdMatcher.group(1);
if (systemIdVersion == null) {
return false;
}
systemIdVersion = systemIdVersion.replaceAll(StringPool.UNDERSCORE, StringPool.EMPTY);
version = version.replaceAll("\\.", StringPool.EMPTY);
if (systemIdVersion.equals(version)) {
return true;
}
} catch (Exception e) {
}
return false;
}
use of org.w3c.dom.DocumentType in project liferay-ide by liferay.
the class DescriptorsPage method isNeedUpgrade.
@Override
protected boolean isNeedUpgrade(IFile srcFile) {
IDOMModel domModel = null;
try {
domModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(srcFile);
domModel.aboutToChangeModel();
IDOMDocument document = domModel.getDocument();
DocumentType docType = document.getDoctype();
if (docType != null) {
final String publicId = docType.getPublicId();
String oldPublicIdVersion = _getOldVersion(publicId, _publicidRegrex);
final String systemId = docType.getSystemId();
String oldSystemIdVersion = _getOldVersion(systemId, _systemidRegrex);
if (((publicId != null) && !oldPublicIdVersion.equals("7.0.0")) || ((systemId != null) && !oldSystemIdVersion.equals("7_0_0"))) {
return true;
}
}
} catch (Exception e) {
ProjectUI.logError(e);
} finally {
domModel.releaseFromRead();
}
return false;
}
Aggregations