<s> '''<STR_LIT>''' <EOL> from arelle import XPathContext , XbrlUtil <EOL> from arelle . ModelValue import qname , QName <EOL> from arelle . ModelInstanceObject import ModelDimensionValue , XmlUtil <EOL> from arelle . FunctionUtil import qnameArg , nodeArg , atomicArg <EOL> from arelle import XmlValidate <EOL> from lxml import etree <EOL> '''<STR_LIT>''' <EOL> def xfxc_element ( xc , p , contextItem , args ) : <EOL> if not <NUM_LIT:2> <= len ( args ) <= <NUM_LIT:4> : raise XPathContext . FunctionNumArgs ( ) <EOL> qn = qnameArg ( xc , p , args , <NUM_LIT:0> , '<STR_LIT>' , emptyFallback = None ) <EOL> attrArg = args [ <NUM_LIT:1> ] if isinstance ( args [ <NUM_LIT:1> ] , ( list , tuple ) ) else ( args [ <NUM_LIT:1> ] , ) <EOL> if attrArg : <EOL> if len ( attrArg ) & <NUM_LIT:1> or any ( not isinstance ( attrArg [ i ] , ( QName , _STR_BASE ) ) <EOL> for i in range ( <NUM_LIT:0> , len ( attrArg ) , <NUM_LIT:2> ) ) : <EOL> raise XPathContext . FunctionArgType ( <NUM_LIT:1> , "<STR_LIT>" , errCode = "<STR_LIT>" ) <EOL> else : <EOL> attrParam = [ ( attrArg [ i ] , attrArg [ i + <NUM_LIT:1> ] ) <EOL> for i in range ( <NUM_LIT:0> , len ( attrArg ) , <NUM_LIT:2> ) ] <EOL> else : <EOL> attrParam = None <EOL> value = atomicArg ( xc , p , args , <NUM_LIT:2> , "<STR_LIT>" , emptyFallback = '<STR_LIT>' ) <EOL> if not value : <EOL> value = None <EOL> if len ( args ) < <NUM_LIT:4> : <EOL> childElements = None <EOL> else : <EOL> childElements = xc . flattenSequence ( args [ <NUM_LIT:3> ] ) <EOL> scratchpadXmlDocUrl = "<STR_LIT>" <EOL> if scratchpadXmlDocUrl in xc . modelXbrl . urlDocs : <EOL> modelDocument = xc . modelXbrl . urlDocs [ scratchpadXmlDocUrl ] <EOL> else : <EOL> from arelle import ModelDocument <EOL> modelDocument = ModelDocument . create ( xc . modelXbrl , <EOL> ModelDocument . Type . UnknownXML , <EOL> scratchpadXmlDocUrl , <EOL> initialXml = "<STR_LIT>" ) <EOL> newElement = XmlUtil . addChild ( modelDocument . xmlRootElement , <EOL> qn , <EOL> attributes = attrParam , <EOL> text = value ) <EOL> if childElements : <EOL> for element in childElements : <EOL> if isinstance ( element , etree . ElementBase ) : <EOL> newElement . append ( element ) <EOL> XmlValidate . validate ( xc . modelXbrl , newElement ) <EOL> return newElement <EOL> def xfxcFunctions ( ) : <EOL> return { <EOL> qname ( "<STR_LIT>" ) : xfxc_element , <EOL> } <EOL> __pluginInfo__ = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:version>' : '<STR_LIT:1.0>' , <EOL> '<STR_LIT:description>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : xfxcFunctions , <EOL> } </s>
