use of org.eclipse.wst.xsl.core.model.XSLAttribute in project webtools.sourceediting by eclipse.
the class CallTemplateContentAssistRequest method getCompletionProposals.
/**
* (non-Javadoc)
* @see org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest#getCompletionProposals()
*/
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
proposals.clear();
IFile editorFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(getLocation()));
StylesheetModel model = XSLCore.getInstance().getStylesheet(editorFile);
List<Template> templates = model.getTemplates();
for (Template template : templates) {
XSLAttribute attribute = template.getAttribute(ATTR_NAME);
if (attribute != null) {
String proposalInfo = getAdditionalInfo(template);
CustomCompletionProposal proposal = new CustomCompletionProposal(attribute.getValue(), getStartOffset() + 1, 0, attribute.getValue().length(), XSLPluginImageHelper.getInstance().getImage(XSLPluginImages.IMG_TEMPLATE), attribute.getValue(), null, proposalInfo, 0);
addProposal(proposal);
}
}
return getAllCompletionProposals();
}
use of org.eclipse.wst.xsl.core.model.XSLAttribute in project webtools.sourceediting by eclipse.
the class TemplateModeAttributeContentAssist method addModeProposals.
/**
* @param model
*/
protected void addModeProposals(StylesheetModel model) {
List<Template> templates = model.getTemplates();
ArrayList<String> modes = new ArrayList<String>();
for (Template template : templates) {
XSLAttribute attribute = template.getAttribute(MODE_ATTRIBUTE);
IDOMNode xmlNode = (IDOMNode) node;
if (attribute != null && xmlNode.getStartOffset() != template.getOffset()) {
CustomCompletionProposal proposal = new CustomCompletionProposal(attribute.getValue(), getStartOffset() + 1, 0, attribute.getValue().length(), XSLPluginImageHelper.getInstance().getImage(XSLPluginImages.IMG_MODE), attribute.getValue(), null, null, 0);
if (modes.indexOf(attribute.getValue()) == -1) {
proposals.add(proposal);
modes.add(attribute.getValue());
}
}
}
modes.clear();
}
use of org.eclipse.wst.xsl.core.model.XSLAttribute in project webtools.sourceediting by eclipse.
the class XSLModelObjectFactory method configure.
private void configure(IDOMNode node, XSLElement element) {
setPositionInfo(node, element);
IDOMElement domElem = (IDOMElement) node;
element.setName(domElem.getLocalName());
NamedNodeMap map = node.getAttributes();
for (int i = 0; i < map.getLength(); i++) {
IDOMAttr attr = (IDOMAttr) map.item(i);
XSLAttribute xslatt = new XSLAttribute(element, attr.getName(), attr.getValue());
setPositionInfo(attr, xslatt);
element.setAttribute(xslatt);
}
setParentElement(node, element);
}
use of org.eclipse.wst.xsl.core.model.XSLAttribute in project webtools.sourceediting by eclipse.
the class TestStylesheetModel method testFindAvailableTemplateModes.
@Test
public void testFindAvailableTemplateModes() {
ArrayList<String> modes = new ArrayList();
model = XSLCore.getInstance().getStylesheet(getFile("modeTest.xsl"));
List<Template> templates = model.getTemplates();
assertTrue("No templates returned.", templates.size() > 0);
for (Template template : templates) {
XSLAttribute attribute = template.getAttribute("mode");
if (attribute != null) {
if (modes.indexOf(attribute.getValue()) == -1) {
modes.add(attribute.getValue());
}
}
}
assertEquals("Wrong number of mode templates returned.", 3, modes.size());
}
use of org.eclipse.wst.xsl.core.model.XSLAttribute in project webtools.sourceediting by eclipse.
the class XSLValidator method validateXPath.
private void validateXPath(XSLElement xslEl, XSLValidationReport report, String attName) throws MaxErrorsExceededException {
XSLAttribute att = xslEl.getAttribute(attName);
if (att != null && att.getValue() != null) {
try {
String xslVersion = xslEl.getStylesheet().getVersion();
String xpathExp = att.getValue();
if (xslVersion.equals(XSLT2_Version)) {
XPath20Helper.compile(xpathExp);
} else {
XSLTXPathHelper.compile(att.getValue());
}
} catch (XPathExpressionException e) {
createMarker(report, att, getPreference(ValidationPreferences.XPATHS), Messages.XSLValidator_1);
} catch (NullPointerException e) {
// not sure why NPE is being thrown here
}
}
}
Aggregations