author | Shabe Razvi <shaber@symbian.org> |
Mon, 21 Jun 2010 17:52:23 +0100 | |
changeset 1108 | 86b0bbaa517c |
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" 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
|
3 |
<xsl:output method="xml" indent="yes"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
4 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
5 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
6 |
<!-- filters can only return hide or show --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
7 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
8 |
<!-- filter-only = item's @filter can only have items from the list |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
9 |
anything with no filters passes |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
10 |
--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
11 |
<xsl:template match="filter-only" mode="filter"><xsl:param name="item"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
12 |
<xsl:if test="$item[@filter]"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
13 |
<xsl:variable name="this" select="."/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
14 |
<xsl:variable name="my-filters"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
15 |
<xsl:call-template name="filter-list"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
16 |
<xsl:with-param name="f" select="$item/parent::component/@filter"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
17 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
18 |
<xsl:call-template name="filter-list"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
19 |
<xsl:with-param name="f" select="$item/@filter"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
20 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
21 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
22 |
<xsl:variable name="match"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
23 |
<xsl:for-each select="exslt:node-set($my-filters)/*"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
24 |
<xsl:if test="not($this/*[name()=name(current()) and @v=current()/@v])">x</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
25 |
</xsl:for-each> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
26 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
27 |
<xsl:if test="$match!=''">hide</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
28 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
29 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
30 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
31 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
32 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
33 |
<!-- filter-has = item's @filter must have all filters in the list. ie it can have any other filters, but these must all be present |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
34 |
--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
35 |
<xsl:template match="filter-has" mode="filter"><xsl:param name="item"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
36 |
<xsl:if test="$item[(self::component or self::unit) and not(unit/@filter or self::unit[not(../unit[@filter])])]"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
37 |
<xsl:variable name="my-filters"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
38 |
<xsl:call-template name="filter-list"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
39 |
<xsl:with-param name="f" select="$item/parent::component/@filter"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
40 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
41 |
<xsl:call-template name="filter-list"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
42 |
<xsl:with-param name="f" select="$item/@filter"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
43 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
44 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
45 |
<xsl:variable name="match"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
46 |
<xsl:for-each select="*"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
47 |
<!-- if(f in this) {return true} else if(!f in this) {return false} else {return !(f is positive)} --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
48 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
49 |
<xsl:when test="exslt:node-set($my-filters)/*[name()=name(current()) and @v=current()/@v]"/> <!-- filter in item --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
50 |
<xsl:when test="exslt:node-set($my-filters)/*[name()!=name(current()) and @v=current()/@v]">x</xsl:when> <!-- !filter in item --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
51 |
<xsl:when test="self::filter">x</xsl:when> <!-- !(filter is positive) --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
52 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
53 |
</xsl:for-each> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
54 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
55 |
<xsl:if test="$match!=''">hide</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
56 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
57 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
58 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
59 |
<xsl:template match="filter-with" mode="filter"><xsl:param name="item"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
60 |
<xsl:if test="$item[(self::component or self::unit) and not(unit/@filter or self::unit[not(../unit[@filter])])]"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
61 |
<xsl:variable name="my-filters"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
62 |
<xsl:call-template name="filter-list"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
63 |
<xsl:with-param name="f" select="$item/parent::component/@filter"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
64 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
65 |
<xsl:call-template name="filter-list"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
66 |
<xsl:with-param name="f" select="$item/@filter"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
67 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
68 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
69 |
<xsl:variable name="match"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
70 |
<xsl:for-each select="*"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
71 |
<xsl:if test="exslt:node-set($my-filters)/*[name()!=name(current()) and @v=current()/@v]">x</xsl:if> <!-- !filter in item --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
72 |
</xsl:for-each> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
73 |
</xsl:variable> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
74 |
<xsl:if test="$match!=''">hide</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
75 |
</xsl:if> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
76 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
77 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
78 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
79 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
80 |
<xsl:template name="filter-item"> <xsl:param name="f"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
81 |
<!-- create an element for a given filter. If the filter's empty make nothing --> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
82 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
83 |
<xsl:when test="$f=''"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
84 |
<xsl:when test="starts-with($f,'!')"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
85 |
<not v="{substring($f,2)}"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
86 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
87 |
<xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
88 |
<filter v="{$f}"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
89 |
</xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
90 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
91 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
92 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
93 |
<xsl:template name="filter-list"><xsl:param name="f"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
94 |
<!-- turn a filter list into a set of elements (<filter> or <not>) with the attribute "v" containing the "absolute value" of the filter |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
95 |
filter="A,B,!C" becomes <filter v="A"/><filter v="B"/><not v="C"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
96 |
--> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
97 |
<xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
98 |
<xsl:when test="contains($f,',')"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
99 |
<xsl:call-template name="filter-item"><xsl:with-param name="f" select="normalize-space(substring-before($f,','))"/></xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
100 |
<xsl:call-template name="filter-list"> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
101 |
<xsl:with-param name="f" select="substring-after($f,',')"/> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
102 |
</xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
103 |
</xsl:when> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
104 |
<xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
105 |
<xsl:call-template name="filter-item"><xsl:with-param name="f" select="normalize-space($f)"/></xsl:call-template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
106 |
</xsl:otherwise> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
107 |
</xsl:choose> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
108 |
</xsl:template> |
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
109 |
|
41f42b520ea7
add xsl for merging / downgrading system model
andy simpson <andrews@symbian.org>
parents:
diff
changeset
|
110 |
</xsl:stylesheet> |