Package lxml :: Module etree :: Class XSLTExtension |
[hide private]
[frames] | no frames]

# Class XSLTExtension

    object --+
             |
            XSLTExtension

Base class of an XSLT extension element.

Instance Methods | [hide private]
a new object with type S, a subtype of T |
__new__(T, S, ...) |
apply_templates(self, context, node, output_parent=None, elements_only=False, remove_blank_text=False) Call this method to retrieve the result of applying templates to an element. |
execute(self, context, self_node, input_node, output_parent) Execute this extension element. |
process_children(self, context, output_parent=None, elements_only=False, remove_blank_text=False) Call this method to process the XSLT content of the extension element itself. |
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__init__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __new__(T, S, ...) |
Returns: a new object with type S, a subtype of T Overrides: object.__new__

### apply_templates(self, context, node, output_parent=None, elements_only=False, remove_blank_text=False) |
Call this method to retrieve the result of applying templates to an element. The return value is a list of elements or text strings that were generated by the XSLT processor. If you pass `elements_only=True`, strings will be discarded from the result list. The option `remove_blank_text=True` will only discard strings that consist entirely of whitespace (e.g. formatting). These options do not apply to Elements, only to bare string results. If you pass an Element as `output_parent` parameter, the result will instead be appended to the element (including attributes etc.) and the return value will be `None`. This is a safe way to generate content into the output document directly, without having to take care of special values like text or attributes. Note that the string discarding options will be ignored in this case.

### execute(self, context, self_node, input_node, output_parent) |
Execute this extension element. Subclasses must override this method. They may append elements to the `output_parent` element here, or set its text content. To this end, the `input_node` provides read-only access to the current node in the input document, and the `self_node` points to the extension element in the stylesheet. Note that the `output_parent` parameter may be `None` if there is no parent element in the current context (e.g. no content was added to the output tree yet).

### process_children(self, context, output_parent=None, elements_only=False, remove_blank_text=False) |
Call this method to process the XSLT content of the extension element itself. The return value is a list of elements or text strings that were generated by the XSLT processor. If you pass `elements_only=True`, strings will be discarded from the result list. The option `remove_blank_text=True` will only discard strings that consist entirely of whitespace (e.g. formatting). These options do not apply to Elements, only to bare string results. If you pass an Element as `output_parent` parameter, the result will instead be appended to the element (including attributes etc.) and the return value will be `None`. This is a safe way to generate content into the output document directly, without having to take care of special values like text or attributes. Note that the string discarding options will be ignored in this case.