
from Ft.Xml.Xslt import XsltElement, ContentInfo, AttributeInfo

EXTENSION_NAMESPACE = "http://test.com/foo"

def Test(context):
    repo = context.processor._repository

    if hasattr(repo,'_TestVariable'):
        repo._TestVariable = repo._TestVariable + 1
    else:
        repo._TestVariable = 1

    return "Nothing"

class TestElement(XsltElement):
    """
    Set another var on the context
    """

    content = ContentInfo.Empty

    legalAttrs = {
        }

    childArgument = None

    def instantiate(self, context, processor):
        context.setProcessState(self)
        repo = context.processor._repository

        if hasattr(repo,'_TestElementVariable'):
            repo._TestElementVariable = repo._TestElementVariable + 1
        else:
            repo._TestElementVariable = 1
        return (context,)



ExtFunctions = {
    (EXTENSION_NAMESPACE, 'test'): Test,
    }

ExtElements = {
    (EXTENSION_NAMESPACE, 'test'): TestElement,
    }
