dd2WStree.xsl 6.45 KB
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml"/>

    <xsl:template match="dataRoot/dataCenter">
        <dataRoot>
            <dataCenter name="AMDA" desc="AMDA_Internal_Data_Base" xml:id="myLocalData-treeRootNode">
                <xsl:for-each select="mission">
                    <xsl:choose>
                        <xsl:when test="not(observatory)">
			  <xsl:if test="@available = '1'">
                            <mission att="{@attention}" name="{@name}" rank="{@rank}" xml:id="{@name}" desc="{@desc}" target="{@target}" available="{@available}">
                                <xsl:choose>
                                    <xsl:when test="group">
                                        <xsl:for-each select="group">
                                            <xsl:if test="@restricted = ''">
                                                <xsl:for-each select="instrument">
                                                  <instrument att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}" restricted="{@restricted}">
                                                    <xsl:for-each select="dataset">
                                                        <xsl:apply-templates select="."/>
                                                    </xsl:for-each>
                                                  </instrument>
                                                </xsl:for-each>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </xsl:when>

                                    <xsl:when test="simulationModel">
                                        <xsl:for-each select="simulationModel">
                                            <simulationModel att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}" restricted="{@restricted}">
                                                <xsl:for-each select="instrument">
                                                  <instrument att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}" restricted="{@restricted}">
                                                    <xsl:for-each select="dataset">
                                                        <xsl:apply-templates select="."/>
                                                    </xsl:for-each>
                                                  </instrument>
                                                </xsl:for-each>
                                            </simulationModel>
                                        </xsl:for-each>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:for-each select="instrument">
                                            <instrument att="{@attention}" name="{@name}" xml:id="{parent::mission/@name}:{@name}" desc="{@desc}" restricted="{@restricted}">
                                                        <xsl:for-each select="datasetGroup">
                                                            <xsl:if test="@restricted = ''">
                                                                <xsl:for-each select="dataset">
                                                                    <xsl:apply-templates select="."/>
                                                                </xsl:for-each>
                                                            </xsl:if>
                                                        </xsl:for-each>
                                                    <xsl:for-each select="dataset">
                                                        <xsl:apply-templates select="."/>
                                                    </xsl:for-each>
                                            </instrument>
                                        </xsl:for-each>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </mission>
                           </xsl:if> 
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:for-each select="observatory">
				<xsl:if test="parent::mission/@available = '1'">
                                <mission att="{parent::mission/@attention}" name="{@name}" rank="{parent::mission/@rank}" xml:id="{@xml:id}" desc="{parent::mission/@desc}" target="{parent::mission/@target}" available="{parent::mission/@available}">
                                    <xsl:for-each select="instrument">
                                        <instrument att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}">
                                            <xsl:for-each select="dataset">
                                                <xsl:apply-templates select="."/>
                                            </xsl:for-each>
                                        </instrument>
                                    </xsl:for-each>
                                </mission>
                              </xsl:if>  
                            </xsl:for-each>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>
            </dataCenter>
        </dataRoot>
    </xsl:template>
    <xsl:template match="dataset">
        <dataset att="{@attention}" restricted="{@restricted}" name="{@name}" xml:id="{@xml:id}"
            sampling="{@sampling}" maxSampling="{@maxSampling}" dataStart="{@dataStart}"
            dataStop="{@dataStop}" dataSource="{@dataSource}" target="{@target}">
            <xsl:for-each select="parameter">
                <xsl:choose>
                    <xsl:when test="count(./child::*) &gt; 0 ">
                        <parameter name="{@name}" units="{@units}" display_type="{@display_type}"
                            xml:id="{@xml:id}">
                            <xsl:for-each select="component">
                                <component name="{@name}" xml:id="{@xml:id}"/>
                            </xsl:for-each>
                        </parameter>
                    </xsl:when>
                    <xsl:otherwise>
                        <parameter name="{@name}" display_type="{@display_type}" units="{@units}"
                            xml:id="{@xml:id}"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
        </dataset>
    </xsl:template>
</xsl:stylesheet>