source: metadata/trunk/toolkit/xslt/clean_component.xsl @ 180

Last change on this file since 180 was 180, checked in by dietuyt, 14 years ago

Restructuring of clarin-nl components, moved addtional XSLTs to
separate directory, addition of component cleaning XSLT

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!-- for questions and suggestions: dietuyt@mpi.nl -->
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
4    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
5   
6    <!-- identity copy -->
7    <xsl:template match="@*|node()">
8        <xsl:copy>
9            <xsl:apply-templates select="@*|node()"/>
10        </xsl:copy>
11    </xsl:template>
12   
13    <!-- throw out the reference to the local copy of the XSD generated by oXygen -->
14    <xsl:template match="@xsi:noNamespaceSchemaLocation"/>
15   
16    <!-- clean up the document node -->
17    <xsl:template match="CMD_ComponentSpec">
18        <!-- lesson: work bottom-up, you cannot change an attribute of an already created/copied node -->
19        <xsl:copy>
20            <!-- first copy all attributes (if wanted)-->
21            <xsl:apply-templates select="@*"/>
22               
23            <!-- add reference to the online CMDI schema -->
24            <xsl:attribute name="xsi:schemaLocation">http://www.clarin.eu/cmd http://www.clarin.eu/cmd/general-component-schema.xsd</xsl:attribute>   
25               
26            <!-- add this isProfile attribute (if it's not existing yet) -->
27            <xsl:if test="not(@isProfile)">
28                <xsl:attribute name="isProfile">false</xsl:attribute>
29            </xsl:if>
30           
31            <!-- now copy all nodes  -->
32            <xsl:apply-templates select="node()"/>
33               
34        </xsl:copy>
35       
36           
37     </xsl:template>
38
39
40    <xsl:template name="main">
41        <xsl:for-each select="collection('file:///.?select=*.xml;recurse=no;on-error=ignore')">
42            <xsl:result-document href="{document-uri(.)}.cmdi">
43                <xsl:apply-templates select="."/>
44            </xsl:result-document>
45        </xsl:for-each>
46    </xsl:template>
47
48</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.