Changeset 6683 for metadata/trunk/toolkit/src/main/resources/toolkit/upgrade/cmd-record-1_1-to-1_2.xsl
- Timestamp:
- 10/17/15 07:12:51 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
metadata/trunk/toolkit/src/main/resources/toolkit/upgrade/cmd-record-1_1-to-1_2.xsl
r6262 r6683 17 17 <xsl:variable name="cr-profiles" select="concat($cr-uri,'/profiles')"/> 18 18 <xsl:variable name="cr-extension-xsd" select="'-1_2.xsd'"/> 19 19 <xsl:variable name="cr-extension-xml" select="'.xml'"/> 20 20 21 <!-- identity copy --> 21 22 <xsl:template match="@*|node()"> … … 57 58 <xsl:variable name="cmd-profile-uri" select="concat($cmd-profiles,'/',$profile)"/> 58 59 <xsl:variable name="cr-profile-xsd" select="concat($cr-profiles,'/',$profile,$cr-extension-xsd)"/> 60 <xsl:variable name="cr-profile-xml" select="concat($cr-profiles,'/',$profile,$cr-extension-xml)"/> 59 61 60 62 <!-- CMD version becomes 1.2 --> … … 146 148 147 149 <!-- move CMD attributes to the CMD namespace --> 148 <!-- TODO: @ref is allowed on elements, how to know if this is a element or a component with no children? -->149 <!--<xsl:template match="cmd0:Components//*[exists(*)]/@ref">-->150 150 <xsl:template match="cmd0:Components//@ref"> 151 <xsl:attribute name="cmd:ref" select="."/> 151 <xsl:choose> 152 <xsl:when test="exists(parent::*/text()[normalize-space()!=''])"> 153 <!-- this is an element keep the @ref --> 154 <xsl:copy/> 155 </xsl:when> 156 <xsl:when test="exists(../parent::*/node()) or exists(../parent::*/@ComponentId)"> 157 <!-- the parent is a component add the namespace to @ref --> 158 <xsl:attribute name="cmd:ref" select="."/> 159 </xsl:when> 160 <xsl:otherwise> 161 <!-- don't know if the parent is a component without children, or an element without value 162 have a look at the profile --> 163 <xsl:variable name="prof" select="doc(resolve-uri($cr-profile-xml,base-uri()))"/> 164 <xsl:variable name="path" select="ancestor::*[. >> /cmd0:CMD/cmd0:Components]"/> 165 <xsl:variable name="attr" select="$prof//Attribute[Name='ref'][string-join(ancestor::*[local-name()=('CMD_Component','CMD_Element')]/@name,'/')=string-join($path/local-name(),'/')]"/> 166 <xsl:choose> 167 <xsl:when test="exists($attr/parent::AttributeList/parent::CMD_Component)"> 168 <!-- the parent is a component add the namespace to @ref --> 169 <xsl:message>!MENZO: the parent is a component add the namespace to @ref</xsl:message> 170 <xsl:attribute name="cmd:ref" select="."/> 171 </xsl:when> 172 <xsl:otherwise> 173 <!-- this is an element keep the @ref --> 174 <xsl:message>!MENZO: the parent is an element keep the @ref</xsl:message> 175 <xsl:copy/> 176 </xsl:otherwise> 177 </xsl:choose> 178 </xsl:otherwise> 179 </xsl:choose> 152 180 </xsl:template> 153 181
Note: See TracChangeset
for help on using the changeset viewer.