use of org.eclipse.wst.xsl.core.model.Function in project webtools.sourceediting by eclipse.
the class XSLElementFactory method createFunction.
public XSLElement createFunction() {
stylesheetParserData.setCurrentTemplate(null);
Function function = new Function(stylesheetParserData.getStylesheet());
stylesheetParserData.getFunctions().push(function);
stylesheetParserData.getStylesheet().addFunction(function);
return function;
}
use of org.eclipse.wst.xsl.core.model.Function in project webtools.sourceediting by eclipse.
the class XSLElementFactory method createParamater.
public XSLElement createParamater() {
Parameter param = new Parameter(stylesheetParserData.getStylesheet());
// determine whether param has a value
NodeList childNodes = element.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node childNode = childNodes.item(i);
if (childNode.getNodeType() != Node.ATTRIBUTE_NODE) {
param.setValue(true);
break;
}
}
if (stylesheetParserData.getParentEl() != null) {
if (stylesheetParserData.getParentEl().getModelType() == XSLModelObject.Type.FUNCTION) {
Function function = (Function) stylesheetParserData.getParentEl();
function.addParameter(param);
} else if (stylesheetParserData.getParentEl().getModelType() == XSLModelObject.Type.TEMPLATE && stylesheetParserData.getElementStack().size() == 2 && stylesheetParserData.getCurrentTemplate() != null) {
Template template = (Template) stylesheetParserData.getParentEl();
template.addParameter(param);
}
}
return param;
}
use of org.eclipse.wst.xsl.core.model.Function 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.Function 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");
}
use of org.eclipse.wst.xsl.core.model.Function in project webtools.sourceediting by eclipse.
the class TestStylesheet method testGetFunction.
@Test
public void testGetFunction() {
Stylesheet stylesheet = builder.getStylesheet(getFile("XSLT20FunctionTest.xsl"), false);
assertNotNull("Model failed to load, returned NULL", stylesheet);
List<Function> functionList = stylesheet.getFunctions();
assertEquals("Wrong number of global variables returned.", 2, functionList.size());
}
Aggregations