From: SourceForge.net <no...@so...> - 2008-11-12 11:14:54
|
Bugs item #2268892, was opened at 2008-11-12 11:14 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=117691&aid=2268892&group_id=17691 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Cefn Hoile (cefn) Assigned to: Nobody/Anonymous (nobody) Summary: Namespace error arising from incomplete QName information Initial Comment: Invoking an element constructor in a different module seems to require that the namespaces of the passed elements must be declared in the receiving module. The first function shown below is declared in form.xqm, and invokes the second function defined in type.xqm. It seems as if the name information passed in the element is not a fully qualified QName, requiring there to be a matching declaration in the invoked module. I believe this is a violation of argument containment. The problematic line is where an element is attempted to be constructed using an introspected QName from the passed element. This QName information is not complete. Initially I faced the error... XPST0081: No namespace defined for prefix f [at line 292, column 5] In call to function: t:copywithattribute(element(), xs:string, xdt:anyAtomicType?) [292:5] f:linktoattributename(xs:string, element()) [208:21] f:validateentity(node(), element()) [243:9] f:handlerequest(node()) [11:20] ...which was fixed by adding the explicit declaration mapping the namespace short name f: to the file type.xqm... declare namespace f="http://rules.labs.bt.com/form"; ...despite the fact that the short name f: is not actually referenced directly anywhere in type.xqm. Here are the functions in form.xqm and type.xqm respectively. (: Returns a modified element with a link to a named sibling attribute :) declare function f:linktoattributename($toname as xs:string, $from as element()){ t:copywithattribute($from, 'attributeref', $toname) }; (: Copy the specified element, inserting, overwriting or removing the specified attribute :) declare function t:copywithattribute($element as element(), $attname as xs:string, $attvalue as xs:anyAtomicType?){ element {name($element)} { if($attvalue) then attribute {$attname} {$attvalue} else (), $element/@*[not(local-name(.) eq $attname)], $element/(*|text()) } }; ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=117691&aid=2268892&group_id=17691 |