annotate xslt/preprocess.xsl @ 2:035de8b7b18e

Temporary commit, refactoring, added readme
author cin
date Sun, 25 Feb 2018 17:12:33 +0300
parents
children d240adc2ac70
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
1 <?xml version="1.0" encoding="utf-8"?>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
2 <xsl:stylesheet version="1.0"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
4 xmlns:m="http://implab.org/schemas/data-model.v1.xsd"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
5 xmlns:exsl="http://exslt.org/common"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
6 xmlns:t="http://implab.org/schemas/temp"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
7 >
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
8 <!--
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
9 This template provides 'module' variable which is the
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
10 result of processing imports from packages.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
11
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
12 Variable $module is a node set created from the result-tree
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
13 which is the result of applying templates in mode=preprocess
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
14 -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
15 <xsl:output method="xml" indent="yes" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
16 <xsl:variable name="preprocessResult">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
17 <t:module>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
18 <xsl:call-template name="preprocess" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
19 </t:module>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
20 </xsl:variable>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
21 <xsl:variable name="module" select="exsl:node-set($preprocessResult)/t:module"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
22
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
23 <xsl:template name="preprocess">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
24 <xsl:param name="root" select="/" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
25 <xsl:param name="pending" select="$root/m:package/m:import[@href]" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
26 <xsl:param name="seen" select="/.." />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
27 <xsl:param name="file" select="''" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
28 <xsl:param name="primary" select="true()" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
29
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
30 <xsl:if test="not($seen[generate-id() = generate-id($root)])">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
31 <xsl:apply-templates select="$root" mode="preprocess">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
32 <xsl:with-param name="primary" select="$primary" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
33 <xsl:with-param name="file" select="$file" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
34 </xsl:apply-templates>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
35 <xsl:if test="$pending">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
36 <xsl:variable name="doc" select="document($pending[1]/@href)" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
37 <xsl:call-template name="preprocess">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
38 <xsl:with-param name="root" select="$doc" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
39 <xsl:with-param name="file" select="$pending[1]/@href" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
40 <xsl:with-param name="pending"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
41 select="$pending[position() > 1] | $doc/m:package/m:import[@href]" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
42 <xsl:with-param name="seen" select="$root | $seen" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
43 <xsl:with-param name="primary" select="false()" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
44 </xsl:call-template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
45 </xsl:if>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
46 </xsl:if>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
47 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
48
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
49 <xsl:template match="m:package" mode="preprocess">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
50 <xsl:param name="primary" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
51 <xsl:param name="file" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
52 <xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
53 <xsl:copy-of select="@*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
54 <xsl:if test="$primary">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
55 <xsl:attribute name="primary"><xsl:value-of select="$primary" /></xsl:attribute>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
56 </xsl:if>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
57 <xsl:if test="$file">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
58 <xsl:attribute name="file"><xsl:value-of select="$file" /></xsl:attribute>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
59 </xsl:if>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
60 <xsl:apply-templates mode="preprocess">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
61 <xsl:with-param name="primary" select="$primary" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
62 <xsl:with-param name="file" select="$file" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
63 </xsl:apply-templates>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
64 </xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
65 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
66
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
67 <xsl:template match="*|/" mode="preprocess">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
68 <xsl:param name="primary" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
69 <xsl:param name="file" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
70 <xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
71 <xsl:copy-of select="@*" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
72 <xsl:apply-templates mode="preprocess">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
73 <xsl:with-param name="primary" select="$primary" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
74 <xsl:with-param name="file" select="$file" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
75 </xsl:apply-templates>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
76 </xsl:copy>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
77 </xsl:template>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
78 </xsl:stylesheet>