I need to be able to determine if an arbitrary node is or is not a database 
node.

I implemented this function:

declare function util:isDatabaseNode($node as node()) as xs:boolean {
  let $isDbNode as xs:boolean :=
    try {
      let $nodeId as xs:integer? := db:node-id($node)
      (: let $msg := prof:dump(``[[DEBUG]   relpath:isDatabaseNode(): nodeId: 
"`{$nodeId}`"]``) :)
      return exists($nodeId)
    } catch * {
      (: let $msg := prof:dump(``[[DEBUG]   relpath:isDatabaseNode(): Got 
exception `{$err:code}` - `{$err:description}`]``) :)
      (: return :) false()
    }
  let $msg := prof:dump(``[[DEBUG]   relpath:isDatabaseNode(): Returning 
`{$isDbNode}``]``)
  return $isDbNode
};

With the prof:dump() calls commented out as shown here, it always returns true, 
even when it returned false.

If I comment in the prof:dumps then I get the expected correct false result.

This must be the result some optimization at compile time but I haven’t been 
able to find a construction of this function that works without the debug 
messages.

Is there a better way to determine if a node is a database node?

This is with 10.6.

Cheers,

E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | 
Twitter<https://twitter.com/servicenow> | 
YouTube<https://www.youtube.com/user/servicenowinc> | 
Facebook<https://www.facebook.com/servicenow>

Reply via email to