<commit_before><?xml version="1.0" encoding="UTF-8"?>

<!-- 
    $Rev: 484 $ 
    $Date: 2011-10-21 12:01:58 +0200 (Fri, 21 Oct 2011) $ 
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org/ns/dcr"
    xmlns:ann="http://www.clarin.eu">
    
    <xsl:variable name="CMDVersion" select="'1.1'"/>

    <xsl:strip-space elements="*"/>
    <xsl:include href="comp2schema-header.xsl"/>
    <!-- note: the automatic chaining with clean-xsd.xsl only works with the Saxon XSLT processor, otherwise you'll have to do this manually (or use e.g the Xalan pipeDocument tag) -->
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" saxon:indent-spaces="1"
        saxon:next-in-chain="cleanup-xsd.xsl" xmlns:saxon="http://saxon.sf.net/"/>

    <!-- Start includes -->

    <!-- resolve includes -->
    <xsl:template match="@*|node()" mode="include">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" mode="include"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="CMD_Component[@filename]" mode="include">
        <!-- some of the outer CMD_Component attributes can overwrite the inner CMD_Component attributes -->
        <xsl:variable name="outer-attr" select="@CardinalityMin|@CardinalityMax"/>
        <xsl:for-each select="document(@filename)/CMD_ComponentSpec/CMD_Component">
            <xsl:variable name="inner-attr" select="@*"/>
            <xsl:copy>
                <xsl:apply-templates select="$outer-attr" mode="include"/>
                <xsl:apply-templates
                    select="$inner-attr[not(node-name(.) = $outer-attr/node-name(.))]"
                    mode="include"/>
                <xsl:apply-templates select="node()" mode="include"/>
            </xsl:copy>
        </xsl:for-each>
    </xsl:template>

    <!-- Stop includes -->

    <!-- main -->
    <xsl:template match="/">
        <!-- Resolve all includes -->
        <xsl:variable name="tree">
            <xsl:apply-templates mode="include"/>
        </xsl:variable>
        <!-- Process the complete tree -->
        <xsl:apply-templates select="$tree/*"/>
    </xsl:template>

    <!-- generate XSD -->
    <xsl:template match="/CMD_ComponentSpec">

        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org/ns/dcr" xmlns:kin="http://mpi.nl/tla/kin" xmlns:cmd="http://www.clarin.eu/cmd/" targetNamespace="http://www.clarin.eu/cmd/" elementFormDefault="qualified">

            <!-- import this for the use of the xml:lang attribute -->
            <xs:import namespace="http://www.w3.org/XML/1998/namespace"
                schemaLocation="http://www.w3.org/2001/xml.xsd"/>


            <!--  first create complex types for valueschemes (not inline) -->
            <xsl:call-template name="CreateComplexTypes"/>

            <!-- then create simple type for the ResourceProxy -->
            <xsl:call-template name="PrintHeaderType"/>


            <xs:element name="Kinnate">
                <xs:complexType>
                    
                    <xs:sequence>

                        <!-- Produce (fixed) header elements (description and resources)-->
                        <xsl:call-template name="PrintHeader"/>

                        <!-- Then generate the components -->
                        <xs:element name="Metadata">

                            <xs:complexType>
                                <xs:sequence><commit_msg>Started to add a clarin bridge schema so that clarin profiles can be used for entity metadata. Much work on this is still required.<commit_after><?xml version="1.0" encoding="UTF-8"?>

<!-- 
    $Rev: 484 $ 
    $Date: 2011-10-21 12:01:58 +0200 (Fri, 21 Oct 2011) $ 
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org/ns/dcr"
    xmlns:ann="http://www.clarin.eu">
    
    <xsl:variable name="CMDVersion" select="'1.1'"/>

    <xsl:strip-space elements="*"/>
    <xsl:include href="comp2schema-header.xsl"/>
    <!-- note: the automatic chaining with clean-xsd.xsl only works with the Saxon XSLT processor, otherwise you'll have to do this manually (or use e.g the Xalan pipeDocument tag) -->
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" saxon:indent-spaces="1"
        saxon:next-in-chain="cleanup-xsd.xsl" xmlns:saxon="http://saxon.sf.net/"/>

    <!-- Start includes -->

    <!-- resolve includes -->
    <xsl:template match="@*|node()" mode="include">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" mode="include"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="CMD_Component[@filename]" mode="include">
        <!-- some of the outer CMD_Component attributes can overwrite the inner CMD_Component attributes -->
        <xsl:variable name="outer-attr" select="@CardinalityMin|@CardinalityMax"/>
        <xsl:for-each select="document(@filename)/CMD_ComponentSpec/CMD_Component">
            <xsl:variable name="inner-attr" select="@*"/>
            <xsl:copy>
                <xsl:apply-templates select="$outer-attr" mode="include"/>
                <xsl:apply-templates
                    select="$inner-attr[not(node-name(.) = $outer-attr/node-name(.))]"
                    mode="include"/>
                <xsl:apply-templates select="node()" mode="include"/>
            </xsl:copy>
        </xsl:for-each>
    </xsl:template>

    <!-- Stop includes -->

    <!-- main -->
    <xsl:template match="/">
        <!-- Resolve all includes -->
        <xsl:variable name="tree">
            <xsl:apply-templates mode="include"/>
        </xsl:variable>
        <!-- Process the complete tree -->
        <xsl:apply-templates select="$tree/*"/>
    </xsl:template>

    <!-- generate XSD -->
    <xsl:template match="/CMD_ComponentSpec">

        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org/ns/dcr" xmlns:cmd="http://www.clarin.eu/cmd/" targetNamespace="http://www.clarin.eu/cmd/" elementFormDefault="qualified">
                                                                                        <!--xmlns:kin="http://mpi.nl/tla/kin" -->
            <!-- import this for the use of the xml:lang attribute -->
            <xs:import namespace="http://www.w3.org/XML/1998/namespace"
                schemaLocation="http://www.w3.org/2001/xml.xsd"/>


            <!--  first create complex types for valueschemes (not inline) -->
            <xsl:call-template name="CreateComplexTypes"/>

            <!-- then create simple type for the ResourceProxy -->
            <xsl:call-template name="PrintHeaderType"/>


            <xs:element name="Kinnate">
                <xs:complexType>
                    
                    <xs:sequence>

                        <!-- Produce (fixed) header elements (description and resources)-->
                        <xsl:call-template name="PrintHeader"/>

                        <!-- Then generate the components -->
                        <xs:element name="Metadata">

                            <xs:complexType>
                                <xs:sequence>
{'fraction_non_alphanumeric': 0.1698009608785175, 'fraction_numerical': 0.01757035003431709, 'mean_word_length': 2.1405172413793103, 'pattern_counts': {'":': 0, '<': 114, '<?xml version=': 2, '>': 114, 'https://': 0, 'lorem ipsum': 0, 'www.': 20, 'xml': 26}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '405759', 'n_tokens_mistral': 2293, 'n_tokens_neox': 2016, 'n_words': 410}