Example #1
0
def GenerateId(context, nodeSet=None):
    if nodeSet is not None and type(nodeSet) != type([]):
        raise XsltException(Error.WRONG_ARGUMENT_TYPE)
    if not nodeSet:
        return 'id' + ` id(context.node) `
    else:
        node = Util.SortDocOrder(nodeSet)[0]
        return 'id' + ` id(node) `
Example #2
0
 def evaluate(self, context):
     lSet = self._left.evaluate(context)
     if type(lSet) != type([]):
         raise StringException(
             "Left Expression does not evaluate to a node set")
     rSet = self._right.evaluate(context)
     if type(rSet) != type([]):
         raise StringException(
             "Right Expression does not evaluate to a node set")
     set = Set.Union(lSet, rSet)
     set = Util.SortDocOrder(set)
     return set
Example #3
0
def LocalName(context, nodeSet=None):
    """Function: <string> local-name(<node-set>?)"""
    if nodeSet is None:
        node = context.node
    else:
        if type(nodeSet) != type([]):
            raise RuntimeException(RuntimeException.WRONG_ARGUMENTS,
                                   'local-name', _("expected node set"))
        nodeSet = Util.SortDocOrder(nodeSet)
        if type(nodeSet) != type([]) or len(nodeSet) == 0:
            return ''
        node = nodeSet[0]
    en = ExpandedName(node)
    if en == None or en.localName == None:
        return ''
    return en.localName
Example #4
0
def NamespaceUri(context, nodeSet=None):
    """Function: <string> namespace-uri(<node-set>?)"""
    if nodeSet is None:
        node = context.node
    else:
        if type(nodeSet) != type([]):
            raise RuntimeException(
                RuntimeException.WRONG_ARGUMENTS,
                "namespace-uri",
                _("expected node set"),
            )
        nodeSet = Util.SortDocOrder(nodeSet)
        if type(nodeSet) != type([]) or len(nodeSet) == 0:
            return ""
        node = nodeSet[0]
    en = ExpandedName(node)
    if en == None or en.namespaceURI == None:
        return ""
    return en.namespaceURI