Search in sources :

Example 1 with Include

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);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) XSLAttribute(org.eclipse.wst.xsl.core.model.XSLAttribute) Include(org.eclipse.wst.xsl.core.model.Include)

Example 2 with Include

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);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) XSLAttribute(org.eclipse.wst.xsl.core.model.XSLAttribute) Include(org.eclipse.wst.xsl.core.model.Include)

Example 3 with Include

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;
}
Also used : Include(org.eclipse.wst.xsl.core.model.Include)

Example 4 with 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;
}
Also used : Function(org.eclipse.wst.xsl.core.model.Function) Import(org.eclipse.wst.xsl.core.model.Import) Variable(org.eclipse.wst.xsl.core.model.Variable) XSLModelObject(org.eclipse.wst.xsl.core.model.XSLModelObject) Include(org.eclipse.wst.xsl.core.model.Include) Stylesheet(org.eclipse.wst.xsl.core.model.Stylesheet) Template(org.eclipse.wst.xsl.core.model.Template)

Example 5 with Include

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());
}
Also used : Include(org.eclipse.wst.xsl.core.model.Include) Stylesheet(org.eclipse.wst.xsl.core.model.Stylesheet) Test(org.junit.Test)

Aggregations

Include (org.eclipse.wst.xsl.core.model.Include)5 IFile (org.eclipse.core.resources.IFile)2 Stylesheet (org.eclipse.wst.xsl.core.model.Stylesheet)2 XSLAttribute (org.eclipse.wst.xsl.core.model.XSLAttribute)2 Function (org.eclipse.wst.xsl.core.model.Function)1 Import (org.eclipse.wst.xsl.core.model.Import)1 Template (org.eclipse.wst.xsl.core.model.Template)1 Variable (org.eclipse.wst.xsl.core.model.Variable)1 XSLModelObject (org.eclipse.wst.xsl.core.model.XSLModelObject)1 Test (org.junit.Test)1