Element(String name, Iterable<Attribute> attrs) { this.name = name; for (Attribute attr : attrs) { put(attr.getName(), attr.getValue()); } }
private AttributeComponentBinding parseAttributeComponent(Attribute attr) { int prefixLength = attr.getName().indexOf(':'); String prefix = attr.getName().substring(0, prefixLength); String name = attr.getName().substring(prefixLength + 1); String fullName = prefix + ":" + name; AttributeComponentMetadata componentMeta = resolveAttrComponent(prefix, name);
private void parseNamespaces() { Attributes attributes = tag.getAttributes(); if( attributes != null ) { for( Attribute attribute : tag.getAttributes() ) { String name = attribute.getName(); if( name.toLowerCase(Locale.ROOT).startsWith( "xmlns" ) ) { int colon = name.indexOf( ":", 5 ); String prefix; if( colon <= 0 ) { prefix = ""; } else { prefix = name.substring( colon ); } namespaces.put( prefix, attribute.getValue() ); } } } }
private AttributeComponentBinding parseAttributeComponent(Attribute attr) { int prefixLength = attr.getName().indexOf(':'); String prefix = attr.getName().substring(0, prefixLength); String name = attr.getName().substring(prefixLength + 1); String fullName = prefix + ":" + name; AttributeComponentMetadata componentMeta = resolveAttrComponent(prefix, name);
private void parseNamespaces() { Attributes attributes = tag.getAttributes(); if( attributes != null ) { for( Attribute attribute : tag.getAttributes() ) { String name = attribute.getName(); if( name.toLowerCase(Locale.ROOT).startsWith( "xmlns" ) ) { int colon = name.indexOf( ':', 5 ); String prefix; if( colon <= 0 ) { prefix = ""; } else { prefix = name.substring( colon ); } namespaces.put( prefix, attribute.getValue() ); } } } }
/** * Populates the specified <code>Map</code> with the name/value pairs from these attributes. * <p> * Both names and values are stored as <code>String</code> objects. * <p> * The entries are added in order of apprearance in the source document. * <p> * An attribute with {@linkplain Attribute#hasValue() no value} is represented by a map entry with a <code>null</code> value. * <p> * Attribute values are automatically {@linkplain CharacterReference#decode(CharSequence) decoded} * before storage in the map. * * @param attributesMap the map to populate, must not be <code>null</code>. * @param convertNamesToLowerCase specifies whether all attribute names are converted to lower case in the map. * @return the same map specified as the argument to the <code>attributesMap</code> parameter, populated with the name/value pairs from these attributes. * @see #generateHTML(Map attributesMap) */ public Map<String,String> populateMap(final Map<String,String> attributesMap, final boolean convertNamesToLowerCase) { for (Attribute attribute : this) { attributesMap.put(convertNamesToLowerCase ? attribute.getKey() : attribute.getName(),attribute.getValue()); } return attributesMap; }
private void processAttribute( Attribute attribute ) { writer.write( " " ); writer.write( attribute.getName() ); if(attribute.hasValue()) { /* * non decoded value, return the raw value of the attribute as it appears * in the source document, without decoding, see KNOX-791. */ String inputValue = attribute.getValueSegment().toString(); String outputValue = inputValue; try { Level tag = stack.peek(); String name = getRuleName(inputValue); outputValue = filterAttribute( tag.getQName(), tag.getQName( attribute.getName() ), inputValue, name ); if( outputValue == null ) { outputValue = inputValue; } } catch ( Exception e ) { LOG.failedToFilterAttribute( attribute.getName(), e ); } writer.write( "=" ); writer.write( attribute.getQuoteChar() ); writer.write( outputValue ); writer.write( attribute.getQuoteChar() ); } }
private void processAttribute( Attribute attribute ) { writer.write( " " ); writer.write( attribute.getName() ); if(attribute.hasValue()) { /* * non decoded value, return the raw value of the attribute as it appears * in the source document, without decoding, see KNOX-791. */ String inputValue = attribute.getValueSegment().toString(); String outputValue = inputValue; try { Level tag = stack.peek(); String name = getRuleName(inputValue); outputValue = filterAttribute( tag.getQName(), tag.getQName( attribute.getName() ), inputValue, name ); if( outputValue == null ) { outputValue = inputValue; } } catch ( Exception e ) { LOG.failedToFilterAttribute( attribute.getName(), e ); } writer.write( "=" ); writer.write( attribute.getQuoteChar() ); writer.write( outputValue ); writer.write( attribute.getQuoteChar() ); } }
private CharSequence getStartTagHTML(StartTag startTag) { // tidies and filters out non-approved attributes StringBuilder sb = new StringBuilder(); sb.append('<').append(startTag.getName()); for (Attribute attribute : startTag.getAttributes()) { if (allowedAttributes.contains(attribute.getKey().toLowerCase())) { sb.append(' ').append(attribute.getName()); if (attribute.getValue() != null) { sb.append("=\""); sb.append(CharacterReference.encode(attribute.getValue())); sb.append('"'); } } } if (startTag.getElement().getEndTag() == null && !HTMLElements.getEndTagOptionalElementNames().contains(startTag.getName())) { sb.append(" /"); } sb.append('>'); return sb; }
literalChar.get(0) + attr.getValue() + literalChar.get(0), errorReporter); if (errors.isEmpty()) { expressions.put(attr.getName().toLowerCase(), exp); continue; final CFExpression exp = cfmlParser .parseCFMLExpression(literalChar.get(1) + attr.getValue() + literalChar.get(1), this); expressions.put(attr.getName().toLowerCase(), exp); } catch (final Exception e2) { if (!quiet) { } else if (tagInfo.isExpressionAttribute(elem, attr.getName())) { try { final CFExpression exp = cfmlParser.parseCFMLExpression(attr.getValue(), this); expressions.put(attr.getName().toLowerCase(), exp); } catch (final Exception e2) { if (!quiet) {
literalChar.get(0) + attr.getValue() + literalChar.get(0), errorReporter); if (errors.isEmpty()) { expressions.put(attr.getName().toLowerCase(), exp); continue; final CFExpression exp = cfmlParser .parseCFMLExpression(literalChar.get(1) + attr.getValue() + literalChar.get(1), this); expressions.put(attr.getName().toLowerCase(), exp); } catch (final Exception e2) { if (!quiet) { } else if (tagInfo.isExpressionAttribute(elem, attr.getName())) { try { final CFExpression exp = cfmlParser.parseCFMLExpression(attr.getValue(), this); expressions.put(attr.getName().toLowerCase(), exp); } catch (final Exception e2) { if (!quiet) {
private Map<String, Pair<String, Position>> makeAllAttributes() { Map<String, Pair<String, Position>> result = HashMapFactory.make(); if (innerElement.getStartTag().getAttributes() != null) { for (Attribute a : innerElement.getStartTag().getAttributes()) { result.put( a.getName().toLowerCase(), Pair.make(a.getValue(), getPosition(a.getValueSegment()))); } } return result; }
private Map<String, Pair<String, Position>> makeAllAttributes() { Map<String, Pair<String, Position>> result = HashMapFactory.make(); if (innerElement.getStartTag().getAttributes() != null) { for (Attribute a : innerElement.getStartTag().getAttributes()) { result.put( a.getName().toLowerCase(), Pair.make(a.getValue(), getPosition(a.getValueSegment()))); } } return result; }
for (Attribute attribute : attributes) { if (attribute != null) { String name = attribute.getName(); if (name != null && (isDirective(name) || (attributeNamespace != null && name.startsWith(attributeNamespace)) && isDirective(name.substring(attributeNamespace.length())))) { // 识别名称空间 String directiveName = attributeNamespace != null ? name.substring(attributeNamespace.length()) : name; String name = attribute.getName(); if (ifattr.equals(name)) { String val = attribute.getValue(); String buf = String.format("#if(%s)%s=\"%s\"#end()", expression, oriattr.getName(), oriattr.getValue()); document.replace(new Segment(source, oriattr.getBegin(), oriattr.getEnd()), buf); document.remove(new Segment(source, attribute.getBegin(), attribute.getEnd())); // 移除ifattr控制属性 String name = attribute.getName(); if (setattr.equals(name)) { String val = attribute.getValue();
String value2 = st2.getAttributeValue(attribute1.getName()); if(value2 == null) { System.out.println("Attribute not present in stream2: attribute1=" + attribute1.getBegin() + "; tag2=" + st2.getBegin());
startTag.getAttributes().populateMap(attributeMap, true), attribute.getName())) { case ATTRIBUTE_TRANS: propertyOrTextUnitPlaceholders.add(createPropertyTextUnitPlaceholder( PlaceholderAccessType.TRANSLATABLE, attribute.getName(), attribute.getValue(), startTag, attribute)); break; PlaceholderAccessType.WRITABLE_PROPERTY, attribute.getName(), attribute.getValueSegment().toString(), startTag, attribute)); break; case ATTRIBUTE_READONLY: propertyOrTextUnitPlaceholders.add(createPropertyTextUnitPlaceholder( PlaceholderAccessType.READ_ONLY_PROPERTY, attribute.getName(), attribute.getValue(), startTag, attribute)); break; case ATTRIBUTE_ID: propertyOrTextUnitPlaceholders.add(createPropertyTextUnitPlaceholder( PlaceholderAccessType.NAME, attribute.getName(), attribute.getValue(), startTag, attribute)); currentId = attribute.getValue() + "-" + attribute.getName(); break; case ATTRIBUTE_PRESERVE_WHITESPACE: boolean preserveWS = getConfig().isPreserveWhitespaceCondition(attribute.getName(), attributeMap); boolean defaultWS = getConfig().isDefaultWhitespaceCondition(attribute.getName(), attributeMap); PlaceholderAccessType.WRITABLE_PROPERTY, attribute.getName(), attribute.getValue(), startTag, attribute));
att.getValue().toLowerCase().indexOf(target.toLowerCase()) >= 0) { context.setTagAttribute(att.getName()); context.setInUrlAttribute(this.isUrlAttribute(att.getName())); context.setInScriptAttribute(this.isScriptAttribute(att.getName())); if (isInputTag && att.getName().equalsIgnoreCase("type") && "image".equalsIgnoreCase(att.getValue())) { isImageInputTag = true;
localComponent.flatMap(lc -> lc.getPropForAttribute(attribute.getName())); optionalProp.ifPresent(foundProps::add);
private TemplateNode parseDomElement(Element elem) { DOMElement templateElem = new DOMElement(elem.getName()); templateElem.setLocation(new Location(elem.getBegin(), elem.getEnd())); for (int i = 0; i < elem.getAttributes().size(); ++i) { Attribute attr = elem.getAttributes().get(i); if (attr.getName().indexOf(':') > 0) { AttributeComponentBinding component = parseAttributeComponent(attr); if (component != null) { templateElem.getAttributeComponents().add(component); } } else { templateElem.setAttribute(attr.getName(), attr.getValue(), new Location(attr.getBegin(), attr.getEnd())); } } Set<String> vars = new HashSet<>(); for (AttributeComponentBinding attrComponent : templateElem.getAttributeComponents()) { for (ComponentVariableBinding var : attrComponent.getVariables()) { vars.add(var.getName()); pushVar(var.getName(), var.getValueType()); } } parseSegment(elem.getEnd(), templateElem.getChildNodes(), child -> true); for (String var : vars) { popVar(var); } return templateElem; }
private TemplateNode parseDomElement(Element elem) { DOMElement templateElem = new DOMElement(elem.getName()); templateElem.setLocation(new Location(elem.getBegin(), elem.getEnd())); for (int i = 0; i < elem.getAttributes().size(); ++i) { Attribute attr = elem.getAttributes().get(i); if (attr.getName().indexOf(':') > 0) { AttributeComponentBinding component = parseAttributeComponent(attr); if (component != null) { templateElem.getAttributeComponents().add(component); } } else { templateElem.setAttribute(attr.getName(), attr.getValue(), new Location(attr.getBegin(), attr.getEnd())); } } Set<String> vars = new HashSet<>(); for (AttributeComponentBinding attrComponent : templateElem.getAttributeComponents()) { for (ComponentVariableBinding var : attrComponent.getVariables()) { vars.add(var.getName()); pushVar(var.getName(), var.getValueType()); } } parseSegment(elem.getEnd(), templateElem.getChildNodes(), child -> true); for (String var : vars) { popVar(var); } return templateElem; }