WAS v8.5 > Develop applications > XML applications > Use the XML API to perform operations > Performing basic operations > Overview of the XML API

Performance tips

Follow these tips to improve performance when using XPath, XQuery, and XSLT.

Performance tips. Follow these tips to improve performance.

Language Tip
XPath Use // can be an expensive operation. Making the path more explicit (a/b/c rather than a//c) can improve performance. This is especially important when the path starts at or near the root of a large document.
The last() function, because it requires fully evaluating the sequence to count the items, can be an expensive operation.
Positional predicates with constant values, such as [3], are usually more efficient than those with values that are computed or that are retrieved from variables.
XQuery Consider calling the registerImportedSchemas method on the XQueryExecutable instance if the query imports one or more schemas and the same query will be executed more than once. If registerImportedSchemas is not called, the imported schemas will be loaded every time one of the execute methods is called. By default, imported schemas can only be used to validate result trees; but calling this method has the same effect as registering the schemas with the XFactory, which means they will be used to validate input documents.
XSLT Parameters are slower to access than variables. If we do not need to supply the value of the parameter externally, use a variable.
Use xsl:key elements and the key() function can be an efficient way to retrieve node sets.
Pattern matching and apply-templates dispatch are usually faster than the xsl:if or xsl:when statements.
Positional predicates in match patterns are usually expensive.
In general, simpler match patterns such as "address" are less expensive to process than complicated ones such as "/purchaseorder/shipping/customer/postal/address". Take advantage of your knowledge of the document's structure and your stylesheet's behavior to avoid unnecessarily overspecifying.
For some data models, the xsl:skip-space operation must be applied during document navigation rather than during document load. This can add some execution-time overhead.
Consider calling the registerImportedSchemas method on the XSLTExecutable instance if the stylesheet imports one or more schemas and the same stylesheet will be executed more than once. If registerImportedSchemas is not called, the imported schemas will be loaded every time one of the execute methods is called. By default, imported schemas can only be used to validate result trees; but calling this method has the same effect as registering the schemas with the XFactory, which means they will be used to validate input documents.
XPath, XQuery, and XSLT Decoding and encoding is expensive. Generally, UTF-8 and UTF-16 can be read and written more quickly than other encodings.


+

Search Tips   |   Advanced Search