@ Override protected Object doExec ( Element element , Object scope , String propertyPath , Object ... arguments ) throws IOException , TemplateException { if ( ! propertyPath . equals ( "." ) && ConverterRegistry . hasType ( scope . getClass ( ) ) ) { throw new TemplateException ( "Operand is property path but scope is not an object." ) ; } if ( element . hasChildren ( ) ) { throw new TemplateException ( "Illegal TEXT operator on element with children." ) ; } Format format = ( Format ) arguments [ 0 ] ; String text = content . getString ( scope , propertyPath , format ) ; if ( text != null ) { serializer . writeTextContent ( text ) ; } return null ; }
Execute TEXT operator . Uses property path to extract content value convert it to string and set element text content . Note that this operator operates on element without children . Failing to obey this constraint rise templates exception ; anyway validation tool catches this condition .