use of org.eclipse.wst.xsl.core.model.Stylesheet in project webtools.sourceediting by eclipse.
the class StylesheetBuilder method parseModel.
private Stylesheet parseModel(IDOMModel model, IFile file) {
IDOMDocument document = model.getDocument();
Stylesheet sf = new Stylesheet(file);
StylesheetParser walker = new StylesheetParser(sf);
walker.walkDocument(document);
return sf;
}
use of org.eclipse.wst.xsl.core.model.Stylesheet in project webtools.sourceediting by eclipse.
the class StylesheetBuilder method build.
private Stylesheet build(IFile file) {
long start = System.currentTimeMillis();
if (Debug.debugXSLModel) {
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("Building " + file + "...");
}
Stylesheet stylesheet = null;
IStructuredModel smodel = null;
try {
smodel = StructuredModelManager.getModelManager().getExistingModelForRead(file);
if (smodel == null) {
smodel = StructuredModelManager.getModelManager().getModelForRead(file);
if (Debug.debugXSLModel) {
long endParse = System.currentTimeMillis();
System.out.println(// $NON-NLS-1$ //$NON-NLS-2$
"PARSE " + file + " in " + (endParse - start) + // $NON-NLS-1$
"ms");
}
} else if (Debug.debugXSLModel) {
long endParse = System.currentTimeMillis();
System.out.println(// $NON-NLS-1$ //$NON-NLS-2$
"NO-PARSE " + file + " in " + (endParse - start) + // $NON-NLS-1$
"ms");
}
// start = System.currentTimeMillis();
if (smodel != null && smodel instanceof IDOMModel) {
IDOMModel model = (IDOMModel) smodel;
stylesheet = parseModel(model, file);
}
} catch (IOException e) {
XSLCorePlugin.log(e);
} catch (CoreException e) {
XSLCorePlugin.log(e);
} finally {
if (smodel != null)
smodel.releaseFromRead();
}
if (Debug.debugXSLModel) {
long end = System.currentTimeMillis();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
System.out.println("BUILD " + file + " in " + (end - start) + "ms");
}
return stylesheet;
}
use of org.eclipse.wst.xsl.core.model.Stylesheet in project webtools.sourceediting by eclipse.
the class StylesheetBuilder method getStylesheet.
/**
* Get the <code>Stylesheet</code> associated with the given file. If either
* the <code>Stylesheet</code> has not yet been created or
* <code>force</code> is specified then the <code>Stylesheet</code> is
* built.
*
* @param file
* the XSL file
* @param force
* <code>true</code> to force a parse of the file
* @return the <code>Stylesheet</code>
*/
public Stylesheet getStylesheet(IFile file, boolean force) {
Stylesheet stylesheet = builtFiles.get(file);
if (stylesheet == null || force) {
stylesheet = build(file);
builtFiles.put(file, stylesheet);
}
return stylesheet;
}
use of org.eclipse.wst.xsl.core.model.Stylesheet in project webtools.sourceediting by eclipse.
the class XSLWorkbenchAdapter method getLabel.
public String getLabel(Object o) {
String label = null;
XSLModelObject obj = (XSLModelObject) o;
switch(obj.getModelType()) {
case STYLESHEET:
Stylesheet stylesheet = (Stylesheet) obj;
label = stylesheet.getVersion() == null ? "?" : // $NON-NLS-1$
stylesheet.getVersion();
break;
case IMPORT:
Import imp = (Import) obj;
label = imp.getHref();
break;
case INCLUDE:
Include inc = (Include) obj;
label = inc.getHref();
break;
case TEMPLATE:
Template t = (Template) obj;
StringBuffer sb = new StringBuffer();
if (t.getName() != null)
// $NON-NLS-1$
sb.append(t.getName()).append(" ");
if (t.getMatch() != null)
// $NON-NLS-1$
sb.append(t.getMatch()).append(" ");
if (t.getMode() != null)
// $NON-NLS-1$//$NON-NLS-2$
sb.append("(").append(t.getMode()).append(")");
label = sb.toString();
break;
case VARIABLE:
Variable v = (Variable) obj;
label = v.getName();
break;
case FUNCTION:
Function f = (Function) obj;
label = f.getName();
}
return label;
}
use of org.eclipse.wst.xsl.core.model.Stylesheet in project webtools.sourceediting by eclipse.
the class TestStylesheet method testGetFunctionFunc1.
@Test
public void testGetFunctionFunc1() {
Stylesheet stylesheet = builder.getStylesheet(getFile("XSLT20FunctionTest.xsl"), false);
assertNotNull("Model failed to load, returned NULL", stylesheet);
List<Function> functionList = stylesheet.getFunctions();
for (Function function : functionList) {
if (function.getName().equals("func1")) {
return;
}
}
fail("Did not find XSL func func1");
}
Aggregations