author | Maciej Seroka <maciejs@symbian.org> |
Wed, 16 Jun 2010 13:25:59 +0100 | |
changeset 1096 | 7e7420e7272c |
parent 852 | 41f42b520ea7 |
permissions | -rw-r--r-- |
852
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
1 |
<?xml version="1.0"?> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
2 |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
3 |
xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="exslt"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
4 |
<!-- save SF namespace as a constant to avoid the risk of typos--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
5 |
<xsl:variable name="defaultns">http://www.symbian.org/system-definition</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
6 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
7 |
<!-- create a stand-alone sysdef from a linked set of fragments --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
8 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
9 |
<xsl:template match="/*" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
10 |
<xsl:message terminate="yes">Cannot process this document</xsl:message> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
11 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
12 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
13 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
14 |
<xsl:template match="/SystemDefinition[@schema='3.0.0' and count(*)=1]" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
15 |
<xsl:param name="origin" select="/.."/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
16 |
<xsl:param name="root"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
17 |
<xsl:param name="filename"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
18 |
<xsl:param name="namespaces"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
19 |
<xsl:param name="data" select="/.."/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
20 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
21 |
<xsl:when test="$origin"> <!-- this sysdef fragment was linked from a parent sysdef --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
22 |
<xsl:for-each select="*"> <!-- can be only one --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
23 |
<xsl:variable name="upid"><xsl:apply-templates select="$origin/@id" mode="my-id"/></xsl:variable> <!-- namespaceless ID of this in parent doc --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
24 |
<xsl:variable name="id"><xsl:apply-templates select="@id" mode="my-id"/></xsl:variable> <!-- namespaceless ID of this here --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
25 |
<xsl:variable name="upns"><xsl:apply-templates select="$origin/@id" mode="my-namespace"/></xsl:variable> <!-- ID's namespace in parent doc --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
26 |
<xsl:variable name="ns"><xsl:apply-templates select="@id" mode="my-namespace"/></xsl:variable> <!-- ID's namespace --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
27 |
<xsl:if test="$id!=$upid or $ns!=$upns"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
28 |
<xsl:message terminate="yes">Linked ID "<xsl:value-of select="$id"/>" (<xsl:value-of select="$ns"/>) must match linking document "<xsl:value-of select="$upid"/>" (<xsl:value-of select="$upns"/>)</xsl:message> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
29 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
30 |
<!-- copy any attributes not already defined (parent doc overrides child doc)--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
31 |
<xsl:for-each select="@*"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
32 |
<xsl:variable name="n" select="name()"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
33 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
34 |
<xsl:when test="$n='id'"/> <!-- never copy this, always set --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
35 |
<xsl:when test="$origin/@*[name()=$n]"> <!-- don't copy if already set --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
36 |
<xsl:message>Cannot set "<xsl:value-of select="$n"/>", already set</xsl:message> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
37 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
38 |
<xsl:when test="$n='before'"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
39 |
<!-- ensure ns is correct (if any future attribtues will ever use an ID, process it here too)--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
40 |
<xsl:apply-templates select="." mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
41 |
<xsl:with-param name="namespaces" select="$namespaces"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
42 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
43 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
44 |
<xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- just copy anything else --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
45 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
46 |
</xsl:for-each> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
47 |
<xsl:copy-of select="../namespace::*[not(.=$namespaces)]"/> <!-- set any namespaces not already set (they should all alreayd be, but some XSLT processors are quirky) --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
48 |
<xsl:apply-templates select="$data" mode="overlay-attributes"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
49 |
<xsl:with-param name="item" select="current()"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
50 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
51 |
<xsl:variable name="content"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
52 |
<xsl:apply-templates select="*|comment()" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
53 |
<xsl:with-param name="root" select="$root"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
54 |
<xsl:with-param name="filename" select="$filename"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
55 |
<xsl:with-param name="data" select="$data"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
56 |
<xsl:with-param name="namespaces" select="$namespaces | ../namespace::*[not(.=$namespaces)]"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
57 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
58 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
59 |
<xsl:apply-templates select="." mode="is-content-filtered"> <!-- optionally add filtered="yes" if some content has been removed --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
60 |
<xsl:with-param name="content" select="$content"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
61 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
62 |
<xsl:apply-templates select="$data" mode="overlay-meta"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
63 |
<xsl:with-param name="item" select="current()"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
64 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
65 |
<xsl:copy-of select="$content"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
66 |
</xsl:for-each> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
67 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
68 |
<xsl:when test="function-available('exslt:node-set')"> <!-- this is the root element of a root sysdef --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
69 |
<!--try to put all namespaces in root element --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
70 |
<xsl:variable name="nss"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
71 |
<!-- contains node set of namespaces to add to root element. |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
72 |
May panic if there are too many single-letter namespaces and this can't create a new one --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
73 |
<xsl:call-template name="needed-namespaces"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
74 |
<xsl:with-param name="foundns"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
75 |
<xsl:apply-templates select="//*[(self::component or self::collection or self::package or self::layer) and @href]" mode="scan-for-namespaces"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
76 |
</xsl:with-param> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
77 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
78 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
79 |
<xsl:variable name="ns" select="@id-namespace | namespace::* | exslt:node-set($nss)/*"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
80 |
<xsl:copy><xsl:copy-of select="@*"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
81 |
<xsl:apply-templates select="self::*[not(@id-namespace)]" mode="add-id-ns"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
82 |
<xsl:for-each select="exslt:node-set($nss)/*"> <!-- add namespace definitions --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
83 |
<xsl:attribute name="xmlns:{name()}"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
84 |
<xsl:value-of select="."/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
85 |
</xsl:attribute> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
86 |
</xsl:for-each> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
87 |
<!-- no need to call is-content-filtered, it never will be from this element --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
88 |
<xsl:apply-templates select="*|comment()" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
89 |
<xsl:with-param name="namespaces" select="$ns"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
90 |
<xsl:with-param name="root" select="$root"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
91 |
<xsl:with-param name="data" select="$data"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
92 |
<xsl:with-param name="filename" select="$filename"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
93 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
94 |
</xsl:copy> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
95 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
96 |
<xsl:otherwise> <!-- can't handle node-set() so put the namespaces in the document instead of the root element--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
97 |
<xsl:variable name="ns" select="@id-namespace | namespace::*"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
98 |
<xsl:copy><xsl:copy-of select="@*"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
99 |
<!-- no need to call is-content-filtered, it never will be from this element --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
100 |
<xsl:apply-templates select="*|comment()" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
101 |
<xsl:with-param name="namespaces" select="$ns"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
102 |
<xsl:with-param name="root" select="$root"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
103 |
<xsl:with-param name="data" select="$data"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
104 |
<xsl:with-param name="filename" select="$filename"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
105 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
106 |
</xsl:copy> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
107 |
</xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
108 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
109 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
110 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
111 |
<xsl:template match="*" mode="scan-for-namespaces"/> <!-- just in case of errors, consider replacing by terminate --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
112 |
<xsl:template match="*[@href and not(self::meta)]" mode="scan-for-namespaces"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
113 |
<!-- produce a list of namespace-prefix namespace pairs separated by newlines, in reverse order found in documents |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
114 |
reverse order so we can try to use the first namespace prefix defined if it's available--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
115 |
<xsl:for-each select="document(@href,.)/*"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
116 |
<xsl:apply-templates select="//*[(self::component or self::collection or self::package or self::layer) and @href]" mode="scan-for-namespaces"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
117 |
<xsl:for-each select="//namespace::* | @id-namespace"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
118 |
<xsl:value-of select="concat(name(),' ',.,'
')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
119 |
</xsl:for-each> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
120 |
</xsl:for-each> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
121 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
122 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
123 |
<xsl:template name="needed-namespaces"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
124 |
<xsl:param name="foundns"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
125 |
<xsl:param name="usedpre"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
126 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
127 |
<xsl:if test="foundns!=''"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
128 |
<xsl:variable name="line" select="substring-before($foundns,'
')"/> <!-- always has trailing newline --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
129 |
<xsl:variable name="name" select="substring-after($line,' ')"/> <!-- namespace prefix --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
130 |
<xsl:variable name="remainder" select="substring-after($foundns,'
')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
131 |
<xsl:variable name="newprefix"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
132 |
<xsl:if test="not(contains(concat('
',$remainder),concat('
',$line,'
'))) and |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
133 |
not(//namespace::*[.=$name] or @id-namespace[.=$name] or (not(@id-namespace) and $defaultns=$name))"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
134 |
<xsl:apply-templates select="." mode="ns-prefix"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
135 |
<xsl:with-param name="ns" select="$name"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
136 |
<xsl:with-param name="pre" select="substring-before($line,' ')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
137 |
<xsl:with-param name="dontuse" select="$usedpre"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
138 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
139 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
140 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
141 |
<xsl:if test="$newprefix!=''"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
142 |
<!-- can treat this as if it were a namespace node --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
143 |
<xsl:element name="{$newprefix}"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
144 |
<xsl:value-of select="$name"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
145 |
</xsl:element> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
146 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
147 |
<xsl:if test="$remainder!=''"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
148 |
<xsl:call-template name="needed-namespaces"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
149 |
<xsl:with-param name="foundns" select="$remainder"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
150 |
<xsl:with-param name="usedpre" select="concat($usedpre,' ',$newprefix,' ')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
151 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
152 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
153 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
154 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
155 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
156 |
<xsl:template match="/SystemDefinition" mode="ns-prefix"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
157 |
<!-- should be able to replace this with mechanism that uses the XSLT processor's own ability to generate namespaces --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
158 |
<xsl:param name="ns"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
159 |
<xsl:param name="pre"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
160 |
<xsl:param name="dontuse"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
161 |
<xsl:param name="chars">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</xsl:param> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
162 |
<xsl:variable name="name" select="substring(substring-after($ns,'http://www.'),1,1)"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
163 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
164 |
<xsl:when test="$pre!='' and $pre!='id-namespace' and not(//namespace::*[name()=$pre]) and not(contains($dontuse,concat(' ',$pre,' ')))"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
165 |
<xsl:value-of select="$pre"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
166 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
167 |
<xsl:when test="$ns='' and $chars=''"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
168 |
<xsl:message terminate="yes">Cannot create namespace prefix for downstream default namespace</xsl:message> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
169 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
170 |
<xsl:when test="$name!='' and not(contains($dontuse,concat(' ',$name,' ')))"><xsl:value-of select="$name"/></xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
171 |
<xsl:when test="namespace::*[name()=substring($chars,1,1)] or contains($dontuse,concat(' ',substring($chars,1,1),' '))"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
172 |
<xsl:apply-templates mode="ns-prefix"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
173 |
<xsl:with-param name="chars" select="substring($chars,2)"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
174 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
175 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
176 |
<xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
177 |
<xsl:value-of select="substring($chars,1,1)"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
178 |
</xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
179 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
180 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
181 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
182 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
183 |
<xsl:template match="unit" mode="join"> <xsl:param name="root"/><xsl:param name="filename"/><xsl:param name="data"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
184 |
<xsl:variable name="display"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
185 |
<xsl:apply-templates select="$data" mode="filter"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
186 |
<xsl:with-param name="item" select="current()"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
187 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
188 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
189 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
190 |
<xsl:if test="$display != 'hide' "> <!-- if hide, remove completely from the output--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
191 |
<xsl:element name="{name()}"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
192 |
<xsl:apply-templates select="@*" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
193 |
<xsl:with-param name="root" select="$root"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
194 |
<xsl:with-param name="filename" select="$filename"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
195 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
196 |
</xsl:element> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
197 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
198 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
199 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
200 |
<!-- override mode="meta" to translate metadata sections. By default, include --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
201 |
<xsl:template match="meta" priority="2"><xsl:param name="data"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
202 |
<xsl:variable name="display"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
203 |
<xsl:apply-templates select="$data" mode="filter"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
204 |
<xsl:with-param name="item" select="current()"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
205 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
206 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
207 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
208 |
<xsl:if test="$display != 'hide' "> <!-- if hide, remove completely from the output--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
209 |
<xsl:apply-templates select="." mode="meta"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
210 |
<xsl:with-param name="display" select="$display"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
211 |
<xsl:with-param name="data" select="$data"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
212 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
213 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
214 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
215 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
216 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
217 |
<xsl:template match="*" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
218 |
<xsl:param name="root"/><xsl:param name="filename"/><xsl:param name="namespaces"/><xsl:param name="data"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
219 |
<!-- get attribtues from overlay --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
220 |
<!-- test for presence, if filtered out, just return --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
221 |
<!-- test for children, if it has some, but they're filtered out, either return or leave as empty, dependening on filter rule |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
222 |
if had items and now has none, options: |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
223 |
still has meta: keep / delete |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
224 |
still has comments: keep / delete |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
225 |
--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
226 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
227 |
<xsl:variable name="display"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
228 |
<xsl:apply-templates select="$data" mode="filter"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
229 |
<xsl:with-param name="item" select="current()"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
230 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
231 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
232 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
233 |
<xsl:if test="$display != 'hide' "> <!-- if hide, remove completely from the output--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
234 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
235 |
<xsl:variable name="href"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
236 |
<xsl:apply-templates select="." mode="link"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
237 |
<xsl:with-param name="data" select="$data"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
238 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
239 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
240 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
241 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
242 |
<xsl:element name="{name()}"> <!-- use this instead of <copy> so xalan doesn't add extra wrong namespaces --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
243 |
<xsl:apply-templates select="@*" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
244 |
<xsl:with-param name="namespaces" select="$namespaces"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
245 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
246 |
<xsl:if test="$display != '' "> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
247 |
<!-- custom attribute to indicate how this is to be represented. Blank indicates normal, hide removes from the output (see above), anything else is put in the attribute --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
248 |
<xsl:attribute name="display"><xsl:value-of select="$display"/></xsl:attribute> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
249 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
250 |
<xsl:apply-templates select="$data" mode="overlay-attributes"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
251 |
<xsl:with-param name="item" select="current()"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
252 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
253 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
254 |
<xsl:when test="$href !='' "> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
255 |
<xsl:variable name="origin" select="."/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
256 |
<xsl:apply-templates select="document($href,.)/*" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
257 |
<xsl:with-param name="origin" select="$origin"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
258 |
<xsl:with-param name="data" select="$data"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
259 |
<xsl:with-param name="namespaces" select="$namespaces"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
260 |
<xsl:with-param name="filename"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
261 |
<xsl:call-template name="joinpath"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
262 |
<xsl:with-param name="file" select="$filename"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
263 |
<xsl:with-param name="rel" select="$href"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
264 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
265 |
</xsl:with-param> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
266 |
<xsl:with-param name="root"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
267 |
<xsl:value-of select="$root"/>/<xsl:call-template name="lastbefore"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
268 |
<xsl:with-param name="string" select="$href"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
269 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
270 |
</xsl:with-param> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
271 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
272 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
273 |
<xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
274 |
<xsl:variable name="content"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
275 |
<xsl:apply-templates select="*|comment()" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
276 |
<xsl:with-param name="root" select="$root"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
277 |
<xsl:with-param name="filename" select="$filename"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
278 |
<xsl:with-param name="namespaces" select="$namespaces"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
279 |
<xsl:with-param name="data" select="$data"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
280 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
281 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
282 |
<xsl:apply-templates select="." mode="is-content-filtered"> <!-- add filtered="yes" if some content has been removed --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
283 |
<xsl:with-param name="content" select="$content"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
284 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
285 |
<xsl:apply-templates select="$data" mode="overlay-meta"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
286 |
<xsl:with-param name="item" select="current()"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
287 |
</xsl:apply-templates> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
288 |
<xsl:copy-of select="$content"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
289 |
</xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
290 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
291 |
</xsl:element> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
292 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
293 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
294 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
295 |
<!-- By default, do nothing. Can override template to add filtered="yes" if need to track what's a placeholder and what's been filtered |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
296 |
implement with param name="content" |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
297 |
--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
298 |
<xsl:template mode="is-content-filtered" match="*" priority="-2"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
299 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
300 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
301 |
<xsl:template match="@mrp[starts-with(.,'/')] | @bldFile[starts-with(.,'/')] | @base[starts-with(.,'/')]" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
302 |
<xsl:copy-of select="."/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
303 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
304 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
305 |
<xsl:template match="@mrp|@bldFile|@base" mode="join"> <xsl:param name="root"/><xsl:param name="filename"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
306 |
<xsl:attribute name="{name()}"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
307 |
<xsl:call-template name="joinpath"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
308 |
<xsl:with-param name="file" select="$filename"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
309 |
<xsl:with-param name="rel" select="."/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
310 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
311 |
</xsl:attribute> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
312 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
313 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
314 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
315 |
<xsl:template match="@href" mode="join"/> <!--never copy this into the generated doc, that's the whole point of this module --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
316 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
317 |
<xsl:template match="@*" mode="my-namespace"> <!-- the namespace of an ID --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
318 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
319 |
<xsl:when test="contains(.,':')"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
320 |
<xsl:value-of select="ancestor::*/namespace::*[name()=substring-before(current(),':')]"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
321 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
322 |
<xsl:when test="/SystemDefinition/@id-namespace"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
323 |
<xsl:value-of select="/SystemDefinition/@id-namespace"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
324 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
325 |
<xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
326 |
<xsl:value-of select="$defaultns"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
327 |
</xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
328 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
329 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
330 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
331 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
332 |
<xsl:template match="@*" mode="my-id"> <!-- the ID with namespace prefix removed --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
333 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
334 |
<xsl:when test="contains(.,':')"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
335 |
<xsl:value-of select="substring-after(.,':')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
336 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
337 |
<xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
338 |
<xsl:value-of select="."/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
339 |
</xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
340 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
341 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
342 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
343 |
<xsl:template match="@id|@before" mode="join"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
344 |
<xsl:param name="namespaces"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
345 |
<!-- this will change the namespace prefixes for all IDs to match the root document --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
346 |
<xsl:variable name="ns"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
347 |
<xsl:apply-templates select="." mode="my-namespace"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
348 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
349 |
<xsl:if test="$ns=''"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
350 |
<xsl:message terminate="yes">Could not find namespace for <xsl:value-of select="."/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
351 |
</xsl:message> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
352 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
353 |
<xsl:variable name="prefix" select="name($namespaces[.=$ns])"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
354 |
<xsl:attribute name="{name()}"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
355 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
356 |
<xsl:when test="$prefix = 'id-namespace' or (not($namespaces[name()='id-prefix']) and $ns=$defaultns)"/> <!-- it's the default namespace, no prefix --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
357 |
<xsl:when test="$prefix='' and contains(.,':')"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
358 |
<!-- complex: copy id and copy namespace (namespace should be copied already)--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
359 |
<xsl:value-of select="."/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
360 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
361 |
<xsl:when test="$prefix='' and $ns=$defaultns"/> <!-- no prefix and it's the default --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
362 |
<xsl:when test="$prefix!=''"> <!-- just change the prefix --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
363 |
<xsl:value-of select="concat($prefix,':')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
364 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
365 |
<xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
366 |
<xsl:message terminate="yes">Error</xsl:message> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
367 |
</xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
368 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
369 |
<xsl:apply-templates select="." mode="my-id"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
370 |
</xsl:attribute> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
371 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
372 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
373 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
374 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
375 |
<xsl:template match="@*|comment()" mode="join"><xsl:copy-of select="."/></xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
376 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
377 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
378 |
<!-- path handling follows --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
379 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
380 |
<xsl:template name="lastbefore"><xsl:param name="string"/><xsl:param name="substr" select="'/'"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
381 |
<xsl:if test="contains($string,$substr)"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
382 |
<xsl:value-of select="substring-before($string,$substr)"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
383 |
<xsl:if test="contains(substring-after($string,$substr),$substr)"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
384 |
<xsl:value-of select="$substr"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
385 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
386 |
<xsl:call-template name="lastbefore"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
387 |
<xsl:with-param name="string" select="substring-after($string,$substr)"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
388 |
<xsl:with-param name="substr" select="$substr"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
389 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
390 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
391 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
392 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
393 |
<xsl:template name="joinpath"><xsl:param name="file"/><xsl:param name="rel"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
394 |
<xsl:call-template name="reducepath"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
395 |
<xsl:with-param name="file"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
396 |
<xsl:call-template name="lastbefore"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
397 |
<xsl:with-param name="string" select="$file"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
398 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
399 |
<xsl:text>/</xsl:text> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
400 |
<xsl:value-of select="$rel"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
401 |
</xsl:with-param> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
402 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
403 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
404 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
405 |
<xsl:template name="reducepath"><xsl:param name="file"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
406 |
<xsl:call-template name="reducedotdotpath"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
407 |
<xsl:with-param name="file"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
408 |
<xsl:call-template name="reducedotpath"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
409 |
<xsl:with-param name="file" select="$file"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
410 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
411 |
</xsl:with-param> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
412 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
413 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
414 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
415 |
<xsl:template name="reducedotdotpath"><xsl:param name="file"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
416 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
417 |
<xsl:when test="starts-with($file,'../')"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
418 |
<xsl:text>../</xsl:text> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
419 |
<xsl:call-template name="reducedotdotpath"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
420 |
<xsl:with-param name="file" select="substring($file,4)"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
421 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
422 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
423 |
<xsl:when test="contains($file,'/../')"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
424 |
<xsl:call-template name="reducepath"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
425 |
<xsl:with-param name="file"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
426 |
<xsl:call-template name="lastbefore"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
427 |
<xsl:with-param name="string" select="substring-before($file,'/../')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
428 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
429 |
<xsl:text>/</xsl:text> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
430 |
<xsl:value-of select="substring-after($file,'/../')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
431 |
</xsl:with-param> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
432 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
433 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
434 |
<xsl:otherwise><xsl:value-of select="$file"/></xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
435 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
436 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
437 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
438 |
<xsl:template name="reducedotpath"><xsl:param name="file"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
439 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
440 |
<xsl:when test="starts-with($file,'./')"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
441 |
<xsl:call-template name="reducedotpath"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
442 |
<xsl:with-param name="file" select="substring($file,3)"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
443 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
444 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
445 |
<xsl:when test="contains($file,'/./')"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
446 |
<xsl:call-template name="reducepath"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
447 |
<xsl:with-param name="file"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
448 |
<xsl:value-of select="substring-before($file,'/./')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
449 |
<xsl:text>/</xsl:text> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
450 |
<xsl:value-of select="substring-after($file,'/./')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
451 |
</xsl:with-param> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
452 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
453 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
454 |
<xsl:otherwise><xsl:value-of select="$file"/></xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
455 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
456 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
457 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
458 |
<!-- overridable templates follow --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
459 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
460 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
461 |
<xsl:template match="*" mode="filter" priority="-9"/> <!-- by default show --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
462 |
<xsl:template match="*" mode="overlay-attributes" priority="-9"/> <!-- by default do nothing --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
463 |
<xsl:template match="*" mode="overlay-meta" priority="-9"/> <!-- by default do nothing --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
464 |
<xsl:template match="/SystemDefinition" mode="add-id-ns" priority="-9"/> <!-- some tools may have an easier job if this were always present, but, by default, assume it can just stay implied --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
465 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
466 |
<xsl:template match="*" mode="link" priority="-1"> <!-- can be overriden to allow custom changes to href values --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
467 |
<xsl:value-of select="@href"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
468 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
469 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
470 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
471 |
<xsl:template match="*" mode="meta" priority="-9"><xsl:param name="data"/><xsl:param name="display"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
472 |
<xsl:element name="{name()}"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
473 |
<xsl:copy-of select="@*[name()!='href']"/> <!-- copy all attributes as is, always drop href --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
474 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
475 |
<xsl:when test="$display='local' and @href and contains(@href,':') and not(starts-with(@href,'file:'))"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
476 |
<!-- non-local URL: only want local URLs, so keep href as is--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
477 |
<xsl:copy-of select="@href"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
478 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
479 |
<xsl:when test="@href"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
480 |
<xsl:copy-of select="document(@href,.)/*"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
481 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
482 |
<xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
483 |
<xsl:copy-of select="*|comment()"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
484 |
</xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
485 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
486 |
</xsl:element> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
487 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
488 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
489 |
</xsl:stylesheet> |