[28361] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
| 2 | <xsl:stylesheet version="1.0"
|
---|
| 3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 4 | xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
---|
| 5 | xmlns:xalan="http://xml.apache.org/xslt">
|
---|
| 6 |
|
---|
| 7 | <!-- Change these values to match the desired namespace and metadata set name. -->
|
---|
| 8 | <xsl:variable name="namespace">cdwalite</xsl:variable>
|
---|
| 9 | <xsl:variable name="setName">CDWALite</xsl:variable>
|
---|
| 10 |
|
---|
| 11 | <!-- for CDWALite, processing starts at this element. May be different for other metadata sets in XSD format. change "descriptiveMetadata" to appropriate root element-->
|
---|
| 12 | <xsl:variable name="startElement">descriptiveMetadata</xsl:variable>
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="4"/>
|
---|
| 16 | <xsl:strip-space elements="*"/>
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | <xsl:template match="xsd:element[@name=$startElement]">
|
---|
| 20 | <xsl:call-template name="elements"/>
|
---|
| 21 | </xsl:template>
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | <xsl:template name="elements">
|
---|
| 25 | <xsl:for-each select="xsd:complexType/xsd:sequence/xsd:element">
|
---|
| 26 | <xsl:variable name="elementName" select="substring-after(@ref, ':')"/>
|
---|
| 27 |
|
---|
| 28 | <xsl:for-each select="ancestor::xsd:schema/xsd:element[@name=$elementName]">
|
---|
| 29 | <Element name="{@name}">
|
---|
| 30 | <Language code="en">
|
---|
| 31 | <Attribute name="label"><xsl:value-of select="@name"/></Attribute>
|
---|
| 32 | <Attribute name="definition"><xsl:value-of select="xsd:annotation/xsd:documentation"/></Attribute>
|
---|
| 33 | <Attribute name="comment"/>
|
---|
| 34 | </Language>
|
---|
| 35 |
|
---|
| 36 | <xsl:call-template name="elements"/>
|
---|
| 37 | </Element>
|
---|
| 38 | </xsl:for-each>
|
---|
| 39 | </xsl:for-each>
|
---|
| 40 | </xsl:template>
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 | <xsl:template match="/">
|
---|
| 44 | <xsl:text disable-output-escaping='yes'><!DOCTYPE MetadataSet SYSTEM "http://www.greenstone.org/dtd/MetadataSet/1.0/MetadataSet.dtd"></xsl:text>
|
---|
| 45 | <MetadataSet contact="" creator="" family="" lastchanged="" namespace="{$namespace}">
|
---|
| 46 | <SetLanguage code="en">
|
---|
| 47 | <Name><xsl:value-of select="$setName"/></Name>
|
---|
| 48 | <Description/>
|
---|
| 49 | </SetLanguage>
|
---|
[28363] | 50 | <xsl:apply-templates select="xsd:schema/xsd:element[@name=$startElement]"/>
|
---|
[28361] | 51 | </MetadataSet>
|
---|
| 52 |
|
---|
| 53 | </xsl:template>
|
---|
| 54 |
|
---|
| 55 | </xsl:stylesheet> |
---|