@ Nonnull private String _getErrorText ( @ Nonnull final List < PSXPathBoundElement > aBoundContentElements , @ Nonnull final Node aSourceNode ) throws SchematronValidationException { final StringBuilder aSB = new StringBuilder ( ) ; for ( final PSXPathBoundElement aBoundElement : aBoundContentElements ) { final Object aContent = aBoundElement . getElement ( ) ; if ( aContent instanceof String ) aSB . append ( ( String ) aContent ) ; else if ( aContent instanceof PSName ) { final PSName aName = ( PSName ) aContent ; if ( aName . hasPath ( ) ) { // XPath present try { aSB . append ( ( String ) XPathEvaluationHelper . evaluate ( aBoundElement . getBoundExpression ( ) , aSourceNode , XPathConstants . STRING , m_sBaseURI ) ) ; } catch ( final XPathExpressionException ex ) { _error ( aName , "Failed to evaluate XPath expression to a string: '" + aBoundElement . getExpression ( ) + "'" , ex . getCause ( ) != null ? ex . getCause ( ) : ex ) ; // Append the path so that something is present in the output aSB . append ( aName . getPath ( ) ) ; } } else { // No XPath present aSB . append ( aSourceNode . getNodeName ( ) ) ; } } else if ( aContent instanceof PSValueOf ) { final PSValueOf aValueOf = ( PSValueOf ) aContent ; try { aSB . append ( ( String ) XPathEvaluationHelper . evaluate ( aBoundElement . getBoundExpression ( ) , aSourceNode , XPathConstants . STRING , m_sBaseURI ) ) ; } catch ( final XPathExpressionException ex ) { _error ( aValueOf , "Failed to evaluate XPath expression to a string: '" + aBoundElement . getExpression ( ) + "'" , ex ) ; // Append the path so that something is present in the output aSB . append ( aValueOf . getSelect ( ) ) ; } } else if ( aContent instanceof PSEmph ) aSB . append ( ( ( PSEmph ) aContent ) . getAsText ( ) ) ; else if ( aContent instanceof PSDir ) aSB . append ( ( ( PSDir ) aContent ) . getAsText ( ) ) ; else if ( aContent instanceof PSSpan ) aSB . append ( ( ( PSSpan ) aContent ) . getAsText ( ) ) ; else throw new SchematronValidationException ( "Unsupported assert/report content element: " + aContent ) ; } return aSB . toString ( ) ; }
Get the error text from an assert or report element .