try {
IProject prj = StructuredModelUtil.getProjectFor(part.getIDOMNode()
.getModel());
PageExpressionContext.initialize(prj);
IDOMDocument doc = (IDOMDocument) part.getIDOMNode();
Object obj = doc.getAdapterFor(IDocumentPageVariableAdapter.class);
if (obj instanceof IPageVariablesProvider) {
((IPageVariablesProvider) obj).refresh();
PageExpressionContext.getCurrent().pushPageVarProvider(
(IPageVariablesProvider) obj);
} else {
PageExpressionContext.getCurrent().pushPageVarProvider(null);
}
// IDOMModel previewModel =
// (IDOMModel)StructuredModelManager.getModelManager().createNewInstance(doc.getModel());
// IDOMDocument previewDoc = previewModel.getDocument();
// CR400625: creating XML model here instead of HTML model. Since
// for HTML model, there are checking enforced
// by WTP to make sure the HTML content model is not invalidated.
// And sometimes, the converted HTML may not fully
// comply with HTML content model.
// Use XML instead to workaround the content model validation.
// CR403449: But if we use XML, then system can't recogonize special
// tag such as "script", "style", they
// support <!-- --> in them.
// So we are still using HTML model, but in TagConverter, we are
// always caling DOMUtil.cloneNodeDeepIgnoreError
// to try to skip the errors.
// Hopefully in later version of SSE, the famous "br" problem is
// fixed, and we won't met error when doing
// deep clone.
// IStructuredModel sModel =
// StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(IContentTypeIdentifier.ContentTypeID_XML);
// FIXME: if is not jsp, should use original contentType, if is jsp,
// should use the corresponding
// content type
IStructuredModel sModel = StructuredModelManager.getModelManager()
.createUnManagedStructuredModelFor(
ContentTypeIdForHTML.ContentTypeID_HTML);
IDOMDocument previewDoc = ((IDOMModel) sModel).getDocument();
PreviewConvertContext context = new PreviewConvertContext(
previewDoc);
ISourceGenerator generator = XMLGeneratorImpl.getInstance();
List subeditparts = part.getChildren();