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 static boolean tagHasUnquotedAttribute(StartTag tag) { if (tag.getAttributes() != null && !tag.getAttributes().isEmpty() && tag.getTagType() != StartTagType.XML_DECLARATION && tag.getTagType() != StartTagType.DOCTYPE_DECLARATION && tag.getTagType() != StartTagType.XML_PROCESSING_INSTRUCTION) { for (Attribute att : tag.getAttributes()) { if (att.getQuoteChar() == ' ') { return true; } } } return false; } }