dd2tree.xsl
5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<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">
<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">
<group 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>
</group>
</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:when test="observatory">
<xsl:for-each select="observatory">
<observatory 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}">
<xsl:for-each select="dataset">
<xsl:apply-templates select="."/>
</xsl:for-each>
</instrument>
</xsl:for-each>
</observatory>
</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">
<datasetGroup att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}" restricted="{@restricted}">
<xsl:for-each select="dataset">
<xsl:apply-templates select="."/>
</xsl:for-each>
</datasetGroup>
</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: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::*) > 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>