use of org.eclipse.wst.xsl.core.model.Include in project webtools.sourceediting by eclipse.
the class XSLValidator method checkIncludes.
private void checkIncludes(StylesheetModel stylesheetComposed, XSLValidationReport report) throws MaxErrorsExceededException {
for (Include include : stylesheetComposed.getStylesheet().getIncludes()) {
IFile includedFile = include.getHrefAsFile();
if (includedFile == null || !includedFile.exists()) {
// included
// file does
// not exist
// $NON-NLS-1$
XSLAttribute att = include.getAttribute("href");
if (att != null) {
String baseURI = include.getStylesheet().getFile().getLocationURI().toString();
// $NON-NLS-1$
String resolvedURI = URIResolverPlugin.createResolver().resolve(baseURI, "", att.getValue());
if ((resolvedURI == null) || !(importOrIncludeExists(stylesheetComposed.getStylesheet().getFile(), resolvedURI))) {
createMarker(report, att, getPreference(ValidationPreferences.MISSING_INCLUDE), Messages.XSLValidator_4 + include.getHref());
}
} else {
createMarker(report, include, getPreference(ValidationPreferences.NAME_ATTRIBUTE_EMPTY), Messages.XSLValidator_23);
}
} else if (includedFile.equals(include.getStylesheet().getFile())) {
// stylesheet
// including
// itself!
createMarker(report, include.getAttribute("href"), getPreference(ValidationPreferences.CIRCULAR_REF), // $NON-NLS-1$
Messages.XSLValidator_6);
}
}
}
use of org.eclipse.wst.xsl.core.model.Include in project webtools.sourceediting by eclipse.
the class XSLValidator method checkImports.
private void checkImports(StylesheetModel stylesheetComposed, XSLValidationReport report) throws MaxErrorsExceededException {
for (Include include : stylesheetComposed.getStylesheet().getImports()) {
IFile includedFile = include.getHrefAsFile();
if (includedFile == null || !includedFile.exists()) {
// included
// file does
// not exist
// $NON-NLS-1$
XSLAttribute att = include.getAttribute("href");
if (att != null) {
String baseURI = include.getStylesheet().getFile().getLocationURI().toString();
// $NON-NLS-1$
String resolvedURI = URIResolverPlugin.createResolver().resolve(baseURI, "", att.getValue());
if ((resolvedURI == null) || (!importOrIncludeExists(stylesheetComposed.getStylesheet().getFile(), resolvedURI))) {
createMarker(report, att, getPreference(ValidationPreferences.MISSING_INCLUDE), Messages.XSLValidator_4 + include.getHref());
}
}
} else if (includedFile.equals(include.getStylesheet().getFile())) {
// stylesheet
// including
// itself!
createMarker(report, include.getAttribute("href"), getPreference(ValidationPreferences.CIRCULAR_REF), // $NON-NLS-1$
Messages.XSLValidator_10);
}
}
}
use of org.eclipse.wst.xsl.core.model.Include in project webtools.sourceediting by eclipse.
the class XSLElementFactory method createInclude.
public XSLElement createInclude() {
Include include = new Include(stylesheetParserData.getStylesheet());
stylesheetParserData.getStylesheet().addInclude(include);
return include;
}
use of org.eclipse.wst.xsl.core.model.Include 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.Include in project webtools.sourceediting by eclipse.
the class TestStylesheet method testGetIncludes.
@Test
public void testGetIncludes() {
Stylesheet stylesheet = builder.getStylesheet(getFile("style1.xsl"), false);
assertNotNull("Model failed to load, returned NULL", stylesheet);
List<Include> includeList = stylesheet.getIncludes();
assertEquals("Wrong number of includes returned.", 1, includeList.size());
}
Aggregations