private AttributesImpl buildAttributes(JellyContext context) { AttributesImpl actual = new AttributesImpl(); for (ExpressionAttribute att : attributes.values()) { Expression expression = att.exp; String v = expression.evaluateAsString(context); if (v==null) continue; // treat null as no attribute actual.addAttribute(att.nsURI, att.name, att.qname(),"CDATA", v); } if (EMIT_LOCATION) { actual.addAttribute("","file","file","CDATA",String.valueOf(getFileName())); actual.addAttribute("","line","line","CDATA",String.valueOf(getLineNumber())); // try to obtain the meaningful part of the script and put it in CSS with a // class name like "jelly-foo-bar-xyz" given "file://path/to/src/tree/src/main/resources/foo/bar/xyz.jelly" String form = getFileName().replace('\\','/'); for (String suffix : SUFFIX) { int idx = form.lastIndexOf(suffix); if (idx>0) form=form.substring(idx+suffix.length()); } int c = actual.getIndex("class"); if (c>=0) actual.setValue(c, actual.getValue(c)+" "+form); else actual.addAttribute("","class","class","CDATA",form); } return actual; } };
private AttributesImpl buildAttributes(JellyContext context) { AttributesImpl actual = new AttributesImpl(); for (ExpressionAttribute att : attributes.values()) { Expression expression = att.exp; String v = expression.evaluateAsString(context); if (v==null) continue; // treat null as no attribute actual.addAttribute(att.nsURI, att.name, att.qname(),"CDATA", v); } if (EMIT_LOCATION) { actual.addAttribute("","file","file","CDATA",String.valueOf(getFileName())); actual.addAttribute("","line","line","CDATA",String.valueOf(getLineNumber())); // try to obtain the meaningful part of the script and put it in CSS with a // class name like "jelly-foo-bar-xyz" given "file://path/to/src/tree/src/main/resources/foo/bar/xyz.jelly" String form = getFileName().replace('\\','/'); for (String suffix : SUFFIX) { int idx = form.lastIndexOf(suffix); if (idx>0) form=form.substring(idx+suffix.length()); } int c = actual.getIndex("class"); if (c>=0) actual.setValue(c, actual.getValue(c)+" "+form); else actual.addAttribute("","class","class","CDATA",form); } return actual; } };