ó <ěm>c@s9dZddlZddlZddlZddlZddlmZmZddlm Z ddl m Z ddl m Z mZmZmZd„Zd„Zdd „Zdd „Zdd „Zdd „Zd „Zd„Zdd„Zd„Zd„ZyddlZd„ZWn dZnXd„Z dd„Z!dd„Z"d„Z#d„Z$d„Z%i eedf6eedf6ej&dkr—epšeedf6eedf6eedf6eedf6eed f6e ed!f6e!ed"f6e"ed#f6e#ed$f6e$ed%f6e%ed&f6eed'f6eed(f6eed)f6eed*f6eedf6eedf6ej&dkr‰epŒeedf6eedf6eedf6eedf6eed f6e ed!f6e!ed"f6e"ed#f6e#ed$f6e$ed%f6e%ed&f6eed'f6eed(f6Z'dS(+sń 4XPath-specific Extension functions WWW: http://4suite.org/XSLT e-mail: support@4suite.org Copyright (c) 2000-2001 Fourthought Inc, USA. All Rights Reserved. See http://4suite.org/COPYRIGHT for license and copyright information i˙˙˙˙N(tNodetEMPTY_NAMESPACE(tText(tboolean(t CoreFunctionst ConversionstFT_EXT_NAMESPACEtFT_OLD_EXT_NAMESPACEcCs'yddlm}|SWndSXdS(Ni˙˙˙˙(t __version__s0.11.1(t Ft.__init__R(tcontextR((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pytVersions cCs\t|ƒtgƒkr|St|dƒrO|jtjkrOt|jƒ}n |g}|S(s,Convert a result-tree fragment to a node-settnodeType(ttypethasattrR Rt DOCUMENT_NODEtlistt childNodes(R trtftnode_set((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pytNodeSets ! cCsI|s|j}ntj|ƒ}tj||ƒr<tjpBtj}|S(s2Do a regular expression match against the argument(tnodeRt StringValuetretmatchRttruetfalse(R tpatterntargtbool((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pytMatch's  $cCsR|s|j}ntj|ƒ}tj|ƒ}tj|ƒ}tj|||ƒS(s5Do a global search and replace of the string contents(RRRtstringtreplace(R toldtnewR((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pytReplace0s  c Cs0|s|j}ntj|ƒ}tj||ƒ}|j}g}xç|D]ß}|jƒ|jdjdt ƒt |ƒt dƒkr”|f}nxM|D]E}|jdjdt ƒ|jdj |ƒ|jdj dƒq›W|jdj dƒ|j ƒ}|jj|ƒ|j|jdƒqIW|S(sJDo a regular expression search against the argument (i.e. get all matches)i˙˙˙˙RtGroupi((RRRRtfindallt processort pushResulttwriterst startElementRR ttextt endElementt popResulttrtfstappendR( R RRtmatchestproctmatches_nodesettgroupstgrouptfrag((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pytSearchRe;s(       c CsY|s|j}ntj|ƒ}|j}g}tj|ƒ}|j|ƒ}x|rT|jƒ|jdj dt ƒ|j ƒ}|sŸt |j ƒƒ}nxS|D]K}|jdj dt ƒ|jdj|pŮdƒ|jdjdƒqŚW|jdjdƒ|jƒ} |jj| ƒ|j| jdƒ|j||jƒƒ}qQW|S(sJDo a regular expression search against the argument (i.e. get all matches)i˙˙˙˙RR$ti(RRRR&RtcompiletsearchR'R(R)RR2ttupleR3R*R+R,R-R.Rtend( R RRR0R1t_ret_matcht_groupsR3R4((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pyt SearchRePy20Vs.       c Gst|d|jƒ\}}tjtƒp<tjjtdƒ}|sXtd|ƒ‚ntgt |ƒ}d„}t t ||f|ƒ}|j } g} xe|D]]} | j ƒ| jdjtj| ƒƒ| jƒ} |jj| ƒ| j| jdƒqŁW| S(sÍ Apply the function serially over the given node sets. In iteration i, the function is passed N parameters where N is the number of argument node sets. Each parameter is a node set of size 1, whose node is the ith node of the corresponding argument node set. The return value is a node set consisting of a series of result-tree nodes, each of which is a text node whose value is the string value of the result of the ith function invocation. Warning: this function uses the implied ordering of the node set Based on its implementation as a Python list. But in reality There is no reliable ordering of XPath node sets. In other words, this function is voodoo. t namespacess*Dynamically invoked function %s not found.cWs t||ƒS(N(tapply(txtftargs((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pytŠsi˙˙˙˙iN(t ExpandQNamet processorNsstg_extFunctionstgettexpandedRtNonet ExceptionRBtlenR@tmapR&R'R(R*RRR,R-R.R( R tfuncnametnodesetstprefixtlocaltfunctflisttlftretlistR0tresult_nodesettretR4((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pytMapts"     cCstjtj|ƒƒS(s"Escape illegal characters in a URL(turllibtquoteRR(R turl((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pyt EscapeUrl˜scCsU|s|jg}nt|ddƒr3|djSt|ddƒrQ|djSdS(s Get the base URI of the argumentitbaseUritrefUriR6(RRR]R^(R R((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pytBaseUris  cCs(ddl}|jƒ}|jj|ƒS(Ni˙˙˙˙(tDateTimetnowtISOtstr(R R`td((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pytIsoTime¨s  cCs+ddl}|jjtjtƒd|ƒS(Ni˙˙˙˙R (t xml.xpathtxpathtEvaluateRRtst(R texprtxml((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pyRhŽs cCs#ddlm}|j|jƒƒS(Ni˙˙˙˙(tUuid(tFt.LibRlt UuidAsStringt GenerateUuid(R Rl((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pyRośscCs[t|ƒtgƒkr'tdƒ‚ni}x!|D]}||tj|ƒRXR\R_ReRhtFt.Lib.DumpBgTupletFtRoRsRuR|R‚R‡Rˆt hexversiont ExtFunctions(((sO/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/BuiltInExtFunctions.pyt sx0"    $           "                "