metatools/sysdeftools/joinandparesysdef.xsl
changeset 624 f70b728ea30c
equal deleted inserted replaced
621:96fee2635b19 624:f70b728ea30c
       
     1 <?xml version="1.0"?>
       
     2  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       
     3 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 	All rights reserved.
       
     5 	This component and the accompanying materials are made available
       
     6 	under the terms of the License "Eclipse Public License v1.0"
       
     7 	which accompanies this distribution, and is available
       
     8 	at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     9 
       
    10 	Initial Contributors:
       
    11 	Nokia Corporation - initial contribution.
       
    12 	Contributors:
       
    13 	Description:
       
    14 	Create a stand-alone sysdef from a linked set of fragments, paring down to just a set of items of the desired rank.
       
    15 -->
       
    16  	<xsl:output method="xml" indent="yes"/>
       
    17 
       
    18 <!--Description:This pares the generated sysdef down to just a set of items of the desired
       
    19 rank. In other words, you provide a list of IDs to keep and a system model
       
    20 rank (layer, package, collection, component). 
       
    21 Every item of that rank in the sysdef will be removed except those in the list
       
    22 of IDs.
       
    23 Primary use cases of this would be to extract a single layer, or to select a
       
    24 specific set of packages.
       
    25 
       
    26 -->
       
    27 <xsl:param name="pare"/>		
       
    28 	<!--<list> - (required) A comma-separated list of IDs in the literal from as the document they appear in (ie same namespace prefix) -->
       
    29 
       
    30 <xsl:param name="rank">package</xsl:param>
       
    31 	<!--<rank> = the rank item to pare down. This will remove any item of that rank EXCEPT those in $pare -->
       
    32 
       
    33 <xsl:variable name="pare-list" select="concat(',',translate(normalize-space($pare),' ',','),',')"/> <!-- accept spaces in pare. Pad with commas to make computing easier -->
       
    34 
       
    35 <xsl:include href="joinsysdef.xsl"/>  
       
    36 
       
    37 <xsl:template match="/SystemDefinition[systemModel]">
       
    38 	<xsl:apply-templates select="." mode="join">
       
    39 		<xsl:with-param name="filename" select="$path"/>
       
    40 		<xsl:with-param name="data" select="current()"/> <!-- just has to be non-empty -->
       
    41 	</xsl:apply-templates>
       
    42 </xsl:template>
       
    43 
       
    44 <xsl:template match="*" mode="filter"> <!-- use this to strip out the unwanted items -->
       
    45 	<xsl:param name="item" />
       
    46 	<xsl:if test="$rank=name($item) and not(contains($pare-list,concat(',',$item/@id,',')))">hide</xsl:if>
       
    47 </xsl:template>
       
    48 
       
    49 </xsl:stylesheet>