XQuery.CompileExternalVariable MethodXQuery.CompileExternalVariable MethodXQuery::CompileExternalVariable Method

Compiles the specified XQuery expression and returns an XQueryXQueryXQuery instance that represents the XQuery expression using the specified static context settings.

Syntax

Public Shared Function CompileExternalVariable( _
    query As String, _
    settings As XQuerySettings _
) As IEnumerable(Of System.Xml.XPath.XPathItem)
public static IEnumerable<System.Xml.XPath.XPathItem> CompileExternalVariable(
    string query,
    XQuerySettings settings
)
public:
static IEnumerable<System.Xml.XPath::XPathItem^>^ CompileExternalVariable(
    String^ query, 
    XQuerySettings^ settings
)
 

Parameters

query

Type: System.StringSystem.StringSystem::String^

An XQuery expression.

settings

Type: XmlPrime.XQuerySettingsXmlPrime.XQuerySettingsXmlPrime::XQuerySettings^

The initial static context settings.

Return Value

Type: System.Collections.Generic.IEnumerable<T>System.Collections.Generic.IEnumerable(Of T)System.Collections.Generic::IEnumerable<T>^

An IEnumerable<T>IEnumerable(Of T)IEnumerable<T> containing the result of evaluating the expression in the specified context, or null a null reference (Nothing in Visual Basic) nullptr if an unrecoverable error was raised and handled by a subscriber to CompilationErrorCompilationErrorCompilationError.

Exceptions

ExceptionCondition
ArgumentNullExceptionArgumentNullExceptionArgumentNullException query or settings is null a null reference (Nothing in Visual Basic) nullptr.
XdmExceptionXdmExceptionXdmExceptionAn error occurred compiling the query.

Remarks

Any errors or warnings encountered during compilation raise the CompilationErrorCompilationErrorCompilationError event. If nothing subscribes to this event then an XdmExceptionXdmExceptionXdmException is thrown if an unrecoverable error is encountered. If this event is subscribed to then the exception is not thrown, and this method returns null a null reference (Nothing in Visual Basic) nullptr instead.

The CompileExternalVariableCompileExternalVariableCompileExternalVariable method is used to compile a single XQuery expression, which can then be used to set the value of an external declared variable in another query. The query parameter should match the ExprSingle production, which is the same syntax as for a variable declaration in a query.

The NameTableNameTableNameTable property of the settings parameter should refer to the same XmlNameTableXmlNameTableXmlNameTable as is used in the XQueryXQueryXQuery for which this expression is a parameter.