Search in sources :

Example 1 with XSLAttribute

use of org.eclipse.wst.xsl.core.model.XSLAttribute 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 XSLAttribute

use of org.eclipse.wst.xsl.core.model.XSLAttribute 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 XSLAttribute

use of org.eclipse.wst.xsl.core.model.XSLAttribute in project webtools.sourceediting by eclipse.

the class TestStylesheet method testGetAttributes.

@Test
public void testGetAttributes() {
    Stylesheet stylesheet = builder.getStylesheet(getFile("globalVariablesTest.xsl"), false);
    assertNotNull("Model failed to load, returned NULL", stylesheet);
    Map<String, XSLAttribute> attributeList = stylesheet.getAttributes();
    assertEquals("Incorrect number of attributes", 4, attributeList.size());
    XSLAttribute attribute = stylesheet.getAttribute("exclude-result-prefixes");
    assertEquals("Wrong attribute returned:", "exclude-result-prefixes", attribute.getName());
}
Also used : XSLAttribute(org.eclipse.wst.xsl.core.model.XSLAttribute) Stylesheet(org.eclipse.wst.xsl.core.model.Stylesheet) Test(org.junit.Test)

Example 4 with XSLAttribute

use of org.eclipse.wst.xsl.core.model.XSLAttribute in project webtools.sourceediting by eclipse.

the class XSLHyperlinkDetector method createWithParamHyperLink.

private IHyperlink createWithParamHyperLink(IFile currentFile, Element elem, Attr attr, IRegion hyperlinkRegion) {
    IHyperlink hyperlink = null;
    StylesheetModel sf = XSLCore.getInstance().getStylesheet(currentFile);
    if (sf != null) {
        Node parentNode = elem.getParentNode();
        Attr parentAttribute = (Attr) parentNode.getAttributes().getNamedItem(ATTR_NAME);
        String templateName = parentAttribute.getValue();
        List<Template> templates = sf.getTemplatesByName(templateName);
        if (templates != null && templates.size() == 1) {
            Template template = templates.get(0);
            List<Parameter> parameters = template.getParameters();
            for (Parameter param : parameters) {
                String paramName = attr.getValue();
                XSLAttribute parameterNameAttr = param.getAttribute(ATTR_NAME);
                if (parameterNameAttr != null && parameterNameAttr.getValue().equals(paramName)) {
                    hyperlink = new SourceFileHyperlink(hyperlinkRegion, template.getStylesheet().getFile(), param);
                }
            }
        }
    }
    return hyperlink;
}
Also used : XSLAttribute(org.eclipse.wst.xsl.core.model.XSLAttribute) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) Node(org.w3c.dom.Node) Parameter(org.eclipse.wst.xsl.core.model.Parameter) StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel) Attr(org.w3c.dom.Attr) IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr) Template(org.eclipse.wst.xsl.core.model.Template)

Example 5 with XSLAttribute

use of org.eclipse.wst.xsl.core.model.XSLAttribute in project webtools.sourceediting by eclipse.

the class CallTemplateContentAssistRequest method getAdditionalInfo.

protected String getAdditionalInfo(Template template) {
    XSLAttribute nameAttribute = template.getAttribute(ATTR_NAME);
    String proposalInfo = Messages.CallTemplateContentAssistTemplateName + nameAttribute.getValue() + "\r\n" + Messages.CallTemplateContentAssistTemplateNameFile + // $NON-NLS-1$
    template.getStylesheet().getFile().getName();
    return proposalInfo;
}
Also used : XSLAttribute(org.eclipse.wst.xsl.core.model.XSLAttribute)

Aggregations

XSLAttribute (org.eclipse.wst.xsl.core.model.XSLAttribute)10 Template (org.eclipse.wst.xsl.core.model.Template)4 IFile (org.eclipse.core.resources.IFile)3 ArrayList (java.util.ArrayList)2 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)2 IDOMAttr (org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)2 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)2 Include (org.eclipse.wst.xsl.core.model.Include)2 StylesheetModel (org.eclipse.wst.xsl.core.model.StylesheetModel)2 Test (org.junit.Test)2 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 Path (org.eclipse.core.runtime.Path)1 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)1 IDOMElement (org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement)1 Parameter (org.eclipse.wst.xsl.core.model.Parameter)1 Stylesheet (org.eclipse.wst.xsl.core.model.Stylesheet)1 Attr (org.w3c.dom.Attr)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1 Node (org.w3c.dom.Node)1