Context: Context

View source: R/Context.R

ContextR Documentation

Context

Description

Binds a value to the context. The type will be ignored if the string is empty. The function returns no value.

Usage

Context(query_obj, value, type)

Arguments

query_obj

QueryClass instance-ID

value

Value that should be boud to the context

type

The type will be ignored when the string is empty

Details

The type that is provided to the context, should be one of the standard-types. An alternative way is to parse the document information. This method returns self invisibly, thus making it possible to chain together multiple method calls.

Examples

## Not run: 
ctxt_query_txt <- "for $t in .//text() return string-length($t)"
ctxt_query     <- Query(Session, ctxt_query_txt)
ctxt_txt       <- paste0("<xml>",
                         "<txt>Hi</txt>",
                         "<txt>World</txt>",
                         "</xml>")
Context(ctxt_query, ctxt_txt, type = "document-node()")
print(Execute(ctxt_query))  ## returns "2"  "5"

ctxt_query_txt <- "for $t in parse-xml(.)//text() return string-length($t)"
Context(ctxt_query, ctxt_txt)
print(Execute(ctxt_query))

## End(Not run)


RBaseX documentation built on Dec. 2, 2022, 5:10 p.m.

Related to Context in RBaseX...