use of org.eclipse.wst.xsl.core.model.Variable in project webtools.sourceediting by eclipse.
the class TestStylesheet method testGetGlobalVariables.
@Test
public void testGetGlobalVariables() {
Stylesheet stylesheet = builder.getStylesheet(getFile("globalVariablesTest.xsl"), false);
assertNotNull("Model failed to load, returned NULL", stylesheet);
List<Variable> globalVariablesList = stylesheet.getGlobalVariables();
assertEquals("Wrong number of global variables returned.", 3, globalVariablesList.size());
}
use of org.eclipse.wst.xsl.core.model.Variable in project webtools.sourceediting by eclipse.
the class XSLElementFactory method createVariable.
public XSLElement createVariable(XSLElement xslEl) {
if (stylesheetParserData.getElementStack().size() == 1) {
// global variable
Variable var = new Variable(stylesheetParserData.getStylesheet());
stylesheetParserData.getStylesheet().addGlobalVariable(var);
xslEl = var;
} else if (stylesheetParserData.getElementStack().size() > 1 && stylesheetParserData.getCurrentTemplate() != null) {
// local
// variable
Variable var = new Variable(stylesheetParserData.getStylesheet());
stylesheetParserData.getCurrentTemplate().addVariable(var);
xslEl = var;
}
return xslEl;
}
use of org.eclipse.wst.xsl.core.model.Variable 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;
}
Aggregations