STX templates are called sequentially for each incoming node rather than from other templates. Pair events for the document and elements match only one template, which is broken into two parts; the first part is executed when the start event appears and the second one at the end event.
The two parts are separated by the stx:process-children element. Namespaces from source streams can be mapped to different namespaces in result streams using the stx:namespace-alias element. Both attributes are mandatory and can contain either a prefix bound to the namespace to be used or the " default" keyword for the default namespace. Rules to process input events are written in templates.
The stx:template element must be a child of either the stx:transform or the stx:group element. Templates match to the events by means of precedence categories and a pattern in the mandatory match attribute. The optional priority attribute can contain an explicit priority value used for matching see 2. Two optional attributes; visibility and public ; control whether the template is visible from other groups and thus can match to the next event or not. The default value of the visibility attribute is "local".
The default value of the public attribute for top-level templates as "yes", for group templates it is "no". Whether a top-level template is public or not is important only when the stylesheet is included into another stylesheet, because every top-level template then becomes a group template, see 3. The optional new-scope attribute specifies whether the template creates new instances of group variables. These variables shadow their former values and exist as long as the template is being processed.
The content of templates may include both STX instructions and declarations, and literal elements. Literal elements are simply copied to the output. A text template is defined as the content of some elements stx:attribute , stx:variable , stx:param , stx:assign , stx:with-param , stx:cdata , stx:processing-instruction , stx:comment , stx:message.
This is a part of template that generates nothing but character events to the current output stream. An STX processor is required to issue a run-time recoverable error if another type of event is emitted. The processor is allowed to recover from this error by ignoring the non-character event.
Procedures are sub-templates that can be called by names with the stx:call-procedure instruction. The optional visibility , public , and new-scope attributes have the same meaning and default values as for templates. Only visible procedures can be called by name, the new-scope must be set to "yes" to create new copies of group variables. It is a static non-recoverable error if a stylesheet contains more than one visible procedure with the same name within the same precedence category.
The stx:call-procedure element makes it possible to invoke a procedure by its name. The name attribute is mandatory. The optional group attribute allows to use the specified group instead of the current group as a base group for calling the procedure. The target procedure will be determined according to the precedence categories described in 2. If the first category doesn't contain a procedure with the requested name, then the second category will be searched.
If neither the first nor the second category contain such procedure, the third category is searched. It is a static non-recoverable error if none of the three precedence categories contain the requested procedure. Values can be passed to stylesheets or to their templates and procedures as parameters.
Parameter are variables see 6. Stylesheet parameters behave in the same way as variables of the default group. There are two elements available to work with parameters:.
Parameters are passed to templates or procedures using the stx:with-param element. The required name attribute specifies the name of the parameter. The value of the parameter is either the result returned by the expression located in the optional select attribute or the content of this element if the select attribute is missing.
If neither the select attribute nor the content is present the parameter value is the empty string. The stx:with-param instruction is allowed as a child of the elements stx:process-children , stx:process-attributes , stx:process-self , stx:process-siblings , stx:process-document , stx:process-buffer , or stx:call-procedure , and must not have any of these elements in its content. The stx:param element is allowed as a top-level element indicating a stylesheet parameter as a child of stx:transform and in templates or procedures as a child of stx:template or stx:procedure.
The optional select attribute or the content of this element specifies a default value, which is both evaluated and used only when there is no value specified using the select attribute or the content of the appropriate stx:with-param element. Should both the select attribute and the content be missing, the parameter defaults to the empty string. Stylesheet parameters are statically initialized while parsing the stylesheet; only the static context information is available during the initialization.
Since there is no current source stream available during the static initialization, it is a recoverable error if a stylesheet top-level parameter has an stx:process-children , stx:process-attributes , stx:process-self , or stx:process-siblings instruction in its content.
A processor may recover from this error by ignoring such an instruction. The optional required attribute may be used to indicate that a parameter is mandatory. The default value is "no", indicating that the parameter is optional. If the value of the required attribute is "yes", the stx:param element must be empty, and must have no select attribute.
It is a dynamic non-recoverable error if the caller doesn't supply a value with stx:with-param for a required parameter. The stx:copy element is used to copy the current node to the output. The optional attributes attribute contains a pattern. These attributes of the current node that match the pattern are copied to the output. If the attributes attribute isn't present no attributes are copied with the current node.
If the stx:copy instruction applies to a node other than element the attributes attribute is ignored. The instruction stx:process-children suspends the processing of the current template by processing the children of the current node. Using SAX2 terms: this instruction splits a template into two parts such that a SAX2 startElement event causes the execution of the first part and the corresponding SAX2 endElement event causes the execution of the second part.
There must be always at most one stx:process-children instruction executed during the processing of a template. Moreover, it is a non-recoverable error if stx:process-children is encountered after an stx:process-self instruction or an stx:process-siblings instruction. If a template doesn't contain any stx:process-children instruction, the children of this element will be skipped. The default rule applies only to nodes that are processed and no matching template is found. If the current node is neither an element node nor the document root then the stx:process-children instruction simply does nothing.
The optional group attribute makes it possible to use the specified group instead of the current group as the base for matching see 2. It is a recoverable error if the group of the specified name is not available. An STX processor can recover from this error by using the current group.
The stx:process-siblings instruction suspends the processing of the current template and processes the following siblings of the current node. The processing can be terminated by one of while or until conditions, or because of the end of the parent element or the current buffer see stx:process-buffer. If the current node is an attribute node or the document root node the stx:process-siblings instruction does nothing.
The optional while attribute contains a pattern. The next siblings are processed as long as they match the specified pattern. The first non-matching node stops the processing; this node is not processed by this stx:process-siblings instruction.. The while attribute defaults to node. The optional until attribute contains a pattern. The next siblings are processed until a node matching the pattern is encountered; this node is not processed by this stx:process-siblings instruction.
The until attribute defaults to node [false ]. If both while and until attributes have been specified then both conditions have to be met.
Variable bindings used within the patterns will be interpreted with regard to the current context. That means changed group variables affect the evaluation, whereas new instances of group variables or local variables are not visible. Whitespace text nodes not stripped from the document must be considered in the patterns, particularly when using the while attribute. An stx:process-siblings instruction encountered during the processing of siblings does not affect the while and until conditions of the previous stx:process-siblings.
In other words: nested stx:process-siblings instructions process at most the siblings chosen in the preceding stx:process-siblings. That means stx:process-siblings also returns if there are no more siblings in the input available or a preceding stx:process-siblings terminates. Though multiple stx:process-siblings instructions may appear within the same template it is a non-recoverable error if an stx:process-children or stx:process-self instruction will be encountered after stx:process-siblings.
This instruction is used to process the current node using the template that would have been chosen if the current template wasn't present in the stylesheet. The current template won't be instantiated again for this node, even in a chain of calls to stx:process-self.
There must be always at most one stx:process-self instruction executed during the processing of a template. Moreover it is a non-recoverable error if an stx:process-self instruction is encountered after an stx:process-children or an stx:process-siblings instruction in a template.
If no group attribute has been specified then the current group will be used for choosing the next best matching template. This is also true if the current group has been automatically entered via a public template.
This instruction processes a string in a similar way as stx:template processes nodes. The mandatory select attribute of stx:process-text selects a string to process by evaluating the expression and converting it to a string. The mandatory regexp attribute of stx:pattern takes a regular expression by evaluating the expression in the regexp attribute and converting it to a string, which describes a substring to look for. The optional case attribute determines whether the regular expression is case-sensitive value "sensitive" or not value "insensitive".
The default is "sensitive". The stx:process-text instruction looks for the pattern among the regexp attributes of all stx:pattern elements that matches first in the string selected by the select attribute. The substring before the matched substring will be output, and the matched substring itself will be replaced by the contents of the stx:pattern element. Afterwards this stx:process-text instruction will continue by processing the substring after the matched substring.
If no pattern matches then the remaining string will be emitted as a text node to the result stream. A pattern must match at least one character. In case two or more pattern may match at the same position then the pattern which matches the longest character sequence will be used. If still two or more patterns meet this condition then the first one will be used. This instructions emits characters to the result stream. The mandatory select attribute contains an STXPath expression which is evaluated and converted to a string.
This element is always empty. The optional markup attribute determines how non-text nodes in the content of stx:text should be handled: "error" causes the processor to raise a run-time recoverable error for such nodes, "ignore" ignores any markup by emitting only the string value of the contents to the result stream, "serialize" emits any markup serialized as text.
The default value is "error". The processor may recover from an error raised because having markup set to "error" by ignoring this attempt. For example every STX implementation may choose its own order for serializing attributes. The stx:text element has an implicit xml:space attribute with the default value "preserve". Thus the content is normally neither normalized nor stripped should it contain whitespace characters only. The stx:cdata element has an implicit xml:space attribute with the default value "preserve".
This instruction is used to generate an element. It has the same meaning as in [XSLT]. There are separate instructions available to output an element start tag and an element end tag.
The name attribute is required for both instructions. The both elements must be empty. An attempt to create an end-tag without a matching start-tag must be reported as non-recoverable error by the STX processor. This instruction is used to generate an attribute. Alternatively, the value of the generated attribute may be specified in the optional select attribute.
It is a recoverable error of this instruction has a select attribute and is not empty. A processor can recover from this error by ignoring the content of stx:attribute. It is a recoverable error if there is no immediate element-starting instruction before. A processor can recover from this error by ignoring the stx:attribute instruction. This instruction is used to generate a processing instruction. This instruction is used to generate a comment.
The mandatory test attribute contains an STXPath expression evaluating to boolean. The content template is instantiated if and only if the test attribute has evaluated to true. This instruction must follow immediately after stx:if ; a non-recoverable error must be reported otherwise. The content template is instantiated if and only if the test attribute of the preceding stx:if instruction has evaluated to false. The stx:for-each-item instruction contains a template that is instantiated for each item of the sequence specified by the mandatory select attribute.
The mandatory name attribute specifies a name of local variable that is declared automatically for each item, and that contains the current item. Neither the current node accessed with. The contents of the stx:while element is instantiated repeatedly as long as the test attribute evaluates to true. A stylesheet can process further source streams in addition to this supplied when the transformation is invoked the principal source stream.
The current source stream can be changed with the stx:process-document instruction. When this instruction is instantiated the expression in the mandatory href attribute will be evaluated, each item in the resulting sequence will be converted sequentially to a string a URI , and its value will be used to identity and to process a new current source stream.
Then, the execution of the template containing the stx:process-document instruction continues with the original source stream. Alternatively, the optional base attribute can be used to specify explicitly which base URI should be used. Its value must be either an absolute URI, the string " input" in which case the base URI of the current input stream will be used, or the string " stylesheet" in which case the base URI of the principal stylesheet will be used.
When processing a new document, the ancestor stack of the original document is not available for matching and navigation. Each new document has an ancestor stack of its own. A stylesheet can produce further result streams in addition to the principal result stream. The current result stream can be changed with the stx:result-document instruction. Events generated as the result of executing instructions contained within the stx:result-document element are emitted to a new current result stream identified with the URI which is the result of evaluating the expression in the required href attribute and converting its value to a string.
Then, the execution of instructions behind the end of the stx:result-document element continues to emit events into the original result stream. The optional encoding attribute can be used to specify a preferred output encoding for the new result stream. If this attribute is not present the encoding of the principal result stream will be used.
A sequence of events can be stored into an object called a buffer. The stored events can be emitted and processed later, in the same way as events emitted from a source stream. The events are emitted from a buffer in the same order as they were stored in. In other words, the buffers are temporary storages of the 'first in first out' type.
The events stored in a buffer must represent a well-formed external general parsed entity the restriction on a single root node is relaxed. Top-level buffers are considered members of the top-most default group that exists for each stylesheet. A buffer must be declared before it can be used. The same rules as for variables see 6. The stx:buffer element declares a buffer.
The mandatory name attribute contains a qualified name identifying the declared buffer. The buffer is initialized with events generated as a result of the evaluation of the content of the stx:buffer.
If the content is empty stx:buffer element has no children the buffer is empty. For group buffers, the content of stx:buffer element is evaluated statically.
It is a recoverable error if the element stx:buffer declaring a group buffer contains an stx:process-children , stx:process-self , stx:process-siblings , stx:process-attributes , stx:process-document , stx:process-buffer , or call-procedure instruction in its content. The stx:result-buffer instruction directs events emitted by its content into the buffer specified with the mandatory name attribute rather than to the current result stream. The buffer must be declared with stx:buffer before it can be employed in stx:result-buffer.
If the buffer specified with the name attribute already contains a sequence of events, the new sequence of events is appended behind the last event in the previously stored sequence normally. If the stx:result-buffer element has the optional clear attribute with the value of "yes", the previously stored events are removed from the buffer before the new sequence of events is stored in. The clear attribute defaults to "no".
The events stored in a buffer will be available for a following stx:process-buffer not before the stx:result-buffer instruction has terminated. Until then the previous contents is accessible. It is a non-recoverable error if this instruction is executed for a buffer that acts already as current or suspended result buffer. The stx:process-buffer instruction emits the events currently stored in the buffer specified by the mandatory name attribute to the STX processor.
The events are processed in the same way as events supplied by source streams. When the very last event from the buffer is processed, the processing in the current template continues with an instruction, declaration or literal next to the stx:process-buffer instruction.
Changes to the contents of a buffer that is currently processed won't affect this processing. The stx:process-buffer instruction creates an internal copy of the contained events and emits them afterwards.
The processing of events from a buffer doesn't mean the emptying of this buffer. Once a sequence of events is stored in the buffer, it can be processed repeatedly. A buffer is not treated as a new document, but rather as if events emitted from the buffer originate from the current source stream. The ancestor stack of the current source stream remains available for matching and navigation when processing nodes from the buffer.
The stx:message instruction generates a separate result stream whose handling is implementation dependent. It can be directed to a log, or to a special message resolver, etc. However, all instructions of the content of the stx:message element must processed even if the message stream is ignored.
There are seven types of node recognized in STXPath see 2. For every type of node, there is a way of determining the string-value.
Since descendants are not available in the time of processing, string-values for some types of nodes are different from XPath string-values. An STX processor is allowed to recover from this error by returning the empty string.
Otherwise, the string-value of the element is the empty string. A sequence is an ordered collection of zero or more items. Unlike common lists, sequences are "flat"; sequences may not contain other sequences. Sequences may contain duplicate items. An item must be of one of the atomic types: string, number, boolean, or node. A sequence with zero items is called an empty sequence. A sequence with exactly one item is called a singleton sequence.
There is no distinction between an item and a singleton sequence containing this item; an item is equivalent to a singleton sequence containing this item and vice versa. A sequence has no identity. Equality comparison of sequences is performed only by comparing items of the sequences. Certain operators, functions, and syntactic constructs expect a value of a particular type to be supplied: this type is referred to as a required type. In such an event, a general sequence is converted to the required type according to the conversion rules.
A singleton sequence is converted to a required type according to the type of the only item in the sequence. An attempt to convert boolean, string, or number to node causes a non-recoverable error. A sequence containing more than one item is converted according to its very first item; all other items are ignored. The same conversion rules as for singleton sequences are applied see the table above.
Consider the following example:. In STXPath, on contrary, the same expression returns only a single node from this node-set; the one which is an ancestor of the current node. Each expression has its static context - the information that is available during static analysis of the expression, prior to its evaluation. The static context includes in-scope namespaces, default namespace for element names, default function namespace, and in-scope variables. The information that is available at the time when the expression is evaluated is the current context as defined in 2.
Expressions evaluate always to a sequence. STX variables are scoped statically according to the literal structure of stylesheets. The grouping of templates is used to make the sharing of other than global variables possible. Top-level variables are considered to be members of the top-most default group that exists for each stylesheet.
A group variable is visible for the group where the variable is declared, for all descendant groups and for all templates belonging to these groups.
A local variable is visible for all following siblings of the variable declaration and their descendants. Group variables may be shadowed another variable with the same name is visible by descendant group variables and by local variables.
It is a non-recoverable error to redeclare a variable with the same name in the same group or template. Variables always contain a sequence.
STX instructions stx:variable and stx:assign are used to evaluate an expression and store its value into a variable. Since variables are re-assignable, each variable must be declared using the stx:variable element before it's used assigned, referenced.
Group variables are statically initialized while parsing the stylesheet; Only the static context information is available during the initialization of group variables. Local variables are initialized at run-time. A variable declared with no value is initialized with the singleton sequence containing the empty string.
This instruction is used to declare and initialize a variable. The mandatory name attribute contains the name of the variable. An expression in the select attribute is evaluated and the variable is initialized with its result. The select attribute is optional; a variable is initialized with the string resulting from the content of the stx:variable element if the select is missing. If the content is empty stx:variable element has no children the variable is initialized with the empty string.
It is a recoverable error if the element stx:variable declaring a group variable contains an stx:process-children , stx:process-self , stx:process-siblings , stx:process-attributes , stx:process-document , stx:process-buffer , or call-procedure instruction in its content.
The optional keep-value attribute specifies whether a new instance of the variable created by instantiating a template having its new-scope attribute set to "yes" is initialized with the value of the shadowed variable yes or not no. This attribute is allowed only for group variables. The default value is no. If there is no shadowed variable yet, the keep-value attribute is ignored. This instruction is used to assign a new value to a previously declared variable.
The expression in the optional select attribute is evaluated and its result is assigned to the variable. The string resulting from the content of the stx:assign element is assigned to the variable if the select is missing.
If the content is empty, the empty string is assigned to the variable. A literal is a direct syntactic representation of an atomic value. STXPath supports two kinds of literals: string literals and numeric literals. The value of a string literal is a singleton sequence containing an item whose atomic type is string and whose value is the string denoted by the characters between the delimiting quotation marks.
The value of a numeric literal is a singleton sequence containing an item whose type is number and whose value is obtained by parsing the numeric literal according to the rules for string to numbers conversion see 5. Parentheses may be used to enforce a particular evaluation order in expressions that contain multiple operators.
Parentheses are also used as delimiters in constructing a sequence, as described in 6. A function call consists of a function qualified name followed by a parenthesized list of zero or more expressions. The expressions inside the parentheses provide the arguments of the function call. The number of arguments must be equal to the number of function parameters; otherwise a static non-recoverable error is raised. If the corresponding function parameter has a required type, the argument value is converted to this type.
The function is executed using the converted argument values. The result is a value of the function's declared return type. The sf: prefix is used to refer to this namespace in this document. The default function namespace is assigned to this reserved namespace in STX.
Thus, the functions namespace does not need to be declared in STX stylesheets and STXPath functions can be invoked without any namespace prefix. These functions are not re-defined in this section. Instead, original definitions in [Functions and Operators] are referenced. All errors raised when evaluating STXPath functions are non-recoverable errors see 2.
See the definition in [Functions and Operators]. Returns a sequence of integer numbers, each of which is the index of a member of the specified sequence that is equal to the item that is the value of the second argument. Returns the namespace URI for the QName of the argument node or the current node if the argument is omitted.
The sf:position function returns a number equal to the position of the current node relative to other siblings normally; see 2. The sf:has-child-nodes function returns true if and only if the current node is the document node or an element node and has child nodes it is not empty.
It returns false otherwise. The sf:node-kind function returns a string value representing the node's kind: either "document", "element", "attribute", "text", "cdata", "processing-instruction", or "comment".
Returns the namespace URI of one of the in-scope namespaces for the given element, identified by its namespace prefix. Returns true or false depending on whether the language of the current node, as defined using the xml:lang attribute, is the same as, or a sub-language of, the language specified by the argument.
Accepts a sequence of strings and returns the strings concatenated together with an optional separator. Indicates whether the value of one string begins with the characters of the value of another string. Indicates whether the value of one string ends with the characters of the value of another string. Indicates whether the value of one string contains the characters of the value of another string. Returns the characters of one string that precede in that string the characters in the value of another string.
Returns the characters of one string that succeed in that string the characters in the value of another string. Returns the normalized value of the first argument in the normalization form specified by the second argument. Returns the first argument string with occurrences of characters in the second argument replaced by the character at the corresponding position in the third string. Returns a string composed of as many copies of its first argument as specified in its second argument.
Returns a boolean value that indicates whether the value of the first argument is matched by the regular expression that is the value of the second argument. Returns the value of the first argument with every substring matched by the regular expression that is the value of the second argument replaced by the replacement string that is the value of the third argument.
Returns a sequence of zero or more strings whose values are substrings of the value of the first argument separated by substrings that match the regular expression that is the value of the second argument. The sf:sum function returns the sum, for each item in the argument sequence, of the result of converting the item to a number. If the value of the argument is the empty sequence, the function returns the empty sequence.
If an item can't be converted to a number, then an error is raised. The sf:avg returns the average of all items in the argument sequence converted to numbers. If the argument sequence is the empty sequence, the empty sequence is returned.
The sf:max converts all items of the argument sequence to numbers and returns the item whose value is greater than or equal to the value of every other item in the argument sequence. If there are two or more such items, then the specific item whose value is returned is implementation-dependent. The sf:min converts all items of the argument sequence to numbers and returns the item whose value is less than or equal to the value of every other item in the argument sequence.
The sf:string function returns the result of converting the argument to a string. See 5. The sf:number function returns the result of converting the argument to a number. The software development kit SDK includes everything you need to build and run. NET applications, using command-line tools and any editor like Visual Studio.
Run apps - Runtime Tooltip: Do you want to run apps? The runtime includes everything you need to run. NET applications. The runtime is also included in the SDK.
NET Core Runtime 3. NET Core Module v2 NET Desktop Runtime 3. Downloads for. NET Runtime 3. If using an older patch release, you should upgrade to get these fixes. Release notes Latest release date These releases are generally not supported for production use. Full version 3. Follow us. Package manager instructions. Arm32 Arm64 x64 x64 Alpine. Arm32 x64 x
0コメント