跳到内容

XQuery/数据流图

来自维基教科书,面向开放世界的开放书籍

对 Timetable 应用程序(另一个页面抓取应用程序)中的数据流的这段描述大致基于 XPL

<?xml version="1.0" encoding="UTF-8"?>
<Pipeline id="timetable">
        <process id="i1">
            <title>Input id</title>
        </process>
        <process id="i2">
            <title>input week number</title>
        </process>
        <process id="i3">
            <title>input role</title>
        </process>
        <process id="s1">
            <title>create url</title>
            <input>i1</input>
            <input>i2</input>
            <input>i3</input>
        </process>
         <process id="s2">
            <title>get html</title>
            <input>s1</input>
            <input>x1</input>
        </process>
        <process id="x1">
            <type>external</type>
            <input>s2</input>
            <title>Syllabus Plus</title>
        </process>
        <process id="s3">
            <title>convert to xhtml</title>
            <input>s2</input>
        </process>
        <process id="s4">
            <title>extract xml</title>
            <input>s3</input>
        </process>     
        <process id="s5">
            <title>transform to vcal</title>
            <input>s4</input>
        </process>
        <process id="s6">
            <title>transform to htm</title>
            <input>s4</input>
        </process>
  </Pipeline>

类型到形状的映射

<ProcessTypes>
    <type name="input" shape="invtriangle"/>
    <type name="process" shape="box"/>
    <type name="external" shape="house"/>
</ProcessTypes>


转换为点格式,以便继续转换为 GIF 图像

declare option exist:serialize "method=text";
declare variable $nl := "
";
declare variable $url := request:get-parameter("url","/db/Wiki/DataFlow/timetablexpl.xml");
declare variable $processTypes := /ProcessTypes;
let $pipe  := doc($url)

return   (
  "digraph {" ,
   for $process in $pipe//process 
   let $type := 
        if (exists($process/type))
        then $process/type
        else if (empty($process/input))
        then "input"
        else "process"
    let $shape :=  string($processTypes/type[@name=$type]/@shape)
     return 
      ( concat ($process/@id, ' [shape=',$shape,',label="',$process/title, '"];',$nl),
         for $input in $process/input
        return 
           concat($input, '->', $process/@id,";",$nl)
      ),
   "} ",$nl
)

点文件

华夏公益教科书