Up: Package Subgraphs   [Contents][Index]

B.1.1 Graph Lookups

The provided graph lookups are constructors that use symbols to locate a graph. Using partial application, they are convenient for use in graph:dep-lookup#3 to resolve external graphs.

function: element( preproc:sym-deps )? graph:lookup-from-doc (doc-ext as xs:string, rel-node as node(), symbol as element( preproc:sym ))


Look up a graph on a document indicated by a source symbol $symbol/@src. The document will be loaded relative to $rel-node with the file extension $package-ext.

There are no restrictions on the root node of the document, but the preproc:sym-deps node is expected to be a child of the root.

This function does not care if $symbol actually resolves to anything in the destination package—such is up to the caller to decide. If the referenced document contains no graph (preproc:sym-deps), the empty sequence will be returned. If the referenced document does not exist, the result is implementation-defined.

Customarily, $doc-ext is “xmlo” (the compiled object file) and $rel-node is the package from which $symbol was obtained.


<function name="graph:lookup-from-doc"  as="element( preproc:sym-deps )?">
  <param name="doc-ext"  as="xs:string" />
  <param name="rel-node"  as="node()" />
  <param name="symbol"  as="element( preproc:sym )" />

  <variable name="src"  as="xs:string?"  select="$symbol/@src" />

  <sequence select="if ( $src ) then document( concat( $src, '.', $doc-ext ), $rel-node ) /node()/preproc:sym-deps else ()" />