1 <?xml version="1.0"?> |
1 <?xml version="1.0"?> |
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"> |
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"> |
3 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
4 All rights reserved. |
4 All rights reserved. |
5 This component and the accompanying materials are made available |
5 This component and the accompanying materials are made available |
6 under the terms of "Eclipse Public License v1.0" |
6 under the terms of the License "Eclipse Public License v1.0" |
7 which accompanies this distribution, and is available |
7 which accompanies this distribution, and is available |
8 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
9 |
9 |
10 Initial Contributors: |
10 Initial Contributors: |
11 Nokia Corporation - initial contribution. |
11 Nokia Corporation - initial contribution. |
12 Contributors: |
12 Contributors: |
13 Description: |
13 Description: |
14 Filter a sysdef in the 2.0 or 3.0 syntax |
14 Filter a sysdef in the 2.0 or 3.0 syntax |
|
15 The functionality of these filters is not supported outside of this tool. |
|
16 The filtering concepts here may not be carried forward in future system definition processing tools |
15 --> |
17 --> |
|
18 <!--Description:This filters a sysdef in either the 2.0 or 3.0 syntax |
|
19 If using the 3.0 syntax, specific IDs optionally be included verbatim |
|
20 --> |
|
21 |
|
22 <!--Input:<sysdef> - (required) The system definition XML file to process. |
|
23 Can be in the 2.0 or 3.0 format, and can be a fragment or |
|
24 stand-alone.--> |
|
25 <!--Output:<sysdef> - (optional) The system definition XML file to save the |
|
26 output as. If not present it will write to stdout.--> |
|
27 |
16 <xsl:output method="xml" indent="yes"/> |
28 <xsl:output method="xml" indent="yes"/> |
17 |
29 |
18 <xsl:param name="filter-type">only</xsl:param> <!-- only, has or with --> |
30 <xsl:param name="filter-type">only</xsl:param> |
19 |
31 <!-- <type> - The method of filtering. Legal values are: |
20 <xsl:param name="filter"/> <!-- comma-separated list --> |
32 "only" = every component/unit can only have zero or more of |
21 |
33 these specified filters. ie, it can only have filters |
22 <xsl:param name="addbuild" select="0"/> <!-- add a system build section that accepts everything --> |
34 from this list, no other filters are allowed. This |
23 |
35 covers the common use case of "I want anything with gt |
|
36 and or techview, but no other filters" that was the |
|
37 first step in all old symbian.com builds. |
|
38 |
|
39 "has" = every component/unit must have all of these filters. |
|
40 ie it can have any other filters, but all specified |
|
41 filters must all be present. This covers the case where |
|
42 filter="test" identifies tests and there is no special |
|
43 filter to identify things that are not tests. So a |
|
44 filter for "!test" will strip out anything with |
|
45 filter="test" (plus any other filters) for a production |
|
46 build, and a filter of "test" will strip out everything |
|
47 that does not have filter="test" (plus any other |
|
48 filters) for a test build. Opposite filters will |
|
49 generate sets that are exactly opposite to each other. |
|
50 |
|
51 "with" = components/units that have the opposite filter are |
|
52 removed. This covers the old symbian.com case of |
|
53 java, !java and "don't care" components. In other words |
|
54 we have a global feature that every item can be built |
|
55 only when the feature is set, only when the feature is |
|
56 not set, or it does not care and will always be built. |
|
57 So for a !java build only items containing filter="java" |
|
58 are stripped out. For a java build, only items with |
|
59 filter="!java" are stripped out. Anything which does not |
|
60 explicitly mention java are always unaffected. Opposite |
|
61 filters will generate sets which overlap. |
|
62 --> |
|
63 |
|
64 |
|
65 <xsl:param name="filter"/> <!-- <list> - (required) A comma-separated list of filters |
|
66 used to process the sysdef.--> |
|
67 |
|
68 <xsl:param name="addbuild" select="0"/> <!--1 - (optional) If present, it will add a system build |
|
69 section that accepts everything. This is needed for genxml |
|
70 processing --> |
|
71 |
|
72 <xsl:param name="verbatim"/> <!-- <list> - (optional) A comma-separated list of system |
|
73 model IDs to include unfiltered. IDs must take the form as in |
|
74 the document they appear (ie using the same namespace prefix). |
|
75 This does not work on 2.0 syntax sysdefs. --> |
|
76 |
|
77 <xsl:variable name="ID-list" select="concat(',',translate(normalize-space($verbatim),' ',''),',')"/> <!-- remove all spaces from $idlist and add surrounding commas for easier processing--> |
24 |
78 |
25 <xsl:template match="node()|@*"><xsl:copy-of select="."/></xsl:template> |
79 <xsl:template match="node()|@*"><xsl:copy-of select="."/></xsl:template> |
26 <xsl:template match="*"><xsl:param name="data"/> |
80 <xsl:template match="*"><xsl:param name="data"/> |
27 <xsl:copy> |
81 <xsl:copy> |
28 <xsl:copy-of select="@*"/> |
82 <xsl:copy-of select="@*"/> |
36 <xsl:variable name="display"> |
90 <xsl:variable name="display"> |
37 <xsl:apply-templates select="$data" mode="filter"> |
91 <xsl:apply-templates select="$data" mode="filter"> |
38 <xsl:with-param name="item" select="current()"/> |
92 <xsl:with-param name="item" select="current()"/> |
39 </xsl:apply-templates> |
93 </xsl:apply-templates> |
40 </xsl:variable> |
94 </xsl:variable> |
41 |
95 <xsl:if test="$display != 'hide' or ($verbatim != '' and ancestor-or-self::*[contains($ID-list,concat(',',@id,','))])"> |
42 <xsl:if test="$display != 'hide' "> <!-- if hide, remove completely from the output--> |
96 <!-- if 'hide', remove completely from the output, but always include any ID listed as a $ID-list item--> |
43 <xsl:copy> |
97 <xsl:copy> |
44 <xsl:copy-of select="@*"/> |
98 <xsl:copy-of select="@*"/> |
45 <xsl:apply-templates select="node()"> |
99 <xsl:apply-templates select="node()"> |
46 <xsl:with-param name="data" select="$data"/> |
100 <xsl:with-param name="data" select="$data"/> |
47 </xsl:apply-templates> |
101 </xsl:apply-templates> |